Security testing and the OWASP Top 10
You learn what static analysis, dynamic scanning, fuzzing, penetration testing and code review find and when, plus the OWASP Top 10 (2021) list. The exam asks 'which category is this scenario' and tool metrics (precision, recall).
You wrote secure code, but is it really secure? The only way to know is to test. This page is the verification and validation leg of the secure SDLC: which testing technique finds which vulnerability, and which one misses what. The second half has the OWASP Top 10 (2021). The two most common types on the exam: “what does this technique do / which one doesn’t execute the code” and “which OWASP category is this scenario”. In between, small calculations such as precision/recall or a fuzzing probability may appear.
Golden rules:
- One technique isn’t enough. Static analysis, dynamic testing and human review find different flaws.
- Early testing is cheap. SAST and code review work while the code is being written.
- Tool output is raw data. Every finding must be verified; a false positive is noise, a false negative is a blind spot.
- No testing without permission. A pentest is done with written permission and a clear scope.
- Recognize the OWASP list from the scenario. Memorizing category names is not enough, match them with examples.
Security testing techniques
| Technique | When | How | What it finds well | Weak side |
|---|---|---|---|---|
| Code review | every commit | a human reads, with a checklist | logic and design flaws, missing authorization checks | slow, depends on the person |
| SAST | during build, CI | data flow analysis without running the code | injection, dangerous APIs, hard-coded passwords | many false positives, doesn’t see the runtime environment |
| DAST | a running application in a test environment | sends HTTP requests from outside | configuration errors, reflected XSS, missing headers | can’t say which line of code it is, limited coverage |
| Fuzzing | test, continuous | thousands of malformed inputs | crashes, memory errors, parser vulnerabilities | doesn’t find logic errors |
| Penetration testing | before release, periodic | an authorized expert thinks like an attacker | chained vulnerabilities, business logic flaws | expensive, a snapshot in time |
| SCA | CI | compares dependency versions with the CVE database | libraries with known vulnerabilities | doesn’t look at flaws in your own code |
Static analysis (SAST)
SAST marks the place where input comes in as the source, and the place where it is used dangerously as the sink, and checks whether there is sanitization on the path in between. This is called taint analysis.
String id = request.getParameter("id"); // source: untrusted
String sql = "SELECT * FROM orders WHERE id = " + id;
stmt.executeQuery(sql); // sink: SQL engine
// SAST warning: tainted data flows from getParameter to executeQuery
Advantage: it doesn’t need a running system yet, and it examines every path. Disadvantage: it can’t always tell that a value is actually harmless, so it produces false alarms.
Measuring a tool’s success: precision and recall
Say a tool reports 60 findings and 45 of them are real. Say the code has 50 real vulnerabilities in total.
| Concept | Meaning | Value |
|---|---|---|
| TP (true positive) | a correct finding | 45 |
| FP (false positive) | a false alarm | 60 − 45 = 15 |
| FN (false negative) | a real vulnerability that was missed | 50 − 45 = 5 |
In security a false negative is more dangerous (the vulnerability goes live), but a very low precision makes the developer switch the tool off. A balance is struck between the two.
Dynamic analysis (DAST)
DAST tests the running application without seeing the source code: it fills in forms, puts special characters in parameters, and looks in the response for error messages, reflected input and missing security headers (Content-Security-Policy, Strict-Transport-Security). Since it tests the real environment, it sees configuration errors; but it tests only the pages it can reach. IAST combines the two by placing an agent inside the application.
Fuzzing
A fuzzer gives the program unexpected input and looks for crashes, infinite loops and memory errors. It is especially effective for file format parsers, network protocols and C/C++ code.
| Type | How it generates input |
|---|---|
| Mutation-based | corrupts valid sample files by flipping bits, inserting and deleting bytes |
| Generation-based | produces from scratch from a format definition (grammar, protocol schema) |
| Coverage-guided | keeps inputs that open a new code path and mutates them (AFL, libFuzzer) |
Why are many inputs needed? If a bug is triggered with probability per input, the probability that it is triggered at least once in independent inputs is:
For , gives . To catch the same bug with high probability, the number of inputs has to be increased several times. Coverage-guided fuzzing tries precisely to increase this .
PITFALL · fuzzing doesn’t find every vulnerability. Bugs that don’t produce a crash (e.g. IDOR, a wrong authorization check) are invisible to a fuzzer. The program returns the “right” response but shows someone else’s data. These are found by code review and pentest.
Penetration testing
A pentest is an authorized expert testing the system through an attacker’s eyes, but with written permission and within a defined scope. The goal is to find the vulnerability and report it to the owner.
| Type | Tester’s knowledge |
|---|---|
| Black-box | no inside information, like an outside attacker |
| Grey-box | partial information, e.g. a normal user account |
| White-box | source code, architecture, administrator accounts |
Typical phases: scope and rules of engagement → information gathering → vulnerability scanning → controlled verification of findings → reporting (with risk level and remediation advice) → retest after the fix. The report is the real product of the test.
OWASP Top 10 (2021)
OWASP (Open Worldwide Application Security Project) publishes the most critical risk categories in web applications every few years. The 2021 list:
| Code | Category | Typical example | Core countermeasure |
|---|---|---|---|
| A01 | Broken Access Control | changing the id in the URL to see someone else’s record (IDOR) | server-side authorization check on every request, default deny |
| A02 | Cryptographic Failures | storing a password with MD5, card data over HTTP | strong algorithms, TLS, bcrypt/Argon2 for passwords |
| A03 | Injection | SQLi, XSS, OS command injection | parameterized queries, output encoding, allowlist |
| A04 | Insecure Design | unlimited attempts on a password reset | threat modeling, secure design patterns |
| A05 | Security Misconfiguration | default password, open directory listing, verbose errors | hardening, automatic configuration |
| A06 | Vulnerable and Outdated Components | a library with a CVE for which a patch exists | dependency inventory, SCA, regular updates |
| A07 | Identification and Authentication Failures | a login open to brute force, weak session management | MFA, rate limiting, secure session ID |
| A08 | Software and Data Integrity Failures | unsigned updates, insecure deserialization | digital signatures, integrity checks, a trusted CI/CD |
| A09 | Security Logging and Monitoring Failures | failed logins aren’t logged, no alerts | central logging, alerts, incident response plan |
| A10 | Server-Side Request Forgery (SSRF) | the server sends a request into the internal network to a user-supplied URL | destination allowlist, block internal addresses |
Important changes from 2017 to 2021: Broken Access Control rose from fifth to first; XSS stopped being a separate category and was merged into Injection; Insecure Design, Software and Data Integrity Failures and SSRF were added as new categories.
TIP · finding the category from the scenario. First ask: is the identity correct? If so, but unauthorized data is being accessed, it is A01; if the identity itself is the problem, A07. If data goes to an interpreter as code, A03. If the setting is wrong, not the code, A05. If the hole is in someone else’s library, A06. If the server goes to an address given by the user, A10.
Which test catches which category well? SAST is strong on A03, SCA is a perfect fit for A06, and DAST is good on A05. A01 and A04 are mostly human work: code review, threat modeling and pentest.
Common mistakes
| Wrong idea | Correct |
|---|---|
| SAST runs the program | It doesn’t; DAST and fuzzing do |
| DAST looks at the source code | It doesn’t; it sends requests to the running application from outside |
| Fuzzing finds logic errors too | It looks for crashes and hangs; it can’t see bugs like IDOR |
| precision = TP/(TP+FN) | That is recall; precision = TP/(TP+FP) |
| A pentest can be done without permission, there’s no problem if I mean well | A test without written permission and scope is illegal |
| First in OWASP 2021 is Injection | A01 is Broken Access Control; Injection is A03 |
| XSS is a separate category in 2021 | It is inside A03 Injection |
| A logged-in user sees someone else’s invoice → A07 | Identity is correct, authorization is wrong: A01 |
| A logging library with a CVE → A09 | It is A06; A09 is the lack of logs and monitoring |
| One pentest is enough | It is a snapshot; repeat it after every major change |
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
Which technique analyzes source code or bytecode for vulnerabilities without executing the program?
- DAST
- Fuzzing
- SAST
- Penetration testing
Show answer
SAST (static application security testing) reads the code without running it: it follows the data flow and checks whether unsanitized input reaches a dangerous point such as executeQuery. DAST and fuzzing send input to the running program, and a pentest is done on a running system.
What does a fuzzer primarily do?
- Reads the code and reports insecure functions
- Feeds large numbers of malformed or random inputs to a program and watches for crashes or hangs
- Encrypts test data
- Generates documentation from code
Show answer
Fuzzing gives a program a large number of malformed, boundary or random inputs and looks for crashes, hangs and memory errors. A mutation-based fuzzer corrupts valid samples, and a generation-based fuzzer produces inputs from the grammar of the format. Modern fuzzers (AFL, libFuzzer) steer the input by code coverage.
In the OWASP Top 10 (2021), which category is ranked #1?
- Injection
- Broken Access Control
- Cryptographic Failures
- Security Misconfiguration
Show answer
In the 2021 list, A01 is Broken Access Control. Injection, which was first in 2017, dropped to A03 in 2021. It rose to the top because some kind of access control flaw was found in a large share of the tested applications.
A logged-in user views /invoice?id=1043, changes the URL to /invoice?id=1044, and sees another customer's invoice. Which OWASP 2021 category is this?
- A03 Injection
- A01 Broken Access Control
- A07 Identification and Authentication Failures
- A10 Server-Side Request Forgery
Show answer
The user's identity is correct (logged in), but the server doesn't check whether the invoice belongs to this user. This is IDOR (insecure direct object reference), the typical example of A01. The fix: check invoice.ownerId == currentUser.id on every request (complete mediation).
In OWASP Top 10 2021, cross-site scripting (XSS) is included in which category?
- It has its own category, A07 XSS
- A03 Injection
- A05 Security Misconfiguration
- It was removed from the list
Show answer
In 2017, XSS was a separate category (A7). In 2021 it was merged into the Injection category, because the root cause is the same: untrusted data reaches an interpreter (the SQL engine, the browser) as code.
An application stores user passwords as unsalted MD5 hashes. Which OWASP 2021 category best fits?
- A02 Cryptographic Failures
- A06 Vulnerable and Outdated Components
- A09 Security Logging and Monitoring Failures
- A04 Insecure Design
Show answer
A weak hash that is unsuitable for passwords (MD5, unsalted) falls under A02. MD5 is very fast, and without salt identical passwords give the same hash and can be cracked with precomputed tables. The right way: a slow, salted password hash function such as bcrypt, scrypt or Argon2.
A production server still has the vendor's default admin password and directory listing enabled. Which OWASP 2021 category is this?
- A05 Security Misconfiguration
- A01 Broken Access Control
- A08 Software and Data Integrity Failures
- A03 Injection
Show answer
There is no bug in the code, the settings are wrong: default password, open directory listing, verbose error pages, unnecessary open services. All are A05. Countermeasure: a hardening checklist and automatic, repeatable configuration across environments.
A SAST tool reports 40 findings; 28 of them are real vulnerabilities. The code actually contains 35 real vulnerabilities. What are the tool's precision and recall?
Show answer
True positives TP = 28, false positives FP = , missed FN = .If precision is low, developers get tired of the false alarms; if recall is low, vulnerabilities slip through. Their harmonic mean is F1 ≈ 0.747.
A mutation fuzzer triggers a particular crash with probability per input, independently. It runs 20 000 inputs. What is the expected number of crashing inputs, and the probability of at least one crash (4 decimals)?
Show answer
Expected value .
At least one crash: .
Check: for small , . To find low-probability bugs a large number of inputs is needed; the power of fuzzing comes from automation.
A penetration tester is given full source code, architecture diagrams and credentials before testing. What type of test is this?
- Black-box
- White-box
- Grey-box
- Red-team without scope
Show answer
In a white-box (clear-box) test the tester knows everything: code, architecture, accounts. In black-box they know nothing, like an outside attacker. Grey-box is in between, for example only a normal user account is given. In every case written permission and a scope (rules of engagement) are required.
An application uses a third-party logging library version with a publicly known critical CVE that has had a patch available for a year. Which OWASP 2021 category is this?
- A06 Vulnerable and Outdated Components
- A09 Security Logging and Monitoring Failures
- A02 Cryptographic Failures
- A04 Insecure Design
Show answer
The hole is not in your code but in a component you use, and a patch exists but has not been applied: A06. Don't let the word "logging" in the name mislead you; A09 is about events not being logged and monitored. Countermeasure: a dependency inventory (SBOM) and SCA (software composition analysis) tools.
A feature lets users enter a URL so the server fetches a preview image. An attacker enters http://169.254.169.254/ and the server returns internal cloud metadata. Which OWASP 2021 category is this, and what is the core fix?
- A03 Injection; escape HTML
- A10 SSRF; validate the destination against an allowlist and block internal address ranges
- A07 Authentication Failures; add MFA
- A05 Misconfiguration; disable directory listing
Show answer
The server sends a request on its own behalf to an address given by the user and reaches a service on the internal network: SSRF (server-side request forgery). The root fix is to limit the destinations the server can go to with an allowlist, block internal network and link-local ranges, and not follow redirects. Egress restrictions at the network level are the second layer.
Verification: Precision, recall, F1 and fuzzing probabilities (1 - (1 - p)^n) were computed with node (verify/SEN2008/14.mjs). The OWASP ranking was checked against the official 2021 list.