Kimi-K3 audit fixes - #4
Open
jamesob wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
2026-08 security audit fixes
Addresses all 12 findings from the security audit (2 medium, 8 low, 2 info).
BIP32 test vectors are unchanged.
Vulnerabilities addressed
errnospuriously rejectserrno; range-check widestrtoulvalue before narrowing; reject components > 2³¹−1m/1h2→m/1h)/⟨digits⟩[marker]bip32_from_seedrejects seeds outside 16–64 bytes per BIP32sodium_memzero'd on every exitbip32_get_publicmasks pubkey failure: success + all-zero pubkeyBIP32Keyhas phantomctxfield — field reads return shifted bytes incl. wrong private keybip32_from_seedctypes prototype → deterministic SIGSEGV inBIP32.from_seed()bip32_index_derivestamps child's fingerprint as parent'sout_size— stock binary always failssizeof(serialized);make testCLI smoke testb58_encodebufferlen*2too small for 1-byte inputs ≥ 0x3achild_numberreflects actual indexassert()compiled out under NDEBUGChanges
bip32.c— seed-length enforcement; strict path parser; CKD retry loop; snapshot-before-mutation inbip32_index_derive; checkedbip32_fingerprint/bip32_pubkey_from_privkeyreturns; complete stack zeroization; NDEBUG-safe init checks.bip32.h—BIP32_{MIN,MAX}_SEED_BYTES; docs for seed requirements, strict paths, in-place derivation, wipe-on-failure.examples/py/bindings.py—bip32_from_seedprototype; FFI layout fixed + pinned by asserts; exact-size b58 buffers.examples/py/test_fuzz_cross_impl.py— base58 TODO workaround removed; oracle seed constructors wrapped so failure comparison is robust.examples/cli.c— initializeout_size.errno, 13 malformed paths, invalid-key neutering, in-place fingerprint equivalence); Python tests (from_seedvector, field access, weak seeds, 1-byte b58); CLI smoke test inmake test.Verification
sodium_init+secp256k1_context_randomize(object-level check).Note: oracles (python-bip32, verystable) do not reject out-of-range seed lengths; fuzz seeds stay clamped to 16–64 bytes since rejection behavior cannot be cross-compared. Our rejection is pinned by unit tests.