diff --git a/Cargo.lock b/Cargo.lock index 1713ac0c..43508f60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1558,9 +1558,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags", "errno", @@ -1571,9 +1571,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.43" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ "log", "once_cell", diff --git a/changelog.d/+rustsec-lockfile.bugfix.md b/changelog.d/+rustsec-lockfile.bugfix.md new file mode 100644 index 00000000..27532207 --- /dev/null +++ b/changelog.d/+rustsec-lockfile.bugfix.md @@ -0,0 +1 @@ +`Cargo.lock` pins rustls 0.23.46 and rustix 1.1.6, the patched releases for RUSTSEC-2026-0285, RUSTSEC-2026-0346, RUSTSEC-2026-0348, RUSTSEC-2026-0349, and RUSTSEC-2026-0486. diff --git a/tests/public_metadata.rs b/tests/public_metadata.rs index 7c693dff..915e6da1 100644 --- a/tests/public_metadata.rs +++ b/tests/public_metadata.rs @@ -644,3 +644,54 @@ fn discovery_metadata_uses_real_index_terms() { ); } } + +/// The locked crate is the one the binary links. A caret in `Cargo.toml` +/// does not record that, so a later `cargo update` can move rustls or rustix +/// back onto a release `cargo audit` rejects. +fn locked_crate_version(lock: &str, package: &str) -> Option> { + let mut current = None; + for line in lock.lines() { + if let Some(rest) = line.strip_prefix("name = \"") { + current = rest.strip_suffix('"').map(str::to_string); + } else if let Some(rest) = line.strip_prefix("version = \"") { + if current.as_deref() == Some(package) { + let text = rest.strip_suffix('"')?; + let mut parts = Vec::new(); + for part in text.split('.') { + parts.push(part.parse::().ok()?); + } + return Some(parts); + } + } + } + None +} + +fn version_at_least(got: &[u64], floor: &[u64]) -> bool { + let width = got.len().max(floor.len()); + for index in 0..width { + let left = got.get(index).copied().unwrap_or(0); + let right = floor.get(index).copied().unwrap_or(0); + match left.cmp(&right) { + std::cmp::Ordering::Greater => return true, + std::cmp::Ordering::Less => return false, + std::cmp::Ordering::Equal => {} + } + } + true +} + +#[test] +fn the_lockfile_pins_patched_rustls_and_rustix() { + let lock = std::fs::read_to_string(repo().join("Cargo.lock")).expect("read Cargo.lock"); + let rustls = locked_crate_version(&lock, "rustls").expect("rustls in Cargo.lock"); + let rustix = locked_crate_version(&lock, "rustix").expect("rustix in Cargo.lock"); + assert!( + version_at_least(&rustls, &[0, 23, 46]), + "rustls {rustls:?} is below 0.23.46 (RUSTSEC-2026-0285, RUSTSEC-2026-0346, RUSTSEC-2026-0348, RUSTSEC-2026-0349)" + ); + assert!( + version_at_least(&rustix, &[1, 1, 6]), + "rustix {rustix:?} is below 1.1.6 (RUSTSEC-2026-0486)" + ); +}