Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(deps): backport zip header consistency security fix

AkitaOnRails5c69054de1e0
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f6ec6fc5..0d56c317 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -477,8 +477,11 @@ jobs:
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
- uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2
- run: cargo install cargo-audit --locked
+ # zip is versioned 8.6.0 for Candle compatibility but pinned to
+ # upstream's official 8.x fix commit (507c5c76) for this GHSA.
- run: >
cargo audit
+ --ignore GHSA-m665-v7pm-7grj
--ignore RUSTSEC-2025-0141
--ignore RUSTSEC-2024-0320
- run: cargo audit --file companions/ai-memory-relay/Cargo.lock
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62e4cd18..9363c430 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,10 @@ version in [`docs/changelog/`](docs/changelog/):
### Fixed
+- Pinned `zip` 8.6 to upstream's official security-backport commit for
+ GHSA-m665-v7pm-7grj. Candle still requires the yanked 8.x line, so the
+ immutable backport keeps fresh builds resolvable while adding the header
+ consistency hardening shipped in `zip` 9.0.5.
- Updated `libz-sys` to 1.1.31 so its build probe no longer records the build
environment, including possible secrets, in Cargo target artifacts
(RUSTSEC-2026-0418).
diff --git a/Cargo.lock b/Cargo.lock
index 05d4b9cb..20bf6519 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5367,7 +5367,7 @@ dependencies = [
[[package]]
name = "zip"
version = "8.6.0"
-source = "git+https://github.com/zip-rs/zip2?rev=771dfc534d2614158af5497ea3dff4d4208d7db1#771dfc534d2614158af5497ea3dff4d4208d7db1"
+source = "git+https://github.com/zip-rs/zip2?rev=507c5c76ddd4cde767e64832fc6f848c51a99e44#507c5c76ddd4cde767e64832fc6f848c51a99e44"
dependencies = [
"crc32fast",
"flate2",
diff --git a/Cargo.toml b/Cargo.toml
index 92659779..0ec0d65b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -200,11 +200,12 @@ tempfile = "3"
rstest = "0.26"
# Candle 0.11 requires `zip ^8.6`, but crates.io yanked every compatible 8.x
-# release after publishing zip 9. Pin the upstream v8.6.0 release commit so a
-# fresh `cargo install --path` can still resolve the graph. Remove this patch
-# when Candle publishes a release compatible with zip 9.
+# release after publishing zip 9. Pin upstream's official 8.x security
+# backport for GHSA-m665-v7pm-7grj so fresh source resolution stays possible
+# without retaining the vulnerable v8.6.0 release. Remove this patch when
+# Candle publishes a release compatible with zip 9.
[patch.crates-io]
-zip = { git = "https://github.com/zip-rs/zip2", rev = "771dfc534d2614158af5497ea3dff4d4208d7db1" }
+zip = { git = "https://github.com/zip-rs/zip2", rev = "507c5c76ddd4cde767e64832fc6f848c51a99e44" }
[workspace.lints.rust]
unsafe_code = "forbid"
diff --git a/crates/ai-memory-cli/src/commands/upgrade.rs b/crates/ai-memory-cli/src/commands/upgrade.rs
index 6ab4656a..b3edc1b4 100644
--- a/crates/ai-memory-cli/src/commands/upgrade.rs
+++ b/crates/ai-memory-cli/src/commands/upgrade.rs
@@ -435,6 +435,9 @@ fn extract_release_tar_gz(bytes: &[u8], dest: &Path) -> Result<()> {
fn extract_release_zip(bytes: &[u8], dest: &Path) -> Result<()> {
let cursor = Cursor::new(bytes);
let mut archive = zip::ZipArchive::new(cursor).context("opening release zip")?;
+ archive
+ .validate_header_consistency()
+ .context("validating release zip headers")?;
let mut budget = ReleaseArchiveBudget::default();
for i in 0..archive.len() {
let mut file = archive
@@ -1545,6 +1548,23 @@ mod tests {
Ok(())
}
+ #[test]
+ fn zip_extract_rejects_inconsistent_local_and_central_names() -> Result<()> {
+ let mut bytes = build_test_zip(&[("ai-memory.exe", b"binary")])?;
+ let local_name = bytes
+ .windows(b"ai-memory.exe".len())
+ .position(|window| window == b"ai-memory.exe")
+ .expect("local header filename");
+ bytes[local_name..local_name + b"ai-memory.exe".len()].copy_from_slice(b"bad-memory.ex");
+
+ let dest = tempfile::tempdir()?;
+ let error = extract_release_archive(&bytes, dest.path(), "ai-memory-windows-x86_64.zip")
+ .expect_err("dual-header archive must be rejected");
+ assert!(error.to_string().contains("validating release zip headers"));
+ assert!(!dest.path().join("ai-memory.exe").exists());
+ Ok(())
+ }
+
#[test]
fn zip_extract_rejects_unexpected_paths() -> Result<()> {
let bytes = build_test_zip(&[("etc/passwd", b"nope")])?;