SECURITY ENGINEERING · PART 8 · WRITING SECURE CODE · PROCESS · 107 OF 229

Security Requirements and Abuse Cases

Most security flaws are missing requirements, not broken code. This episode shows how to write security requirements that can be tested and signed off, how to turn a normal user story into abuse cases by asking how it could be misused, where ready-made requirements come from (OWASP ASVS, the top ten, compliance), and how these become acceptance criteria, test cases and a shared definition of done.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 11

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Most breaches are missing requirements
  • derive them from abuse cases
  • reuse ASVS
  • make them testable and part of done

Notes

What good looks like

A good security requirement looks like any good requirement: specific, testable, and with a reason. The app must be secure is not a requirement; it is a wish. Validate all input is barely better. Compare: passwords are stored with Argon two i d, never logged and never returned in a response. Or: a user can only access records belonging to their own organisation. Each of those can be written as a test, checked in review and signed off. That is the bar.

Vague vs usable
  • vague: "the app must be secure"
  • vague: "validate all input"
  • usable: "passwords are stored with Argon2id; never logged or returned"
  • usable: "a user can only access records of their own organisation"
  • each one can be tested and signed off

Abuse cases

The technique is the abuse case. Take a normal user story and ask how it could be misused. A user uploads a profile photo. How could that be abused? Upload a huge file to exhaust storage. Upload a script instead of an image. Overwrite another user's photo by guessing an identifier. Read a server file by putting a path in the filename. Each abuse case becomes a requirement: a size limit, content-type checks, an ownership check, path handling. One story, four requirements.

From user story to abuse case
  • story: "upload a profile photo". abuse cases: huge file (DoS) a script, not an image (stored XSS, RCE) overwrite another user's photo (access control) read server files via the file path (traversal)
  • each abuse -> a requirement

A prompt list

You do not need inspiration; you need a prompt list. For every feature ask: who should not be able to do this, and can they? What if the input is huge, empty or malformed? What if it is called a thousand times a second? Can I act on someone else's data by changing an identifier in the request? What gets logged, and should it be? What if a step in the flow is skipped, repeated or done out of order? Run a feature through these and the requirements write themselves.

Ask of every feature
  • who should NOT be able to do this? can they?
  • what if the input is huge, empty or malformed?
  • what if it is called 1000x a second?
  • can I act on another user's data by changing an ID?
  • what is logged, and should it be?
  • a step skipped or repeated?

Do not start blank

You should not write these from a blank page. The OWASP Application Security Verification Standard, or ASVS, is a detailed checklist of requirements organised into levels, from basic to high assurance. The OWASP top ten gives the common risk categories, and the API top ten does the same for APIs. The proactive controls and cheat sheets give concrete guidance. Compliance regimes map to requirements too. And your own past incidents are the most relevant source of all.

Ready-made requirements
  • OWASP ASVS: a detailed, levelled checklist of app security requirements
  • OWASP Top 10 and API Top 10: the common risk categories
  • OWASP proactive controls and cheat sheets
  • compliance: PCI DSS, HIPAA, SOC 2 map to requirements
  • your own past incidents

Into the backlog

A requirement that lives in a document will be forgotten. Make it real. Add security acceptance criteria directly to the user story: the reset token expires in fifteen minutes; a user cannot read another organisation's orders. Write them as automated tests where you can, especially negative tests that confirm the bad thing is blocked. Put them in the definition of done. Cross-cutting ones, such as how cryptography and logging work, become shared standards referenced by every story.

Make them real
  • add security acceptance criteria to the user story
  • write them as tests where possible: authz tests, negative tests
  • add them to the definition of done
  • non-functional ones (crypto, logging) become standards
  • reviewed like any other acceptance criteria

A worked example

Here is one story worked through. A user logs in. Guessing passwords leads to a requirement for rate limiting, lockout and multi-factor authentication. User enumeration leads to identical responses and timing for valid and invalid accounts. Stolen passwords lead to breached-password checks and MFA. Session theft leads to secure cookies, session rotation after login and idle timeouts. Brute forcing the MFA code leads to limited attempts and short validity. One story, six concrete, testable requirements.

"A user logs in"
  • abuse -> requirement: guessing passwords -> rate limit + lockout + MFA
  • user enumeration -> identical response and timing
  • stolen password -> breached- password check, MFA
  • session theft -> secure cookie, rotation, timeout
  • brute MFA codes -> limited attempts, short validity

Non-functional too

Not every requirement attaches to a single feature. Some apply to the whole system, and they are easy to forget because no story owns them. All traffic over modern TLS. Secrets from a vault, never in code. Security events logged, but personal data never logged. Dependencies scanned and kept current. Error messages that reveal nothing sensitive. Data retention and deletion honoured. Capture these once as platform requirements that every team inherits, rather than rediscovering them per project.

System-wide requirements
  • all traffic over TLS 1.2+ secrets from a vault, never in code
  • security events logged; PII never logged
  • dependencies scanned and kept current
  • errors reveal nothing sensitive
  • data retention honoured

Common mistakes

Mistakes. Be secure as the whole of the security requirement. Writing only functional stories and never the abuse cases that go with them. Requirements with no test and no owner, which quietly disappear. Ignoring mature lists like ASVS and starting from scratch. Leaving security to appear at the end as penetration test findings, which is the expensive path this whole stage is trying to avoid. And letting the same gap recur in every project because nobody captured it as a standard requirement.

Avoid these
  • "be secure" as the whole requirement
  • functional stories, never abuse cases
  • requirements with no test and no owner
  • ignoring lists like ASVS
  • security added only at the end, as findings
  • the same gap recurring, never captured

Say it like this

In the interview: I derive security requirements from abuse cases. For each user story I ask how it could be misused, from guessing and tampering to acting on other users' data, and each answer becomes a specific, testable requirement. I reuse ready-made lists such as OWASP ASVS and map any compliance obligations. I put the requirements into acceptance criteria and the definition of done, write negative tests for them, and capture cross-cutting ones, like TLS, logging and secrets, as platform standards.

In the interview
  • "I derive them from abuse
  • cases: for each user story I
  • ask how it could be misused, and each answer becomes a testable requirement. I reuse
  • OWASP ASVS and map compliance
  • needs, add them to acceptance
  • criteria and the definition
  • of done, and capture
  • system-wide ones as standards."

Interview questions

Q1What is a security requirement?

A specific, testable statement of security behaviour a system must have, such as how passwords are stored, how access is restricted or how long a token is valid. Like functional requirements, they can be verified and signed off.

Q2What is an abuse case?

The misuse counterpart of a use case: a description of how a feature could be exploited or misused, such as uploading a script instead of an image or accessing another user's data. Abuse cases are used to derive security requirements and test cases.

Q3How do you derive security requirements?

By taking each user story and asking how it could be abused, using prompts about unauthorised access, malformed or excessive input, acting on others' data, and skipped or repeated steps. Each abuse case becomes a requirement, supplemented by standard lists and compliance obligations.

Q4What is OWASP ASVS?

The OWASP Application Security Verification Standard: a structured, levelled catalogue of application security requirements covering authentication, access control, validation, cryptography, logging and more. It provides ready-made, testable requirements for projects.

Q5Why are missing requirements a common cause of breaches?

If no requirement specifies secure behaviour, developers build the feature to work, not to resist misuse. The result, such as tokens that never expire or exports that ignore tenancy, functions correctly yet is insecure, and is only noticed when exploited.

Q6How do security requirements fit into agile development?

They become security acceptance criteria on user stories, automated negative tests, and part of the definition of done, while cross-cutting ones become platform standards. This keeps them visible and verifiable in each iteration rather than deferred.

Q7What is the difference between a use case and a misuse case?

A use case describes intended, legitimate interactions with a system. A misuse or abuse case describes hostile or unintended interactions by an attacker. Analysing both ensures the design accounts for how the system will be attacked, not only used.

Q8What are non-functional security requirements?

System-wide requirements not tied to a single feature, such as enforcing TLS, sourcing secrets from a vault, logging security events without personal data, scanning dependencies and handling errors safely. They are best captured once as standards every team inherits.