This project might be open to known security vulnerabilities, which can be prevented by tightening the version range of affected dependencies. Find detailed information at the bottom.

Crate gix

Dependencies

(57 total, 47 outdated, 2 possibly insecure)

CrateRequiredLatestStatus
 async-std^1.12.01.13.1up to date
 document-features^0.2.00.2.11up to date
 gix-actor^0.33.00.35.2out of date
 gix-archive^0.16.00.22.0out of date
 gix-attributes^0.23.00.27.0out of date
 gix-command^0.3.100.6.2out of date
 gix-commitgraph^0.25.00.29.0out of date
 gix-config^0.41.00.46.0out of date
 gix-credentials^0.25.00.30.0out of date
 gix-date^0.9.10.10.3out of date
 gix-diff^0.47.00.53.0out of date
 gix-dir^0.9.00.15.0out of date
 gix-discover^0.36.00.41.0out of date
 gix-features ⚠️^0.39.00.43.0out of date
 gix-filter^0.14.00.20.0out of date
 gix-fs^0.12.00.16.0out of date
 gix-glob^0.17.00.21.0out of date
 gix-hash^0.15.00.19.0out of date
 gix-hashtable^0.6.00.9.0out of date
 gix-ignore^0.12.00.16.0out of date
 gix-index^0.36.00.41.0out of date
 gix-lock^15.0.018.0.0out of date
 gix-mailmap^0.25.00.27.2out of date
 gix-merge^0.0.00.6.0out of date
 gix-negotiate^0.16.00.21.0out of date
 gix-object^0.45.00.50.0out of date
 gix-odb^0.64.00.70.0out of date
 gix-pack^0.54.00.60.0out of date
 gix-path^0.10.120.10.19up to date
 gix-pathspec^0.8.00.12.0out of date
 gix-prompt^0.8.80.11.1out of date
 gix-protocol^0.46.00.51.0out of date
 gix-ref^0.48.00.53.0out of date
 gix-refspec^0.26.00.31.0out of date
 gix-revision^0.30.00.35.0out of date
 gix-revwalk^0.16.00.21.0out of date
 gix-sec^0.10.90.12.0out of date
 gix-status^0.14.00.20.0out of date
 gix-submodule^0.15.00.20.0out of date
 gix-tempfile^15.0.018.0.0out of date
 gix-trace^0.1.110.1.13up to date
 gix-transport^0.43.00.48.0out of date
 gix-traverse^0.42.00.47.0out of date
 gix-url^0.28.00.32.0out of date
 gix-utils^0.1.130.3.0out of date
 gix-validate^0.9.10.10.0out of date
 gix-worktree^0.37.00.42.0out of date
 gix-worktree-state ⚠️^0.14.00.20.0out of date
 gix-worktree-stream^0.16.00.22.0out of date
 once_cell^1.14.01.21.3up to date
 parking_lot^0.12.10.12.4up to date
 prodash^29.0.030.0.1out of date
 regex^1.6.01.11.1up to date
 serde^1.0.1141.0.219up to date
 signal-hook^0.3.90.3.18up to date
 smallvec^1.9.01.15.1up to date
 thiserror^1.0.262.0.12out of date

Dev dependencies

(8 total, all up-to-date)

CrateRequiredLatestStatus
 anyhow^11.0.98up to date
 async-std^1.12.01.13.1up to date
 insta^1.40.01.43.1up to date
 is_ci^1.1.11.2.0up to date
 pretty_assertions^1.4.01.4.1up to date
 serial_test^3.1.03.2.0up to date
 termtree^0.5.10.5.1up to date
 walkdir^2.3.22.5.0up to date

Security Vulnerabilities

gix-worktree-state: gix-worktree-state nonexclusive checkout sets executable files world-writable

RUSTSEC-2025-0001

Summary

gix-worktree-state specifies 0777 permissions when checking out executable files, intending that the umask will restrict them appropriately. But one of the strategies it uses to set permissions is not subject to the umask. This causes files in a repository to be world-writable in some situations.

Details

Git repositories track executable bits for regular files. In tree objects and the index, regular file modes are stored as 0644 if not executable, or 0755 if executable. But this is independent of how the permissions are set in the filesystem (where supported).

gix_worktree_state::checkout has two strategies for checking out a file and marking it executable on a Unix-like operating system, one of which is vulnerable:

  • If the file is created by assuming it does not already exist, correct permissions are applied, because permissions specified when opening a file are subject to the umask.
  • If the file is considered possibly already to exist—even in a clean checkout if the application does not specify the option to treat the destination directory as empty—then permissions conferring unrestricted access to any user account on the system are wrongly applied, because permissions specified when calling chmod on an existing file are not subject to the umask. 

Specifically, checkout::entry::checkout chooses the strategy for each file. The same strategy is usually chosen for each executable file, if no process (i.e. long running) smudge filter is in use. The strategy depends on the checkout::Options::destination_is_initially_empty value, which is passed along to checkout::entry::open_file, whose return value includes a flag indicating whether permissions still need to be set:

finalize_entry is likewise called from checkout::chunk::process_delayed_filter_results.

PoC

  1. On a Unix-like system such as GNU/Linux or macOS, create a new project and define its dependencies. While the vulnerability is in gix-worktree-state, this example will use vulnerable code through the gix crate, which exposes it. Run:

    cargo new checkout-index
    cd checkout-index
    cargo add gix gix-object
    
  2. In the checkout-index directory, edit src/main.rs so that its entire contents are:

    fn main() -> Result<(), Box<dyn std::error::Error>> {
        let repo = gix::discover("has-executable")?;
        let mut index = repo.open_index()?;
        gix::worktree::state::checkout(
            &mut index,
            repo.work_dir().ok_or("need non-bare repo")?,
            gix_object::find::Never, // Can also use: repo.objects.clone()
            &gix::progress::Discard,
            &gix::progress::Discard,
            &Default::default(),
            Default::default(),
        )?;
        Ok(())
    }
    
  3. Create the test repository that the vulnerable program will operate on. Still in the checkout-index directory, run:

    git init has-executable
    touch has-executable/a has-executable/b
    chmod +x has-executable/b
    git -C has-executable add .
    

    It is not necessary to commit the changes, only to stage them, since the test program will check out the index.

  4. Optionally, run rm has-executable/[ab] to remove the staged files from disk.

  5. Run the program by issuing cargo run. The program uses gix-worktree-state to check out the index. It should terminate successfully and not issue any errors.

  6. Run ls -l has-executable to inspect the permissions of the checked out files. Observe that owner, group, and other all have read, write, and execute permissions on b.

    -rw-r--r-- 1 ek ek 0 Jan  9 03:38 a
    -rwxrwxrwx 1 ek ek 0 Jan  9 03:38 b
    

    With affected versions of gix-worktree-state, the output shows -rwxrwxrwx for b, whether the files were removed in step 4 or not.

  7. It was not necessary to set destination_is_initially_empty to false explicitly to trigger the bug, because that is its default value. If desired, modify the program to pass true and rerun the experiment to verify that b is no longer created with excessive permissions. The modified program would change the last checkout argument from Default::default(), to:

            gix::worktree::state::checkout::Options {
                destination_is_initially_empty: true,
                ..Default::default()
            },
    

Impact

Setting unlimited file permissions is a problem on systems where a user account exists on the system that should not have the ability to access and modify the files. That applies to multi-user systems, or when an account is used to run software with reduced abilities. (Some programs may also treat broad write permissions to mean less validation is required.)

This bug affects Unix-like systems but not Windows. The gix clone command is not believed to be affected, due to checkout_exclusive's use of destination_is_initially_empty: true. Specialized uses in which repositories are known never to have any files marked executable are unaffected. Repositories that no untrusted users can access, due to not having the ability to traverse the directories to them or due to sufficiently restrictive ACLs, are likewise unaffected.

The default value of destination_is_initially_empty is false, so some applications may be affected even if they don't attempt checkouts in nonempty directories. The 0777 permissions are applied to files that are created earlier in the same checkout, as well as those that already existed, regardless of their prior permissions. On preexisting files, 0777 is set even if overwrite_existing is false, as that prevents the checkout from changing file contents but not permissions.

Files not tracked/staged as executable are not checked out with insecure permissions. Such a file that previously existed keeps its old permissions. However, this may include executable permissions that no longer match repository metadata, as well as undesired write permissions acquired from a previous vulnerable checkout. set_mode(0o777) clears other bits, so the bug is not exacerbated by the presence of setuid/setgid bits. In some applications, the vulnerable strategy may be used only for files rewritten by a long running smudge filter or only in the presence of delays.

gix-features: SHA-1 collision attacks are not detected

RUSTSEC-2025-0021

Summary

gitoxide uses SHA-1 hash implementations without any collision detection, leaving it vulnerable to hash collision attacks.

Details

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

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

PoC

The following program demonstrates the problem, using the two SHAttered PDFs:

use sha1_checked::{CollisionResult, Digest};

fn sha1_oid_of_file(filename: &str) -> gix::ObjectId {
    let mut hasher = gix::features::hash::hasher(gix::hash::Kind::Sha1);
    hasher.update(&std::fs::read(filename).unwrap());
    gix::ObjectId::Sha1(hasher.digest())
}

fn sha1dc_oid_of_file(filename: &str) -> Result<gix::ObjectId, String> {
    // Matches Git’s behaviour.
    let mut hasher = sha1_checked::Builder::default().safe_hash(false).build();
    hasher.update(&std::fs::read(filename).unwrap());
    match hasher.try_finalize() {
        CollisionResult::Ok(digest) => Ok(gix::ObjectId::Sha1(digest.into())),
        CollisionResult::Mitigated(_) => unreachable!(),
        CollisionResult::Collision(digest) => Err(format!(
            "Collision attack: {}",
            gix::ObjectId::Sha1(digest.into()).to_hex()
        )),
    }
}

fn main() {
    dbg!(sha1_oid_of_file("shattered-1.pdf"));
    dbg!(sha1_oid_of_file("shattered-2.pdf"));
    dbg!(sha1dc_oid_of_file("shattered-1.pdf"));
    dbg!(sha1dc_oid_of_file("shattered-2.pdf"));
}

The output is as follows:

[src/main.rs:24:5] sha1_oid_of_file("shattered-1.pdf") = Sha1(38762cf7f55934b34d179ae6a4c80cadccbb7f0a)
[src/main.rs:25:5] sha1_oid_of_file("shattered-2.pdf") = Sha1(38762cf7f55934b34d179ae6a4c80cadccbb7f0a)
[src/main.rs:26:5] sha1dc_oid_of_file("shattered-1.pdf") = Err(
    "Collision attack: 38762cf7f55934b34d179ae6a4c80cadccbb7f0a",
)
[src/main.rs:27:5] sha1dc_oid_of_file("shattered-2.pdf") = Err(
    "Collision attack: 38762cf7f55934b34d179ae6a4c80cadccbb7f0a",
)

The latter behaviour matches Git.

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

Impact

An attacker with the ability to mount a collision attack on SHA-1 like the SHAttered or SHA-1 is a Shambles 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.

This vulnerability affects any user of gitoxide, including gix-* library crates, that reads or writes Git objects.