GHSA-cx7h-h87r-jpgr: Gix attributes The Kstring Integration Vulnerability

LOW
CWE-172
Published
Advisory Summary

GHSA-cx7h-h87r-jpgr is a LOW the kstring integration vulnerability (CWE-172: Encoding Error) affecting Gix attributes libraries in the crates.io ecosystem. The issue involves the kstring integration in gix-attributes is unsound. Remediation is available by upgrading affected packages to version 0.22.3.

GHSA-cx7h-h87r-jpgr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-cx7h-h87r-jpgr
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-172: Encoding Error
Affected Product Gix attributes
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-cx7h-h87r-jpgr

To remediate this vulnerability, upgrade all affected Gix attributes dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gix-attributes fixed: 0.22.3
Upgrade gix-attributes to 0.22.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for gix-attributes

How to Check if You Are Affected

To determine whether your application is affected by GHSA-cx7h-h87r-jpgr, inspect your project dependencies for Gix attributes:

inspect dependencies for gix-attributes

Analyze the terminal output to locate any version of Gix attributes in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.22.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-172: Encoding Error, where the product does not properly encode or decode the data, resulting in unexpected values. In Gix attributes, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

`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: ```rust // 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`.

GHSA-cx7h-h87r-jpgr Affected Gix attributes Versions

1 component(s)
Fixed Versions:
0.22.3
Product / Package Ecosystem Affected Versions Fixed Version
gix-attributes
crates.io
< 0.22.3
0.22.3

References

Frequently Asked Questions

What is GHSA-cx7h-h87r-jpgr?
GHSA-cx7h-h87r-jpgr is a security vulnerability in Gix attributes involving The kstring integration in gix-attributes is unsound under CWE-172: Encoding Error.
Which Gix attributes versions are affected?
Affected versions include releases prior to 0.22.3 across affected packages: gix-attributes.
What version fixes GHSA-cx7h-h87r-jpgr?
Upgrading to 0.22.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gix-attributes affected?
Yes, gix-attributes is affected in releases prior to 0.22.3. Upgrade your dependency to 0.22.3 or later.
What CWE is associated with GHSA-cx7h-h87r-jpgr?
GHSA-cx7h-h87r-jpgr is classified under CWE-172: Encoding Error (The product does not properly encode or decode the data, resulting in unexpected values.).
How can I check crates.io dependencies for GHSA-cx7h-h87r-jpgr?
Run the dependency tree command: 'inspect dependencies for gix-attributes'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cx7h-h87r-jpgr",
  "modified" : "2025-01-21T18:18:40Z",
  "published" : "2024-07-25T16:38:42Z",
  "aliases" : [ ],
  "summary" : "The kstring integration in gix-attributes is unsound",
  "details" : "`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",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gix-attributes"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.22.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Byron/gitoxide/issues/1460"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/GitoxideLabs/gitoxide/issues/1460"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rustsec/advisory-db/commit/884aaa1646132bc3a27ba058197d6ef039bec294"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Byron/gitoxide"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0359.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-172" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-25T16:38:42Z",
    "nvd_published_at" : null
  }
}