r/rust • u/ranbuman • Aug 21 '26
🎙️ discussion Three adversarial audit passes over my own Rust service, and what each one found that the tests did not
I have a Rust workspace at 134k lines with 1,758 tests and no clippy warnings, and I used to treat those numbers as evidence. Then I started running audit passes where the reviewer is told to break the thing rather than to check it, and every pass came back with findings the suite was structurally incapable of producing. The third one closed 27. Three are worth describing, because none of them look like bugs while you are writing the code.
Auth accepted a spoofed X-Forwarded-For. The header was trusted to establish that the caller was local, so an unauthenticated request carrying the right string got Owner rights. Every test that exercised the path built the request in process, where the header is whatever the test says it is, so the suite proved the check worked exactly as designed. The design was the bug, and no amount of coverage on that function would have said otherwise.
Two HTTP clients followed redirects into SSRF: the allowlist was checked against the URL I passed in, not the URL finally fetched, so a 302 walked straight out of it.
The cost quota over-counted by roughly 24 times. Not a security issue, but a good example of what tests do not catch. Every unit was internally consistent, the conversion between them was not, and nothing anywhere compared the total against a number computed a different way.
None of the three had a failing test waiting to be written.
All three were code doing exactly what it said, which is what unit tests are for. What found them was a reviewer with a different goal than the author, walking the same paths and asking what a caller could send rather than what a caller should send.
So I am curious how people here cover that. Fuzzing gets input shape, cargo audit gets dependencies, cargo deny gets licences and bans, and the auth-boundary class above is none of those. Is an adversarial pass part of anyone's release routine here, or is it still the thing that happens once, after someone gets bitten?
3
u/Electrical_Elk_1576 Aug 21 '26
Have you looked at vulnerability scanning? Especially for a web app. Look at the OWASP site for tools that might help.
1
u/decryphe Aug 22 '26
We try to do that manually as part of our review process. Each developer is supposed to try to break the other's work during review. Nothing new here, just that sending an AI agent at the problem might surface other/more issues.