Skip to content
Journal

Guide //

Every security fix should ship with a failing test

A security finding is a claim. A regression test that fails on your code is proof. Why proving bugs before fixing them gives you fewer false positives, safer fixes and bugs that stay fixed.

Findings are claims

Static analysis tools report patterns: user input appears to reach a dangerous call. Sometimes the input is already validated, the path is unreachable, or the call is safe in context. Teams learn to ignore noisy reports, and the real ones get ignored along with them.

A failing test turns a claim into proof

Write a test that exercises the reported path with hostile input, and assert what safe code would do. Run it against the current code. If it fails, the bug is real, and you've shown how. If it passes, the finding was a false positive for this code, and you've learned that cheaply, before changing anything.

The same test checks the fix

Once you have a failing test, a fix has a clear bar: make that test pass, without breaking the rest. That's much harder to fake than "the scanner stopped complaining", which can happen just because the code moved.

And keeps it fixed

Commit the test with the fix. If someone later reintroduces string-built SQL or a shell call, CI fails. Security fixes regress more often than people expect, because the safe version can look like a style choice to the next person editing the code.

What a good security regression test checks

  • Behavior, not wording. Assert that input arrives as a parameter or argument, not that the code contains a particular function name. Any correct fix should pass.
  • No real side effects. Intercept the database, shell or loader with mocks. The test should never run a real command.
  • The hostile case and the normal case. Make sure legitimate input still works.

How Mallace uses this

Mallace is built around this loop. For each finding it writes the regression test first and runs it against your current code in a sandbox with no network. Only findings whose test fails count as real. Then it writes the fix, requires the same test to pass, has an independent model review the change, and opens a pull request containing both the fix and the test. See how it works, or try it free.

Let Mallace find and fix these for you.

Scanning is free and unlimited. Each fix comes as a pull request with the test that proved the bug.