{ "schema_version": "1.4.0", "id": "GHSA-2frx-2596-x5r6", "modified": "2025-04-04T16:06:09Z", "published": "2025-04-04T16:06:08Z", "aliases": [ "CVE-2025-31130" ], "summary": "gitoxide does not detect SHA-1 collision attacks", "details": "### Summary\ngitoxide uses SHA-1 hash implementations without any collision detection, leaving it vulnerable to hash collision attacks.\n\n### Details\ngitoxide uses the `sha1_smol` or `sha1` crate, both of which implement standard SHA-1 without any mitigations for collision attacks. This means that two distinct Git objects with colliding SHA-1 hashes would break the Git object model and integrity checks when used with gitoxide.\n\nThe SHA-1 function is considered cryptographically insecure. However, in the wake of the SHAttered attacks, this issue was mitigated in Git 2.13.0 in 2017 by using the [sha1collisiondetection](https://github.com/crmarcstevens/sha1collisiondetection) algorithm by default and producing an error when known SHA-1 collisions are detected. Git is in the process of migrating to using SHA-256 for object hashes, but this has not been rolled out widely yet and gitoxide does not support SHA-256 object hashes.\n\n### PoC\nThe following program demonstrates the problem, using the two [SHAttered PDFs](https://shattered.io/):\n\n```rust\nuse sha1_checked::{CollisionResult, Digest};\n\nfn sha1_oid_of_file(filename: &str) -> gix::ObjectId {\n let mut hasher = gix::features::hash::hasher(gix::hash::Kind::Sha1);\n hasher.update(&std::fs::read(filename).unwrap());\n gix::ObjectId::Sha1(hasher.digest())\n}\n\nfn sha1dc_oid_of_file(filename: &str) -> Result {\n // Matches Git’s behaviour.\n let mut hasher = sha1_checked::Builder::default().safe_hash(false).build();\n hasher.update(&std::fs::read(filename).unwrap());\n match hasher.try_finalize() {\n CollisionResult::Ok(digest) => Ok(gix::ObjectId::Sha1(digest.into())),\n CollisionResult::Mitigated(_) => unreachable!(),\n CollisionResult::Collision(digest) => Err(format!(\n \"Collision attack: {}\",\n gix::ObjectId::Sha1(digest.into()).to_hex()\n )),\n }\n}\n\nfn main() {\n dbg!(sha1_oid_of_file(\"shattered-1.pdf\"));\n dbg!(sha1_oid_of_file(\"shattered-2.pdf\"));\n dbg!(sha1dc_oid_of_file(\"shattered-1.pdf\"));\n dbg!(sha1dc_oid_of_file(\"shattered-2.pdf\"));\n}\n```\n\nThe output is as follows:\n\n```\n[src/main.rs:24:5] sha1_oid_of_file(\"shattered-1.pdf\") = Sha1(38762cf7f55934b34d179ae6a4c80cadccbb7f0a)\n[src/main.rs:25:5] sha1_oid_of_file(\"shattered-2.pdf\") = Sha1(38762cf7f55934b34d179ae6a4c80cadccbb7f0a)\n[src/main.rs:26:5] sha1dc_oid_of_file(\"shattered-1.pdf\") = Err(\n \"Collision attack: 38762cf7f55934b34d179ae6a4c80cadccbb7f0a\",\n)\n[src/main.rs:27:5] sha1dc_oid_of_file(\"shattered-2.pdf\") = Err(\n \"Collision attack: 38762cf7f55934b34d179ae6a4c80cadccbb7f0a\",\n)\n```\n\nThe latter behaviour matches Git.\n\nSince the SHAttered PDFs are not in a valid format for Git objects, a direct proof‐of‐concept using higher‐level APIs cannot be immediately demonstrated without significant computational resources.\n\n### Impact\nAn attacker with the ability to mount a collision attack on SHA-1 like the [SHAttered](https://shattered.io/) or [SHA-1 is a Shambles](https://sha-mbles.github.io/) attacks could create two distinct Git objects with the same hash. This is becoming increasingly affordable for well‐resourced attackers, with the Shambles researchers in 2020 estimating $45k for a chosen‐prefix collision or $11k for a classical collision, and projecting less than $10k for a chosen‐prefix collision by 2025. The result could be used to disguise malicious repository contents, or potentially exploit assumptions in the logic of programs using gitoxide to cause further vulnerabilities.\n\nThis vulnerability affects any user of gitoxide, including `gix-*` library crates, that reads or writes Git objects.", "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N" } ], "affected": [ { "package": { "ecosystem": "crates.io", "name": "gix-features" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.41.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-commitgraph" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.27.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-index" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.39.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-object" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.48.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-odb" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.68.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-pack" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.58.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gitoxide" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.42.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gitoxide-core" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.46.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.71.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-archive" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.20.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-blame" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.1.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-config" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.44.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-diff" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.51.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-dir" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.13.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-discover" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.39.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-filter" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.18.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-fsck" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.10.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-merge" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.4.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-negotiate" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.19.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-protocol" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.49.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-ref" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.51.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-revision" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.33.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-revwalk" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.19.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-status" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.18.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-traverse" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.45.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-worktree" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.40.0" } ] } ] }, { "package": { "ecosystem": "crates.io", "name": "gix-worktree-state" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0" }, { "fixed": "0.18.0" } ] } ] } ], "references": [ { "type": "WEB", "url": "https://github.com/GitoxideLabs/gitoxide/security/advisories/GHSA-2frx-2596-x5r6" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-31130" }, { "type": "WEB", "url": "https://github.com/GitoxideLabs/gitoxide/commit/4660f7a6f71873311f68f170b0f1f6659a02829d" }, { "type": "PACKAGE", "url": "https://github.com/GitoxideLabs/gitoxide" }, { "type": "WEB", "url": "https://rustsec.org/advisories/RUSTSEC-2025-0021.html" } ], "database_specific": { "cwe_ids": [ "CWE-328" ], "severity": "MODERATE", "github_reviewed": true, "github_reviewed_at": "2025-04-04T16:06:08Z", "nvd_published_at": "2025-04-04T15:15:48Z" } }