# GHSA-c8v3-jhv9-4ppc: Use-after-free when setting the locale

> A use-after-free vulnerability in a Rust locale library allows attackers to cause crashes or execute arbitrary code via concurrent locale changes.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 19 Jan 2024
- **Also known as:** RUSTSEC-2024-0007

## What is GHSA-c8v3-jhv9-4ppc?

GHSA-c8v3-jhv9-4ppc is an use after free vulnerability in rust-i18n-support, published on 19 Jan 2024. 

### Official description

Version 3.0.0 introduced an `AtomicStr` type, that is used to store the current locale. It stores the locale as a raw pointer to an `Arc<String>`. The locale can be read with `AtomicStr::as_str()`. `AtomicStr::as_str()` does not increment the usage counter of the `Arc`.

If the locale is changed in one thread, another thread can have a stale -- possibly already freed -- reference to the stored string.

## Which versions are affected by GHSA-c8v3-jhv9-4ppc?

3 open source packages ship an affected version, including rust-i18n-support.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `rust-i18n-support` | crates.io | From 3.0.0 | 3.0.1 |
| `rust-i18n-support` | crates.io | From 3.0.0 | 3.0.1 |
| `rust-i18n-support` | crates.io | From 3.0.0 | 3.0.1 |

## How do I fix GHSA-c8v3-jhv9-4ppc?

Upgrade rust-i18n-support to 3.0.1 or later.

## Is GHSA-c8v3-jhv9-4ppc being exploited?

There is no known exploitation of GHSA-c8v3-jhv9-4ppc in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-c8v3-jhv9-4ppc and fix it if it is affected.

What it is: GHSA-c8v3-jhv9-4ppc is an use after free vulnerability in rust-i18n-support, published on 19 Jan 2024. 
Exploitation: There is no known exploitation of GHSA-c8v3-jhv9-4ppc in the wild and no public exploit code.

Affected packages and fixed versions:
- rust-i18n-support (crates.io): affected from 3.0.0; fixed in 3.0.1
- rust-i18n-support (crates.io): affected from 3.0.0; fixed in 3.0.1
- rust-i18n-support (crates.io): affected from 3.0.0; fixed in 3.0.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-c8v3-jhv9-4ppc/ (Markdown: https://insights.sbomify.com/GHSA-c8v3-jhv9-4ppc/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-c8v3-jhv9-4ppc

---
From sbomify Insights: https://insights.sbomify.com/GHSA-c8v3-jhv9-4ppc/
Summaries are generated and may contain mistakes; the official description above is the record.
