Lesson 6 of 9 · 24m
Security Requirements Engineers Can Implement
Turn threats into testable requirements with acceptance criteria, negative tests, and clear ownership — not vague instructions like 'validate input.'
Most threat models die at the sentence "add appropriate validation." Appropriate to whom? Validated where? Against what? A security requirement is not a wish. It is an implementation-ready invariant with a test that can fail.
Requirements are invariants, not control shopping
Weak: "rate limit password reset." Better: "After five failed reset-code attempts for one account in ten minutes, reject further attempts for that account for fifteen minutes, regardless of source IP."
The second version names state, threshold, scope, and behavior. It can be implemented once and tested directly:
def test_reset_code_lockout_is_per_account(client, user):
payload = {"email": user.email, "code": "000000"}
assert [client.post("/reset/consume", json=payload).status_code for _ in range(5)] == [401] * 5
assert client.post("/reset/consume", json=payload).status_code == 429Notice what it does not say: "use Redis." That is a design choice. Requirements describe the security property; implementation chooses the mechanism.
Pair every positive test with a negative test
Positive tests prove the feature works. Security requirements need negative tests proving the attacker path fails:
requirement: webhook events are processed once
positive: valid signed event creates exactly one fulfillment
negative:
- replayed signed event returns 200 but does not create a second fulfillment
- event with timestamp older than 300 seconds is rejected
- modified payload with original signature is rejectedThe replay test returning 200 is deliberate: webhook providers retry, and an acknowledgement can be safe if processing is idempotent. Security requirements live inside real protocol behavior.
Write abuse cases into user stories
As a customer, I can regenerate an API token.
Abuse case: an attacker with a stolen browser session silently rotates the token and keeps access after logout.
Requirement: token rotation requires step-up authentication and revokes previously issued tokens.This is how threat modeling becomes backlog work rather than a separate universe. The acceptance criteria can name headers, response codes, audit events, and migration behavior.
Trace requirement to evidence
Track each requirement with the threat it addresses, verification evidence, owner, and status. Evidence can be a test, config inspection, code review checklist item, or operational alert. If there is no evidence, the requirement is still theoretical.
Field notes
- "Validate input" becomes useful only when you say which field, where, using what canonical form, and what happens on failure.
- Do not require impossible perfection ("must never leak data"). Require enforceable properties ("PII is excluded from analytics events by schema allowlist").
- Include failure behavior: fail closed, degrade gracefully, alert, or continue read-only.
- Security requirements belong beside functional acceptance criteria, not in a separate security-only tracker.
Was this lesson helpful?