SPB Git

Repository Public

QYV-CRY-005.json 2.6 KB 23 lines json

1{2  "id": "QYV-CRY-005",3  "title": "SHA-256 / SHA-512 kept the digest in their chaining state after finalize: the expanded Ed25519 key, the signing nonce and derived child keys outlived their erasure",4  "severity": "medium",5  "cvss_vector": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:N/A:N",6  "cvss_score": 4.1,7  "cwe": "CWE-226",8  "masvs": "MASVS-STORAGE-2",9  "area": "crypto",10  "location": "Sources/QyvoraSymmetric/SHA2.swift:220",11  "tool": "manual-review",12  "rule": "secret-not-erased",13  "status": "fixed",14  "fix_commit": "f8b62b9",15  "regression_test": "Tests/QyvoraSymmetricTests/SHA2BasicTests.swift: chainingStateIsErasedAfterFinalize",16  "description": "Root cause: `SHA256.finalize` and `SHA512.finalize` erased the pending buffer and the padded tail (QYV-CRY-002) but left the eight words of the chaining state `h`, which after the last compression ARE the digest. The previous review recorded this as a low residual risk for HMAC keys (review register memory-hygiene-crypto.json, 'Chaining state h ... after finalize'). The Ed25519 module added by the multi-chain upgrade makes the digest itself the secret: SHA-512(seed) is the expanded private key (clamped scalar and nonce prefix), SHA-512(prefix ‖ message) is the signing nonce r (r together with the published signature gives the secret scalar), and the HMAC-SHA512 output of SLIP-0010 is the child private key and chain code. `Ed25519.expand`, `Ed25519.sign` and `SLIP10.Node.deriveHardened` erase their copies of these values with SecureMemory.zero, but the identical 64 bytes stayed in the released storage of the hash instance (an array of eight UInt64). Impact: an attacker able to read the memory of the process after a Solana signature or a derivation (memory-disclosure bug, crash dump, forensic image of an unlocked device) could recover the Solana signing key; the same held for the BIP-32 child keys of the other families (HMAC-SHA512 outer state). No such read primitive is known in the application. Severity by the policy: same class and vector as QYV-CRY-002 (4.1, medium).",17  "recommendation": "Fixed: both `finalize` functions erase `h` with SecureMemory.zero after the digest is serialised (an instance is not reusable after `finalize`; copies made before it, as PBKDF2 and HMAC do, are unaffected). What Swift does not allow to erase (struct temporaries on the stack such as the scalar limbs `Sc` and the points of the table lookup, copies made by the runtime) stays tracked as QYV-CRY-003.",18  "evidence": "see security/audit/review/ed25519.json (memory hygiene entries)",19  "fingerprint": "f3cc96ceb0f0",20  "reported": "2026-12-05",21  "owner": "audit-multichain"22}23
Files main
Menu

Theme