Web Application Security and the OWASP Top 10
How web applications are attacked and defended, for security analysts: the OWASP Top 10 categories explained with examples, injection, broken access control, authentication failures, security misconfiguration, vulnerable components, SSRF, logging failures, plus security headers, a WAF, testing and secure development practices.
Why the web is the front line
Almost every organisation exposes web applications and APIs to the internet: customer portals, shops, login pages, admin consoles. They process valuable data, are reachable by anyone, and are built by developers under time pressure, so they are among the most attacked assets. A security analyst needs to understand how these attacks work to detect them in logs, advise developers and test defences. (The Backend and Frontend courses cover the developer’s side; this lesson is the defender’s overview.)
How a web request works, briefly
A browser sends an HTTP request (method, URL, headers, cookies, body) and the server returns a response (status, headers, body). Security issues arise at every point where input from the client is trusted: URL parameters, form fields, headers, cookies, file uploads and JSON bodies are all attacker-controlled. The server application, database, file system and other internal services behind it are the targets.
The OWASP Top 10
The Open Worldwide Application Security Project (OWASP) publishes a widely used awareness list of the most critical web application risks, based on real data. The 2021 edition’s categories (check owasp.org for the current version):
| # | Category | In one sentence |
|---|---|---|
| A01 | Broken Access Control | Users can do or see things they should not |
| A02 | Cryptographic Failures | Sensitive data is not protected properly in transit or at rest |
| A03 | Injection | Untrusted input is interpreted as commands or queries |
| A04 | Insecure Design | Missing or weak security in the design itself |
| A05 | Security Misconfiguration | Insecure defaults, open services, verbose errors, missing hardening |
| A06 | Vulnerable and Outdated Components | Using libraries and frameworks with known flaws |
| A07 | Identification and Authentication Failures | Weak login, session and credential handling |
| A08 | Software and Data Integrity Failures | Untrusted updates, plugins, CI/CD or serialised data |
| A09 | Security Logging and Monitoring Failures | Attacks cannot be detected or investigated |
| A10 | Server-Side Request Forgery (SSRF) | The server is tricked into making requests for the attacker |
A01 Broken Access Control
The most common serious flaw. The application authenticates users but does not properly check what they may do or access.
- IDOR (insecure direct object reference): changing
/orders/1042to/orders/1043shows someone else’s order. - Privilege escalation: a normal user calls an admin function (
/admin/deleteUser) because only the menu was hidden. - Missing function-level checks on APIs, path traversal (
../../etc/passwd), CORS misconfiguration, and forceful browsing to unlinked pages. - Defences: deny by default; enforce authorisation on the server for every request and object; use indirect or unguessable references where useful (but never as the only control); centralise the access-control logic; test with two accounts of different roles; log access-control failures.
A02 Cryptographic Failures
Data exposed because encryption is missing, weak or misused: HTTP instead of HTTPS, old TLS versions, weak ciphers, passwords stored with fast hashes or in plain text, hard-coded keys, no encryption of sensitive fields at rest, predictable tokens. Defences: TLS everywhere with modern settings (HSTS), encrypt sensitive data at rest, hash passwords with Argon2id/bcrypt/scrypt, use strong random numbers, manage keys properly, do not store what you do not need.
A03 Injection
Untrusted data is sent to an interpreter as part of a command or query. Types: SQL injection, NoSQL, OS command injection, LDAP, template injection, and cross-site scripting (XSS), which is injection into the browser.
- SQL injection: input like
' OR '1'='1changes the meaning of a query and can bypass login, read other tables or modify data. Detection in logs: odd characters (',--,UNION SELECT,SLEEP() in parameters, database errors. - XSS: attacker script runs in other users’ browsers (stored, reflected, DOM-based) and can steal sessions or act as the user.
- Defences: parameterised queries and safe APIs, input validation by allow-list, output encoding for the correct context, avoid dangerous functions (
eval,exec,innerHTML), least-privilege database accounts, and a Content Security Policy as a backstop.
A04 Insecure Design
Flaws that cannot be fixed by perfect coding because the design lacks security: no rate limit on password reset, business logic that lets a user apply a coupon repeatedly, a “security question” recovery flow, trust placed in client-side checks. Defences: threat modelling (STRIDE) during design, secure design patterns, abuse-case thinking (“how would I cheat this?”), and security requirements in the specification.
A05 Security Misconfiguration
Default accounts and passwords, unnecessary features and sample apps, directory listing, verbose error pages and stack traces, cloud storage left public, missing security headers, overly permissive CORS, debug mode in production, unpatched servers. Defences: hardened, repeatable builds; remove what is unused; separate configuration per environment; regular configuration scans; automated checks in the pipeline.
A06 Vulnerable and Outdated Components
Applications are mostly third-party code. Flaws such as Log4Shell (Log4j) and many CMS plugin vulnerabilities were exploited at scale. Defences: an inventory of components (SBOM), software composition analysis (Dependabot, npm audit, Snyk, OWASP Dependency-Check), prompt updates, removing unused dependencies, and getting packages only from trusted sources.
A07 Identification and Authentication Failures
Credential stuffing, brute force, weak password rules, missing MFA, session identifiers in URLs, sessions that do not expire or rotate after login, insecure password recovery. Defences: MFA, rate limiting and lockout, breached-password checks, secure session management (random IDs, HttpOnly/Secure/SameSite cookies, timeout, regenerate on login), generic login error messages (see the authentication lesson).
A08 Software and Data Integrity Failures
Code and data used without verifying integrity: auto-updates without signatures, compromised CI/CD pipelines and build dependencies (the SolarWinds attack), insecure deserialisation that runs attacker code, untrusted CDN scripts. Defences: signed artefacts and verified updates, Subresource Integrity for external scripts, protected pipelines with least-privilege secrets, code review, avoiding native deserialisation of untrusted data.
A09 Security Logging and Monitoring Failures
Without logs and alerts, a breach can run for months. Missing logs of login failures and access-control denials, logs that are not monitored, no alerting, logs only stored locally, or logs that contain secrets. Defences: log security events with enough detail, centralise and protect them, alert on suspicious patterns and have an incident response plan (the previous lessons).
A10 Server-Side Request Forgery (SSRF)
The application fetches a URL supplied by the user (an image import, a webhook, a link preview), and the attacker points it at internal services or cloud metadata (http://169.254.169.254/), stealing credentials. Defences: allow-list permitted destinations, block private and link-local ranges, disable unneeded URL schemes and redirects, network segmentation so the app server cannot reach sensitive internal services, and enforce IMDSv2 on cloud instances.
Other attacks worth knowing
- CSRF (cross-site request forgery): a malicious site makes the victim’s browser send an authenticated request. Defences: SameSite cookies, anti-CSRF tokens.
- Clickjacking: hidden frames trick clicks. Defence:
frame-ancestors. - Open redirect: used to make phishing links look legitimate.
- File upload flaws: uploading a script that the server then runs (web shell). Defences: validate type and content, rename files, store outside the web root, disable execution.
- XXE (XML external entities), insecure deserialisation, HTTP request smuggling, race conditions, mass assignment.
- API-specific risks (OWASP API Security Top 10): broken object-level authorisation, excessive data exposure, missing rate limits, unprotected admin endpoints, shadow and forgotten APIs.
- Denial of service at the application layer (expensive queries, regex DoS, slow requests).
- Bots: scraping, credential stuffing, carding, inventory hoarding.
Defensive building blocks
Security headers
| Header | Purpose |
|---|---|
Strict-Transport-Security |
Force HTTPS for a period (HSTS) |
Content-Security-Policy |
Control sources of scripts, styles, frames; reduce XSS impact |
X-Content-Type-Options: nosniff |
Stop MIME-type sniffing |
Referrer-Policy |
Limit referrer data leakage |
Permissions-Policy |
Restrict browser features |
frame-ancestors (CSP) / X-Frame-Options |
Prevent clickjacking |
Set-Cookie: ...; Secure; HttpOnly; SameSite |
Protect cookies |
Test your headers with browser developer tools or free scanners such as securityheaders.com and Mozilla Observatory.
Web application firewall (WAF)
A WAF inspects HTTP traffic and blocks known attack patterns (SQLi, XSS, path traversal) and bad bots, using rule sets such as the OWASP Core Rule Set. Use it for virtual patching (blocking an exploit while you fix the code), rate limiting and bot control. It is a layer, not a cure: it can be evaded, produces false positives that need tuning, and cannot fix logic flaws like broken access control. Run it in detection mode first, then block.
Secure development life cycle (SDLC)
Build security in rather than bolting it on:
- Requirements and design: security requirements, threat modelling.
- Secure coding: standards, framework features, peer review.
- Testing: SAST (static analysis of source code), SCA (dependency scanning), DAST (dynamic scanning of the running app), IAST, manual penetration testing, secrets scanning.
- Pipeline gates: fail builds on critical findings.
- Deployment: hardened configuration, infrastructure as code reviewed.
- Operations: monitoring, WAF, patching, vulnerability disclosure and bug bounty.
What defenders look for in logs
GET /products?id=5' OR '1'='1 -- HTTP/1.1 SQL injection attempt
GET /search?q=<script>alert(1)</script> XSS probe
GET /../../../../etc/passwd path traversal
POST /login (hundreds per minute from one IP, many users) password spraying
GET /wp-admin, /.env, /phpmyadmin, /.git/config scanning for known paths
User-Agent: sqlmap, Nikto, Nmap Scripting Engine automated tools
HTTP 500 spikes right after unusual requests exploit attempts causing errors
Remember that attackers use HTTPS and encode payloads, so detection relies on application and WAF logs as well as network sensors.
Testing safely and legally
Only test applications you own or have written permission to test. Use a deliberately vulnerable practice environment such as OWASP Juice Shop, DVWA, WebGoat or the labs of PortSwigger’s Web Security Academy, run locally or in an isolated lab. Tools: a browser with developer tools, an intercepting proxy such as OWASP ZAP or Burp Suite, and scanners for headers and TLS. Testing someone else’s site without permission can be a crime, even if you mean well.
Customers report that after logging in they can see other customers' invoices by changing a number in the URL. Which OWASP category is this, and what should the developers change?
Broken Access Control (an IDOR). The server must check that the invoice belongs to the signed-in user (or that the user’s role allows access) on every request, rather than trusting the identifier in the URL. Add authorisation checks centrally, test with multiple accounts, and review logs for earlier enumeration (a sequence of increasing IDs from one user) to scope any breach.
Can You Explain It?
Close the lesson and answer these without looking back. The goal isn't the wording — it's whether you've formed a usable mental model.
- Explain how SQL injection works and the single most important defence.
- Describe the difference between authentication failures (A07) and broken access control (A01) with an example of each.
- What can a WAF do well, and what can it never replace?
🧪 Want to practise this on your own computer? See how to set up your lab →