Use mutation testing to find the bugs your tests don't catch #1418
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.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
Thesis. Line/branch coverage proves code was executed, not that behavior is correct. The post demonstrates how mutation testing (via Slither’s
slither-mutate
) exposes gaps that high coverage misses, and shows how it led Trail of Bits to a high‑severity bug in the Arkis DeFi protocol.How tests improve security.
• Unit tests: assert behavior of individual functions and edge inputs.
• Integration tests: assert end‑to‑end user/admin flo...
🔧 Technical Details
Mutation testing to reveal test-suite blind spots. Systematically mutate Solidity code (operators, constants, conditions, comment/revert/type changes) and run the existing tests. Any surviving mutant marks a missing assertion. Automate with
slither-mutate ./src/contracts --test-cmd="forge test"
, list mutators via--list-mutators
, and prioritize mutants to cut runtime. Inspect survivors in./mutation_campaign
, then add assertions/invariants that would fail under the mutated behavior.Assert state, not just return values. Strengthen tests with equality‑boundary checks (e.g., threshold
==
), and verify post‑conditions: balances, supply, authorizations, and emitted events. This kills mutants that alter thresholds, skip lines, or negate conditions while still returning plausible values.Validate user-controlled parameters against on-chain effects. When consuming user‑provided structs/fields (e.g...
🤖 Agent Actions
I analyzed the Trail of Bits post and confirmed it is highly technical and directly relevant to Smart Contract Security testing. There was no existing HackTricks content covering mutation testing for Solidity or Slither’s slither-mutate. I created a new page and linked it from relevant Blockchain pages.
What I added
Where I linked it
Why this location
References included on the new page
No other duplicate content existed, so this addition fills a clear gap without redundancy.
This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.
🗑️ File Cleanup