test(fuzz): add coverage for derive_encrypt and key_derivation parsing#402
Open
mmorrissette-devolutions wants to merge 2 commits into
Open
test(fuzz): add coverage for derive_encrypt and key_derivation parsing#402mmorrissette-devolutions wants to merge 2 commits into
mmorrissette-devolutions wants to merge 2 commits into
Conversation
Add three fuzz targets covering untrusted-byte paths that previously had no coverage: - kdf_encrypted_data_deserialization: KdfEncryptedData::try_from(&[u8]) - derivation_parameters_deserialization: DerivationParameters::try_from(&[u8]) - decrypt_with_password: encrypt/decrypt round-trip via KdfEncryptedData, with Argon2 parameters clamped to keep key derivation cheap enough for fuzzing. CI discovers targets via `cargo fuzz list`, so no workflow change is needed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29a942193b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
A SecretKey requires exactly 32 raw bytes, so an arbitrary Argon2 output length (previously clamped to 1..128) made encrypt_with_password_and_aad fail before the decrypt path for ~127/128 of inputs. Pin the length to 32 so the password-decrypt path is actually exercised; arbitrary output lengths remain covered by the derive_key_argon2 target.
Sébastien Duquette (sduquette-devolutions)
approved these changes
Jun 19, 2026
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 fuzz coverage for three untrusted-byte paths in the
derive_encryptandkey_derivationmodules that previously had no fuzz target.The
derive_encryptmodule was entirely unfuzzed, andDerivationParametersdeserialization — another publicTryFrom<&[u8]>parser of attacker-controllable bytes — had no coverage.New targets
kdf_encrypted_data_deserializationKdfEncryptedData::try_from(&[u8])derivation_parameters_deserializationDerivationParameters::try_from(&[u8])decrypt_with_passwordencrypt_with_password_and_aad→decrypt_with_password_and_aadround-tripFor
decrypt_with_password, the Argon2 parameters are clamped (length/lanes/memory/iterations + small salt, same approach as the existingderive_key_argon2target) so key derivation stays cheap enough for fuzzing — an unclampedArbitraryvalue could request billions of iterations and blow the per-target time budget.The CI action discovers targets via
cargo fuzz list, so no workflow change is needed.Testing
Built and ran all three targets in WSL (nightly + cargo-fuzz 0.13.1), no crashes:
kdf_encrypted_data_deserialization— 18.6M runsderivation_parameters_deserialization— 19.4M runsdecrypt_with_password— full KDF round-trip, no timeout