{"id":"GHSA-cx7h-h87r-jpgr","aliases":["GHSA-cx7h-h87r-jpgr","RUSTSEC-2024-0359"],"related":[],"kind":"vulnerability","state":"published","title":"The kstring integration in gix-attributes is unsound","summary":"`gix-attributes` (in [`state::ValueRef`](https://github.com/Byron/gitoxide/blob/gix-attributes-v0.22.2/gix-attributes/src/state.rs#L19-L27)) unsafely creates a `&str` from a `&[u8]` containing non-UTF8 data, with the justification that so long as nothing reads the `&str` and relies on it being UTF-8 in the `&str`, there is no UB:\n\n```rust\n// SAFETY: our API makes accessing that value as `str` impossible, so illformed UTF8 is never exposed as such.\n```\n\nThe problem is that the non-UTF8 `str` **is** exposed to outside code: first to the `kstring` crate itself, which requires UTF-8 in its documentation and may have UB as a consequence of this, but also to `serde`, where it propagates to e.g. `serde_json`, `serde_yaml`, etc., where the same problems occur.\n\nThis is not sound, and it could cause further UB down the line in these places that can view the `&str`.","summaryFormat":"markdown","summarySource":"ghsa","descriptions":[{"lang":"en","text":"`gix-attributes` (in [`state::ValueRef`](https://github.com/Byron/gitoxide/blob/gix-attributes-v0.22.2/gix-attributes/src/state.rs#L19-L27)) unsafely creates a `&str` from a `&[u8]` containing non-UTF8 data, with the justification that so long as nothing reads the `&str` and relies on it being UTF-8 in the `&str`, there is no UB:\n\n```rust\n// SAFETY: our API makes accessing that value as `str` impossible, so illformed UTF8 is never exposed as such.\n```\n\nThe problem is that the non-UTF8 `str` **is** exposed to outside code: first to the `kstring` crate itself, which requires UTF-8 in its documentation and may have UB as a consequence of this, but also to `serde`, where it propagates to e.g. `serde_json`, `serde_yaml`, etc., where the same problems occur.\n\nThis is not sound, and it could cause further UB down the line in these places that can view the `&str`.","format":"markdown","source":"ghsa"},{"lang":"en","text":"`gix-attributes` (in [`state::ValueRef`](https://github.com/Byron/gitoxide/blob/gix-attributes-v0.22.2/gix-attributes/src/state.rs#L19-L27)) unsafely creates a `&str` from a `&[u8]` containing non-UTF8 data, with the justification that so long as nothing reads the `&str` and relies on it being UTF-8 in the `&str`, there is no UB:\n\n```rust\n// SAFETY: our API makes accessing that value as `str` impossible, so illformed UTF8 is never exposed as such.\n```\n\nThe problem is that the non-UTF8 `str` **is** exposed to outside code: first to the `kstring` crate itself, which requires UTF-8 in its documentation and may have UB as a consequence of this, but also to `serde`, where it propagates to e.g. `serde_json`, `serde_yaml`, etc., where the same problems occur.\n\nThis is not sound, and it could cause further UB down the line in these places that can view the `&str`.\n\n*Thanks to [Devin Jeanpierre](https://github.com/ssbr) for discovering and reporting this issue.*","format":"markdown","source":"rustsec"}],"published":"2024-07-24T12:00:00.000Z","modified":"2026-09-10T03:50:16.580Z","severity":{"scorer":"GitHub","scheme":"rating","rating":"LOW"},"severities":[{"scorer":"GitHub","scheme":"rating","rating":"LOW"}],"cwes":["CWE-172"],"affected":[{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.22.3"}],"ecosystem":"crates.io","package":"gix-attributes","purl":"pkg:cargo/gix-attributes","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.22.3"}],"ecosystem":"crates.io","package":"gix-attributes","purl":"pkg:cargo/gix-attributes","source":"rustsec"}],"references":[{"url":"https://github.com/Byron/gitoxide/issues/1460","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/GitoxideLabs/gitoxide/issues/1460","tags":["report","web"],"sources":["ghsa","rustsec"]},{"url":"https://github.com/rustsec/advisory-db/commit/884aaa1646132bc3a27ba058197d6ef039bec294","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/Byron/gitoxide","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2024-0359.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/gix-attributes","tags":["package"],"sources":["rustsec"]}],"credits":[],"sources":[{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-cx7h-h87r-jpgr","url":"https://github.com/advisories/GHSA-cx7h-h87r-jpgr","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:16.580Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2024-0359","url":"https://rustsec.org/advisories/RUSTSEC-2024-0359.html","licence":"CC0-1.0","modified":"2025-01-19T00:59:32.710Z"}],"updatedAt":"2026-11-25T22:56:43.206Z"}