Repository navigation
test(core): tamper, truncation, downgrade and property tests - #21
Merged
Merged
Conversation
Drives storage::unlock on a real file rather than crypto::open, so the test covers the whole path a user hits. It also pins which error each header region produces. Refs #20
Files shorter than header + tag must fail as Format before any key is derived. Longer ones that are cut or padded must fail authentication. Refs #20
Builds a vault above the floor, then rewrites m_cost in the header. The original key must still fail to open it. That assertion is the one that breaks if the header ever drops out of the associated data. Salt, parameters and nonce all change the key or keystream anyway. Refs #20
Random entries go through create, save and unlock on disk. Fields hold arbitrary Unicode, including quotes, backslashes and control characters. Timestamps span the full RFC 3339 range at nanosecond precision. The test catches anything the JSON or file layers fail to preserve exactly. Adds proptest as a dev-dependency. Refs #20
Saves the same plaintext twice and checks that the salt is kept while the nonce and ciphertext both change. This supersedes the storage unit test that checked only the nonce, so that test is removed. Refs #20
Snapshots every file in the vault directory, names and bytes, before and after a failed unlock. A rewritten vault or .bak fails the test, and so does a stray temp file. The test also pins the exact error message, so a wrong password and a corrupted file stay indistinguishable. This supersedes the storage unit test that checked only the error variant. Refs #20
Without this baseline, the flip and truncation tests would pass vacuously if unlock always failed. Refs #20
Owner
Author
|
Self-review: I read the full diff (
No 🛑 checkpoint on this PR; CI is green on all four required checks. |
5 of 6 tasks
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.
Summary
Adds the security test suite in
crates/pwv-core/tests/. Every test drives real vault files through the publicstorageAPI: wrong password, any flipped byte, every truncated length, an extended file, a memory-cost downgrade, a property-based round trip, and nonce/ciphertext freshness. Two storage unit tests are removed because the new tests strictly supersede them.Closes #20
Type of change
How was this tested?
cargo fmt --all --check,cargo clippy --workspace --all-targets [--all-features] -- -D warnings,cargo test --workspace [--all-features],cargo deny check: all pass locally.tamper.rs4 tests,roundtrip.rs2 tests, 64 proptest cases).sealandopenuse an empty AAD failsmemory_cost_downgrade_is_rejectedat thecrypto::open(&key, &downgraded)assertion.unlock, the salt and parameters change the derived key, the nonce changes the keystream, and the ids fail parsing. So the flip test proves the end-to-end claim, and the downgrade test is the one that guards the AAD.Security checklist
pwv-core::kdf/pwv-core::crypto(tests use those modules, never a crypto crate)Notes for the reviewer
#![cfg(feature = "insecure-test-kdf")], so they run in the--all-featuresCI step and compile to nothing in the featureless step.m_costbyte 7 yields 64 MiB, which is in range, so one real Argon2 run at that size happens (under 1 s in debug).header/kdfunit tests cover that with production values in the featureless run.allow-unwrap-in-testsdoesn't apply to helper functions in integration-test crates, hence a file-level#![allow(clippy::unwrap_used)]with a comment.proptest1.12.0 (MIT OR Apache-2.0);cargo denyis clean.