Security hardening across Python, Rust, and TypeScript implementations#1
Closed
jaschadub wants to merge 2 commits into
Closed
Security hardening across Python, Rust, and TypeScript implementations#1jaschadub wants to merge 2 commits into
jaschadub wants to merge 2 commits into
Conversation
No wire-format or canonicalization changes — pure implementation hardening. Python (src/vectorpin/, tests/): - CLI keygen writes private key with mode 0600 via O_EXCL; parent dir 0700; refuses to clobber existing key - Pin.from_json/from_dict: 64 KiB size cap, strict type checks on every field, sig length == 64, hash regex, extra values must be strings - Verifier returns SIGNATURE_INVALID for non-bytes or wrong-length sig before reaching the cryptography library - Audit loop catches per-record parse errors and continues (one bad row no longer aborts the audit) - LanceDB adapter validates id_column/vector_column/pin_column against identifier regex; rejects record_id containing NUL/newline/backslash - Qdrant + Pinecone adapters refuse api_key over http:// for non-loopback hosts unless VECTORPIN_ALLOW_INSECURE_HTTP=1 - Signer.from_pem requires explicit password= or allow_unencrypted=True - pyproject.toml: cryptography >=42,<46; numpy >=1.26,<3 Rust (rust/vectorpin/): - #![forbid(unsafe_code)] on the crate - Signer::generate -> Result<Self, SignerError::EmptyKeyId> - Signer::private_key_bytes -> Zeroizing<[u8; 32]> - vec_dim cast via u32::try_from on signer + verifier sides - Verifier::add_key -> Result<(), VerifyError::KeyDecodeFailed> - Pin parser rejects non-string values in extra (ExtraTypeMismatch) - Replaced home-rolled date arithmetic with `time` crate (RFC3339 format preserved byte-for-byte) TypeScript (typescript/): - @noble/ed25519 pinned to exact 2.3.0; @noble/hashes to 1.8.0 - pinFromDict: rejects __proto__/constructor/prototype, unknown top-level keys, non-string extra values; strict typeof checks; hash regex; sig length == 64; base64url alphabet enforced - pinFromJSON: 64 KiB cap; extra capped at 32 entries - Switched signing/verifying to async API (signAsync/verifyAsync) and removed the globally-mutable ed25519.etc.sha512Sync hook - Signer.fromPrivateBytes makes a defensive copy; new wipe() method - Module-load assertion that crypto.getRandomValues is available - Verifier detail strings are sanitized (strip control chars, truncate) New tests: tests/test_cli_keygen_perms.py, tests/test_signer_from_pem.py, rust/vectorpin/tests/hardening.rs, typescript/test/attestation.test.ts, plus expanded coverage in the existing suites. All tests pass: Python 83, Rust 24 unit + 9 hardening + 2 cross_lang + 12 doc, TypeScript 58.
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.
No wire-format or canonicalization changes — pure implementation hardening.
Python (src/vectorpin/, tests/):
Rust (rust/vectorpin/):
timecrate (RFC3339 format preserved byte-for-byte)TypeScript (typescript/):
New tests: tests/test_cli_keygen_perms.py, tests/test_signer_from_pem.py, rust/vectorpin/tests/hardening.rs, typescript/test/attestation.test.ts, plus expanded coverage in the existing suites.
All tests pass: Python 83, Rust 24 unit + 9 hardening + 2 cross_lang + 12 doc, TypeScript 58.