RUSTSEC-2024-0359

See a problem?
Source
https://rustsec.org/advisories/RUSTSEC-2024-0359
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2024-0359.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2024-0359
Published
2024-07-24T12:00:00Z
Modified
2024-07-24T23:36:13Z
Summary
The kstring integration in gix-attributes is unsound
Details

gix-attributes (in state::ValueRef) 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:

// SAFETY: our API makes accessing that value as `str` impossible, so illformed UTF8 is never exposed as such.

The 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.

This is not sound, and it could cause further UB down the line in these places that can view the &str.

References

Affected packages

crates.io / gix-attributes

Package

Name
gix-attributes
View open source insights on deps.dev
Purl
pkg:cargo/gix-attributes

Affected ranges

Type
SEMVER
Events
Introduced
0.0.0-0
Fixed
0.22.3

Ecosystem specific

{
    "affected_functions": null,
    "affects": {
        "os": [],
        "functions": [],
        "arch": []
    }
}

Database specific

{
    "cvss": null,
    "informational": "unsound",
    "categories": []
}