From cc179c0d93f68c90a7a10399db83e8091afb3527 Mon Sep 17 00:00:00 2001 From: LoopyLuci Date: Sat, 28 Nov 2026 15:10:11 -0500 Subject: [PATCH 1/3] Ghost keys: move the RSA issuer to rsa 0.10, which clears RUSTSEC-2023-0071 The rsa 0.9 line carries the Marvin timing advisory and has no backport. The ghost-key issuer performs raw RSA private-key operations on blinded messages, so the exposure is live for an issuer. ghostkey.rs moves to rsa 0.10's API: - PrivateKey and PublicKey replace the deprecated RsaPrivateKey and RsaPublicKey aliases. - Values cross the RSA boundary as crypto-bigint BoxedUint; the blinding arithmetic stays on num-bigint-dig, with values converted through bytes. - The random source is rsa::rand_core::UnwrapErr around getrandom::SysRng (a TryCryptoRng). - PSS verification uses rsa's own sha2 Sha384 as the digest type. The RUSTSEC-2023-0071 ignore is removed. cargo audit reports no vulnerabilities with the repo's configuration, and with no ignores at all the only finding is the bincode warning already on the list. Core files: this changes crates/transferd-crypto and .cargo/audit.toml, both listed in core.manifest. TransferDaemon must sync them before its core-sync check passes. Tests: the 37 transferd-crypto tests pass with -D warnings. Workspace clippy with -D warnings passes, and all workspace test binaries pass (run with -j 2: the default parallelism exhausted the Windows paging file while building the overlay tests). Co-Authored-By: Claude Haiku 5.5 --- .cargo/audit.toml | 7 -- Cargo.lock | 119 ++++++++++++++++++------ crates/transferd-crypto/Cargo.toml | 4 +- crates/transferd-crypto/src/ghostkey.rs | 38 ++++---- 4 files changed, 117 insertions(+), 51 deletions(-) diff --git a/.cargo/audit.toml b/.cargo/audit.toml index fea4fe1..9c6c8e4 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -12,13 +12,6 @@ ignore = [ # requires migrating hyper 0.14 -> hyper 1 / tonic 0.12. Tracked migration. "RUSTSEC-2026-0258", - # rsa 0.9.10 — Marvin timing side-channel on RSA private-key operations. The fix is only - # in rsa 0.10, and 0.9.x has no backport. rsa is a direct dependency of transferd-crypto: - # the ghost-key issuer performs raw RSA private-key operations on blinded messages - # (ghostkey.rs, sign_blinded), so this is a live exposure for an issuer. Accepted only - # until rsa 0.10 is adopted. - "RUSTSEC-2023-0071", - # bincode 1.3.3 / 2.0.1 — unmaintained. bincode is the core wire format used # by every protocol envelope; migrating to a maintained fork (bincode 3) is a # tracked, separate task and cannot be done as a dependency bump. diff --git a/Cargo.lock b/Cargo.lock index 572e698..3b2a97e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,6 +82,12 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" +[[package]] +name = "base16ct" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" + [[package]] name = "base64ct" version = "1.8.3" @@ -327,6 +333,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -412,6 +424,21 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-bigint" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c195c4d7fbc5ed7f88d14cbf85914d5c664967658d43404b263913a477e82" +dependencies = [ + "cpubits", + "ctutils", + "getrandom 0.4.3", + "num-traits", + "rand_core 0.10.1", + "serdect", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.7" @@ -434,6 +461,16 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "crypto-primes" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" +dependencies = [ + "crypto-bigint", + "rand_core 0.10.1", +] + [[package]] name = "ctr" version = "0.9.2" @@ -492,7 +529,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid 0.9.6", - "pem-rfc7468", "zeroize", ] @@ -503,6 +539,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a996a108feb8b427a6e12fcf6af4aa83409b79d72c15337d7741368131ee004" dependencies = [ "const-oid 0.10.3", + "pem-rfc7468", "zeroize", ] @@ -513,7 +550,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid 0.9.6", "crypto-common 0.1.7", ] @@ -524,7 +560,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ "block-buffer 0.12.1", + "const-oid 0.10.3", "crypto-common 0.2.2", + "ctutils", "zeroize", ] @@ -547,7 +585,7 @@ dependencies = [ "curve25519-dalek", "ed25519", "serde", - "sha2", + "sha2 0.10.9", "subtle", "zeroize", ] @@ -758,6 +796,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest 0.11.3", +] + [[package]] name = "http" version = "1.5.0" @@ -1009,7 +1056,6 @@ dependencies = [ "rand 0.8.8", "serde", "smallvec", - "zeroize", ] [[package]] @@ -1038,7 +1084,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -1084,9 +1129,9 @@ dependencies = [ [[package]] name = "pem-rfc7468" -version = "0.7.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" dependencies = [ "base64ct", ] @@ -1099,13 +1144,12 @@ checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752" [[package]] name = "pkcs1" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +checksum = "6250dd7321adbe93d12b750aee0ced159fd13e77f625edcdf1cb6f83cd99f650" dependencies = [ - "der 0.7.10", - "pkcs8 0.10.2", - "spki 0.7.3", + "der 0.8.3", + "spki 0.8.1", ] [[package]] @@ -1395,22 +1439,22 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.10" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +checksum = "23e77fd77e0dea28b3011fd62d15445b7de7959333b0276d930e03be0f755699" dependencies = [ - "const-oid 0.9.6", - "digest 0.10.7", - "num-bigint-dig", - "num-integer", - "num-traits", + "const-oid 0.10.3", + "crypto-bigint", + "crypto-common 0.2.2", + "crypto-primes", + "digest 0.11.3", + "hmac", "pkcs1", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sha2", - "signature 2.2.0", - "spki 0.7.3", - "subtle", + "pkcs8 0.11.0", + "rand_core 0.10.1", + "sha2 0.11.2", + "signature 3.0.0", + "spki 0.8.1", "zeroize", ] @@ -1552,6 +1596,16 @@ dependencies = [ "zmij", ] +[[package]] +name = "serdect" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" +dependencies = [ + "base16ct", + "serde", +] + [[package]] name = "sha1" version = "0.10.7" @@ -1574,6 +1628,17 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha2" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0e5c7d67bc53f435386b2130fdc900488c5703770f6d8a4633060e34288a27" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest 0.11.3", +] + [[package]] name = "sha3" version = "0.12.0" @@ -1627,7 +1692,6 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", "rand_core 0.6.4", ] @@ -2005,6 +2069,7 @@ dependencies = [ "blake3", "criterion", "ed25519-dalek", + "getrandom 0.4.3", "hex", "kem", "ml-dsa", @@ -2016,7 +2081,7 @@ dependencies = [ "ring-channel", "rsa", "serde", - "sha2", + "sha2 0.10.9", "signature 2.2.0", "thiserror 2.0.21", "x25519-dalek", diff --git a/crates/transferd-crypto/Cargo.toml b/crates/transferd-crypto/Cargo.toml index 7f382e5..e860968 100644 --- a/crates/transferd-crypto/Cargo.toml +++ b/crates/transferd-crypto/Cargo.toml @@ -28,7 +28,9 @@ hex = "0.4" serde = { version = "1", features = ["derive"] } bincode = "1" # ghost keys (src/ghostkey.rs): RFC 9474 blind RSA signatures -rsa = { version = "0.9", features = ["hazmat", "sha2"] } +rsa = { version = "0.10", features = ["hazmat"] } +# the operating-system RNG for rsa 0.10 (ghostkey.rs rsa_rng); already in the lock file +getrandom = "0.4" sha2 = "0.10" num-bigint-dig = { version = "0.8", features = ["rand"] } num-traits = "0.2" diff --git a/crates/transferd-crypto/src/ghostkey.rs b/crates/transferd-crypto/src/ghostkey.rs index 83fc8c8..aadd91e 100644 --- a/crates/transferd-crypto/src/ghostkey.rs +++ b/crates/transferd-crypto/src/ghostkey.rs @@ -21,7 +21,7 @@ use num_traits::{One, Zero}; use rand::RngCore; use rsa::pkcs8::{DecodePublicKey, EncodePublicKey}; use rsa::traits::PublicKeyParts; -use rsa::{Pss, RsaPrivateKey, RsaPublicKey}; +use rsa::{BoxedUint, Pss, PrivateKey, PublicKey}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha384}; @@ -106,9 +106,14 @@ fn i2osp(x: &BigUint, len: usize) -> Result, GhostKeyError> { Ok(out) } -/// The issuer's public key as num-bigint-dig values (rsa 0.9 hands out its own BigUint, the same type). -fn n_e(pk: &RsaPublicKey) -> (BigUint, BigUint) { - (BigUint::from_bytes_be(&pk.n().to_bytes_be()), BigUint::from_bytes_be(&pk.e().to_bytes_be())) +/// The issuer's public key as num-bigint-dig values, for the blinding arithmetic (rsa 0.10 uses crypto-bigint). +fn n_e(pk: &PublicKey) -> (BigUint, BigUint) { + (BigUint::from_bytes_be(&pk.n().to_be_bytes()), BigUint::from_bytes_be(&pk.e().to_be_bytes())) +} + +/// The operating-system RNG for rsa 0.10, which takes a rand_core 0.10 `TryCryptoRng`. +fn rsa_rng() -> rsa::rand_core::UnwrapErr { + rsa::rand_core::UnwrapErr(getrandom::SysRng) } fn ghost_message(tier: &str, ghost_pub: &[u8; 32]) -> Vec { @@ -123,7 +128,7 @@ fn ghost_message(tier: &str, ghost_pub: &[u8; 32]) -> Vec { /// An issuer key for one tier. Keep the private part offline or on the relay; publish [`IssuerPublic`]. pub struct Issuer { - key: RsaPrivateKey, + key: PrivateKey, pub public: IssuerPublic, } @@ -137,8 +142,8 @@ pub struct IssuerPublic { } impl IssuerPublic { - pub fn rsa(&self) -> Result { - RsaPublicKey::from_public_key_der(&self.spki).map_err(|e| GhostKeyError::Encoding(e.to_string())) + pub fn rsa(&self) -> Result { + PublicKey::from_public_key_der(&self.spki).map_err(|e| GhostKeyError::Encoding(e.to_string())) } /// blake3 of the SPKI, first 8 bytes in hex: how certificates name their issuer. pub fn id(&self) -> String { @@ -154,16 +159,16 @@ impl Issuer { if tier.len() > 64 { return Err(GhostKeyError::Encoding("a tier is at most 64 bytes".into())); } - let key = RsaPrivateKey::new(&mut rand::thread_rng(), bits)?; + let key = PrivateKey::new(&mut rsa_rng(), bits)?; Self::from_private(name, tier, key) } - pub fn from_private(name: &str, tier: &str, key: RsaPrivateKey) -> Result { + pub fn from_private(name: &str, tier: &str, key: PrivateKey) -> Result { let spki = key.to_public_key().to_public_key_der().map_err(|e| GhostKeyError::Encoding(e.to_string()))?.into_vec(); Ok(Self { key, public: IssuerPublic { name: name.into(), tier: tier.into(), spki } }) } - pub fn private_key(&self) -> &RsaPrivateKey { + pub fn private_key(&self) -> &PrivateKey { &self.key } @@ -182,7 +187,7 @@ impl Issuer { return Err(GhostKeyError::Encoding("an issuer secret has a name, a tier and a key".into())); }; let der = hex::decode(der.trim()).map_err(|e| GhostKeyError::Encoding(e.to_string()))?; - let key = RsaPrivateKey::from_pkcs8_der(&der).map_err(|e| GhostKeyError::Encoding(e.to_string()))?; + let key = PrivateKey::from_pkcs8_der(&der).map_err(|e| GhostKeyError::Encoding(e.to_string()))?; Self::from_private(name, tier, key) } } @@ -225,16 +230,17 @@ impl Issuer { if blinded.len() != k { return Err(GhostKeyError::Length { expected: k, got: blinded.len() }); } - let m = rsa::BigUint::from_bytes_be(blinded); - if &m >= self.key.n() { + let n = BigUint::from_bytes_be(&self.key.n().to_be_bytes()); + if BigUint::from_bytes_be(blinded) >= n { return Err(GhostKeyError::MessageTooLong); } - let s = rsa::hazmat::rsa_decrypt_and_check(&self.key, Some(&mut rand::thread_rng()), &m)?; + let m = BoxedUint::from_be_slice(blinded, (8 * k) as u32).map_err(|e| GhostKeyError::Encoding(e.to_string()))?; + let s = rsa::hazmat::rsa_decrypt_and_check(&self.key, Some(&mut rsa_rng()), &m)?; // the check RFC 9474 asks for: s^e == m, so a fault never leaks the key if rsa::hazmat::rsa_encrypt(&self.key.to_public_key(), &s)? != m { return Err(GhostKeyError::BadIssuerSignature); } - i2osp(&BigUint::from_bytes_be(&s.to_bytes_be()), k) + i2osp(&BigUint::from_bytes_be(&s.to_be_bytes()), k) } } @@ -337,7 +343,7 @@ impl GhostCertificate { let mut msg = self.prefix.to_vec(); msg.extend_from_slice(&ghost_message(&self.tier, &self.ghost_public)); let hashed = Sha384::digest(&msg); - pk.verify(Pss::new_with_salt::(SALT_LEN), &hashed, &self.signature).map_err(|_| GhostKeyError::InvalidCertificate) + pk.verify(Pss::::new_with_salt(SALT_LEN), &hashed, &self.signature).map_err(|_| GhostKeyError::InvalidCertificate) } /// A message signed by the ghost key this certificate vouches for. From d5ac4688fc2b3ad3017a7c16ae3b95cf47cdd5db Mon Sep 17 00:00:00 2001 From: LoopyLuci Date: Sat, 28 Nov 2026 15:47:39 -0500 Subject: [PATCH 2/3] Audit: ignore RUSTSEC-2026-0387 with a deadline crypto-bigint 0.5.5 (RUSTSEC-2026-0387) is reached in TransferDaemon through transferd-webrtc -> webrtc 0.12 -> webrtc-dtls 0.11 -> p256 -> ecdsa -> crypto-bigint 0.5.5. Any WebRTC peer can drive it during DTLS. No 0.5.x release is fixed; the fix needs the webrtc 0.21 migration, which is a rewrite of transferd-webrtc in TransferDaemon. This ignore is time-boxed to 2026-12-31, and the deadline is tracked by the maintainer. It is inert in Transferd, which does not depend on webrtc; it reaches TransferDaemon through the core-file sync. Co-Authored-By: Claude Haiku 5.5 --- .cargo/audit.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 9c6c8e4..f1fc3a7 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -45,4 +45,12 @@ ignore = [ # a compatible bump; the affected methods are not exercised by our stack. "RUSTSEC-2026-0002", "RUSTSEC-2026-0253", + + # RUSTSEC-2026-0387 — crypto-bigint 0.5.5, multiple timing-variability issues. + # Exact path: transferd-webrtc -> webrtc 0.12 -> webrtc-dtls 0.11 -> p256 -> ecdsa -> crypto-bigint 0.5.5. + # Reachable from any WebRTC peer during DTLS: the handshake's ECDH and ECDSA run on this path. + # The fix is only in crypto-bigint >=0.7.6; webrtc-dtls 0.11 pins the 0.5 line. The clearing change is + # the webrtc 0.21 migration of transferd-webrtc (a rewrite, not a version bump). + # Time-boxed: remove by 2026-12-31 via that migration; deadline tracked by the maintainer. + "RUSTSEC-2026-0387", ] \ No newline at end of file From f178feca2f2eada3dfb6eee9eaa8e19143ad0d1d Mon Sep 17 00:00:00 2001 From: LoopyLuci Date: Mon, 30 Nov 2026 14:20:12 -0500 Subject: [PATCH 3/3] ci: the selftest's temporary repositories ignore the hook's GIT_DIR Inside a git hook, git sets GIT_DIR to the repository the hook runs for. The selftest's temporary repositories ran git init and git add with that variable set, so they acted on the real repository. On a push from a worktree, that rewrote the shared config to core.bare = true, and every worktree then failed with "must be run in a work tree". clean_git_env drops the repository-location variables. The checks' git() helper and the selftest use it, so temporary repositories find only their own .git. Co-Authored-By: Claude Haiku 5.5 --- ci/checks.py | 19 +++++++++++++++++++ ci/tests/test_checks.py | 9 +++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ci/checks.py b/ci/checks.py index 836b88e..ad56741 100644 --- a/ci/checks.py +++ b/ci/checks.py @@ -39,12 +39,31 @@ class Finding: fix: str = "" +# The variables that point git at one repository. A git hook sets them to the repository it runs for, so a temporary +# repository created with them inherits that repository and can rewrite its config. +_REPOSITORY_VARIABLES = ( + "GIT_DIR", + "GIT_WORK_TREE", + "GIT_INDEX_FILE", + "GIT_COMMON_DIR", + "GIT_OBJECT_DIRECTORY", + "GIT_ALTERNATE_OBJECT_DIRECTORIES", + "GIT_PREFIX", +) + + +def clean_git_env() -> dict: + """The environment for git that finds its repository from the working directory, as in a shell.""" + return {k: v for k, v in os.environ.items() if k not in _REPOSITORY_VARIABLES} + + def git(root: Path, *args: str) -> Tuple[int, str]: """Run git in the repository and return its exit code and standard output.""" try: done = subprocess.run( ["git", *args], cwd=root, + env=clean_git_env(), capture_output=True, text=True, encoding="utf-8", diff --git a/ci/tests/test_checks.py b/ci/tests/test_checks.py index f91e5ff..a6ed4a7 100644 --- a/ci/tests/test_checks.py +++ b/ci/tests/test_checks.py @@ -13,6 +13,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from checks import ( # noqa: E402 + clean_git_env, eol_findings, git_bash, hooks_findings, @@ -188,14 +189,14 @@ def repo(self): tmp = tempfile.TemporaryDirectory() self.addCleanup(tmp.cleanup) root = Path(tmp.name) - subprocess.run(["git", "init", "-q"], cwd=root, check=True) + subprocess.run(["git", "init", "-q"], cwd=root, check=True, env=clean_git_env()) return root def test_a_staged_key_and_trailing_whitespace_are_found(self): root = self.repo() (root / "keys.txt").write_text(KEY_HEADER + "\n", encoding="utf-8") (root / "notes.txt").write_text("trailing \n", encoding="utf-8") - subprocess.run(["git", "add", "-A"], cwd=root, check=True) + subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=clean_git_env()) found = messages(staged_findings(root)) self.assertTrue(any("private key added to keys.txt" in m for m in found), found) self.assertTrue(any("staged changes have problems" in m for m in found), found) @@ -203,14 +204,14 @@ def test_a_staged_key_and_trailing_whitespace_are_found(self): def test_a_large_staged_file_is_an_error(self): root = self.repo() (root / "big.bin").write_bytes(b"x" * 2048) - subprocess.run(["git", "add", "-A"], cwd=root, check=True) + subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=clean_git_env()) found = staged_findings(root, limit=1024) self.assertTrue(any("big.bin" in m and "staged" in m for m in messages(found))) def test_a_clean_stage_has_no_findings(self): root = self.repo() (root / "ok.txt").write_text("plain text\n", encoding="utf-8") - subprocess.run(["git", "add", "-A"], cwd=root, check=True) + subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=clean_git_env()) self.assertEqual(staged_findings(root), [])