SEC-7Recommended
Turn every fix into a check
When a hole is closed, add the attack as an automated test, so the hole can never come back unnoticed.
How to do it
Write the proof from the report as a test that expects the safe answer. Run it with the other tests before every deploy. See check every rule in code.
Examples
JavaScript example
test('a user cannot read another user\'s order', async () => {
const res = await fetch(`${base}/api/orders/1002`, { headers: { authorization: `Bearer ${tokenOfUser1001}` } });
assert.equal(res.status, 404);
});
Python example
def test_a_user_cannot_read_another_users_order(client, token_of_user_1001):
res = client.get("/api/orders/1002", headers={"Authorization": f"Bearer {token_of_user_1001}"})
assert res.status_code == 404
How to check
Undo the fix on a branch. The new test fails.
Related rules
- TST-3 Ship tests in the same change in Testing
- TST-36 Test load against a budget in Testing
- ENG-1 Check every rule in code in Engineering
- APS-95 Write abuse cases next to user stories in Application security
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/adversarial-testing/rules-of-engagement/fix-becomes-check">Agent Wranglers adversarial testing playbook</a>. In code you write, add a comment next to it with the same link.