QA AND TEST AUTOMATION · PART 9 · NON-FUNCTIONAL TESTING · SECURITY · 84 OF 112

Security Testing for QA: OWASP Top 10 and ZAP

Security testing a tester can do every day: the OWASP Top 10 in tester's terms, access control checks that caught ShopRung's order-leak bug (Bob reading Alice's order), authentication tests (no lockout after 10 wrong passwords, but no user enumeration), injection probes, security headers, SAST, dependency scans and DAST with OWASP ZAP, and the rules for testing safely and legally.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 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. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 12

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

Key takeaways

  • OWASP Top 10
  • two-user access tests caught order-leak
  • no lockout found
  • injection
  • headers
  • SAST, SCA, ZAP
  • permission

Notes

OWASP Top 10

OWASP, the Open Worldwide Application Security Project, publishes the Top 10 web risks. In tester's words: broken access control, seeing or changing data that is not yours, is number one. Cryptographic failures, like passwords stored plainly. Injection, such as SQL or script injection. Security misconfiguration. Vulnerable third party components. Authentication failures. And missing logging, so attacks go unnoticed.

Top risks (OWASP 2021)
  • A01 broken access control: seeing others' data
  • A02 crypto failures: plain passwords, no HTTPS
  • A03 injection: SQL, script
  • A05 misconfiguration: headers, debug pages, defaults
  • A06 vulnerable components
  • A07 auth failures: guessing
  • A09 no logging of attacks

Access control

The most valuable security test is simple: log in as one user and ask for another user's data. Order two belongs to Alice. With no token, ShopRung answers four oh one. As Bob, it answers 404, which also hides that the order exists. Then we turned on ShopRung's order leak bug, and Bob received Alice's whole order. This is called IDOR, or broken object level authorization. Test it on every endpoint with an id.

GET /api/orders/2 (Alice's)
as Alice          200  her order
no token          401
as Bob            404  "No order
                       with id 2"

order-leak bug ON:
as Bob            200  Alice's
  order, items and total

Authentication

Next, authentication. We sent ten wrong passwords for Alice: ten four oh ones, and then the correct password still worked. There is no lockout or rate limit, so an attacker could guess forever; that is a real finding. On the good side, an unknown email and a wrong password give the same status and the same message, so attackers cannot discover which emails have accounts. Also test token expiry, logout, and password reset links.

POST /api/auth/login
10 wrong passwords for Alice:
  401 x 10
then the right password:  200
→ no lockout, no rate limit:
  passwords can be guessed

unknown email vs wrong password:
  same 401, same message
→ good: no user enumeration

Injection

Injection testing means sending what an attacker would send. A classic SQL probe in ShopRung's search returned zero products, not every product, because ShopRung uses parameterised queries. A name containing an HTML image tag with an error handler must appear as text, never run. Also try odd ids, huge bodies, wrong types, and extra fields like role admin, to catch mass assignment. Only ever do this on systems you are allowed to test.

Probes
search: ' OR 1=1--
  → 200, 0 products (safe:
    parameterised queries)
name: <img src=x onerror=..>
  → must show as text, never run
ids: -1, 0, 99999999, abc
huge bodies, wrong types,
  extra fields ("role":"admin")
only on systems you may test

Headers

Response headers tell the browser how to protect users. ShopRung's home page sends a content type and cache control, but no content security policy, no X content type options, and no frame protection against clickjacking. On HTTPS sites, also check strict transport security. These are exactly what automated scanners flag first. They are low effort to fix and cheap to check in every pipeline.

curl -I http://localhost:8080/
HTTP/1.1 200 OK
Content-Type: text/html; ...
Cache-Control: no-store

missing, and scanners flag:
  Content-Security-Policy
  X-Content-Type-Options
  frame-ancestors / X-Frame-
    Options (clickjacking)
  Strict-Transport-Security
    (on HTTPS)

Scanners

Automated tools come in kinds. Static analysis, or SAST, reads source code for risky patterns, using tools like Semgrep or CodeQL. Software composition analysis checks dependencies for known vulnerabilities: npm audit, Dependabot, OWASP dependency check. Secret scanning finds keys committed to Git. Dynamic analysis, or DAST, attacks the running application, with OWASP ZAP or Burp Suite. Every finding needs triage: real, false positive, or accepted risk.

Automated security checks
  • SAST: reads source code (Semgrep, CodeQL, SonarQube)
  • SCA: known-vulnerable dependencies (npm audit, Dependabot, OWASP Dep-Check)
  • secret scanning: keys in Git
  • DAST: attacks the running app (OWASP ZAP, Burp Suite)
  • each finding needs triage

OWASP ZAP

OWASP ZAP is a free scanner. Its baseline scan crawls the site and runs passive checks only, looking at responses for issues like missing headers and cookie flags, without attacking, so it is safe for shared environments. It runs in CI from the ZAP Docker image and writes an HTML report. A full scan sends active attacks, so run it only against your own test environment. A lab later in this track runs ZAP against ShopRung.

ZAP baseline scan
docker run --rm -v $(pwd):/zap/wrk \
  ghcr.io/zaproxy/zaproxy:stable \
  zap-baseline.py \
  -t https://staging.example.com \
  -r zap-report.html

baseline = spider + PASSIVE
  checks only: safe for shared
  environments
full scan = ACTIVE attacks:
  only on your own test env

Common mistakes

Mistakes. Testing with only one user, so access control bugs never appear. Trusting the interface: a hidden button does not protect the API behind it. Pasting raw scanner output as bugs without triage. Running active scans on shared or production systems. And treating security as a yearly event instead of checks in every pipeline.

Avoid these
  • only testing with one user
  • trusting the UI: hidden buttons ≠ protected APIs
  • scanner output pasted as bugs without triage
  • active scans on shared or production systems
  • security only once a year

Say it like this

In the interview: access control first, with two users on every endpoint that takes an id, expecting four oh three or 404. Authentication: lockout or rate limits, token expiry, no user enumeration. Injection probes and security headers. In CI, static analysis, dependency and secret scans, and a ZAP baseline scan on staging. All within an agreed scope, with findings triaged and every fix covered by a regression test.

In the interview
  • "Access control first: two users, every id-based endpoint, expect
  • 403/404. Auth: lockout, token
  • expiry, no enumeration.
  • Injection probes, headers.
  • In CI: SAST, dependency and secret scans, ZAP baseline on staging. All within an agreed
  • scope, findings triaged, fixes
  • covered by regression tests."

Interview questions

Q1What is the number one OWASP Top 10 risk?

Broken access control (A01:2021): users acting outside their permissions, such as reading another user's data.

Q2What is IDOR?

Insecure direct object reference: changing an id in a request gives access to another user's object because ownership is not checked.

Q3How do you test access control?

Use two users and request each other's resources on every id-based endpoint, plus requests without a token; expect 401, 403 or 404.

Q4What is user enumeration?

Different responses for unknown accounts and wrong passwords let an attacker discover valid emails; both should look the same.

Q5What is the difference between SAST and DAST?

SAST analyses source code without running it; DAST attacks the running application from outside, like OWASP ZAP.

Q6What does a ZAP baseline scan do?

Spiders the target and runs passive checks only (headers, cookies, information leaks), so it is safe for shared environments.

Q7Which security headers should you check?

Content-Security-Policy, X-Content-Type-Options, frame-ancestors or X-Frame-Options, Strict-Transport-Security on HTTPS, and cookie flags.

Q8What must you have before security testing?

Written permission and an agreed scope; never test production or real data without agreement.