Advisory

RUSTSEC-2024-0359

Also known as: GHSA-cx7h-h87r-jpgr

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.

*Thanks to Devin Jeanpierre for discovering and reporting this issue.*

Severity

Not rated by the source.

Dates

Published
2024-07-24 12:00 UTC
Modified
2025-01-19 00:59 UTC

Affected packages and fixes

gix-attributes

crates.io · All systems

Affected

  • introduced 0.0.0-0, fixed 0.22.3 (semver)

Fixed versions

0.22.3

Fix

  • Fixed version 0.22.3
    cargo update -p gix-attributes --precise 0.22.3

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences