Knowledge / Information Technology / Web application security (OWASP Top 10)

Web application security (OWASP Top 10)

Information Technology (B.E./B.Tech) · Information security · free study notes for exams, placements and interviews

In short

Web application security is the practice of designing, building and testing web applications so that attackers cannot read, alter or destroy data or take over accounts through the application's own interfaces. The OWASP (Open Worldwide Application Security Project) Top 10 is a free, community-ranked list of the ten most critical web application risk categories; the current edition in wide use is OWASP Top 10 - 2021, with a 2025 revision released for community review (check owasp.org for the finalised edition before quoting it as current). It matters because almost every Indian bank, fintech, SaaS and government portal is a web or API application, and breaches invite liability under the Information Technology Act, 2000 (Sections 43A and 72A), the Digital Personal Data Protection Act, 2023 and CERT-In's 2022 directions on 6-hour incident reporting. It is examined in university "Information Security" and "Web Technology" papers, in GATE CS (security unit), and asked in almost every product-company, service-company and security-role interview (TCS, Infosys, Wipro, Accenture, Paytm, Razorpay, Zoho, Freshworks, banks' IT security teams).

Explained

What the OWASP Top 10 is and how it is built

The ten categories (2021 edition), with mechanism and defence

  1. A01 Broken Access Control - the application does not enforce *what a logged-in user is allowed to do*. Includes IDOR (insecure direct object reference: changing /invoice?id=101 to 102), vertical escalation (a normal user reaching /admin), forced browsing, missing function-level authorisation on APIs, and CORS misconfiguration. Defence: deny by default; enforce authorisation server-side on every request from the session identity, never from a client-supplied role/ID; use non-guessable or ownership-checked references; centralise checks in a filter/middleware; log failures.
  2. A02 Cryptographic Failures (was "Sensitive Data Exposure") - data in transit or at rest unprotected or weakly protected: plain HTTP, old TLS, hardcoded keys, MD5/SHA-1 password hashing, ECB mode, weak random. Defence: TLS 1.2/1.3 everywhere with HSTS; bcrypt/scrypt/Argon2 with per-user salt for passwords; AES-GCM for data; CSPRNG for tokens; classify data and do not store what is not needed.
  3. A03 Injection - untrusted input becomes part of a command or query: SQLi, NoSQL injection, OS command injection, LDAP injection, ORM injection, and XSS (merged into Injection in 2021). Defence: parameterised queries / prepared statements, ORM with bound parameters, allow-list input validation, output encoding appropriate to the context (HTML body, attribute, JS, URL), stored procedures without dynamic SQL, LIMIT on queries.
  4. A04 Insecure Design (new in 2021) - the flaw is in the design, not the code: no rate limiting on OTP, business logic that lets a coupon be reused, password reset that trusts an email in a request, no segregation of tenants. Defence: threat modelling (STRIDE), secure design patterns, misuse/abuse-case stories, reference architectures, limits and quotas built into the design.
  5. A05 Security Misconfiguration - default accounts and passwords, directory listing on, debug/stack traces shown, unnecessary features enabled, missing security headers, over-permissive cloud buckets, unpatched sample apps. XML External Entity (XXE) injection is folded here. Defence: hardened repeatable builds, configuration as code, minimal install, generic error pages, security headers, automated configuration scanning.
  6. A06 Vulnerable and Outdated Components - using a library, framework, CMS plugin or server version with known CVEs (Struts, Log4Shell in log4j2, old jQuery, old WordPress plugins). Defence: inventory with SBOM (CycloneDX/SPDX), SCA scanning (OWASP Dependency-Check, npm audit), patch SLAs, remove unused dependencies, get components only from official sources.
  7. A07 Identification and Authentication Failures - credential stuffing allowed, weak or default passwords, no MFA, session IDs in the URL, sessions not rotated after login, no logout/timeout, weak OTP, insecure password recovery. Defence: MFA, block known-breached passwords, rate-limit and progressively delay failed logins, server-side session store, regenerate the session ID on login and privilege change, Secure; HttpOnly; SameSite cookies.
  8. A08 Software and Data Integrity Failures - trusting code or data whose integrity is not verified: insecure deserialization (Java/PHP/Python objects from untrusted input leading to remote code execution), unsigned auto-updates, compromised CI/CD pipeline, scripts pulled from an unverified CDN. Defence: avoid deserializing untrusted data or use data-only formats (JSON) with strict type checks; digital signatures on updates and artefacts; Subresource Integrity (SRI) for CDN scripts; protect the build pipeline.
  9. A09 Security Logging and Monitoring Failures - attacks are not detected because logins, access-control failures and high-value transactions are not logged, logs stay local, or there is no alerting; also logging secrets or PII. Defence: log security-relevant events with user, time, source IP and outcome in a parseable format; ship to a central SIEM; alert and have an incident response plan; retain as required - CERT-In's April 2022 directions require Indian entities to keep ICT system logs for 180 days within India and report specified cyber incidents within 6 hours of noticing them, and to sync clocks to NIC/NPL NTP.
  10. A10 Server-Side Request Forgery (SSRF) - the server fetches a URL supplied by the user, so the attacker reaches internal services (http://169.254.169.254/ cloud metadata, http://localhost:8080/admin, internal databases). Defence: allow-list destination hosts/ports/schemes, resolve and validate the IP (block private/loopback/link-local ranges), disable redirects, no raw responses back to the client, segment the network.

Movement from 2017 to 2021 - commonly asked

2021 categoryWhat changed
A01 Broken Access ControlUp from #5 to #1; 94% of tested apps showed some form
A02 Cryptographic FailuresRenamed from "Sensitive Data Exposure" (cause, not symptom)
A03 InjectionDown from #1 to #3; XSS merged into it
A04 Insecure DesignNew - design-level flaws
A05 Security MisconfigurationUp from #6; XXE merged in
A06 Vulnerable/Outdated ComponentsUp from #9; renamed from "Using Components with Known Vulnerabilities"
A07 Identification and Authentication FailuresRenamed from "Broken Authentication", moved down
A08 Software and Data Integrity FailuresNew; absorbed insecure deserialization (2017 A8)
A09 Logging and Monitoring FailuresUp from #10, scope widened
A10 SSRFNew, added from the community survey
DroppedCross-Site Scripting (merged), Insecure Deserialization (merged), XXE (merged)

The classic three attacks in detail (exam favourites)

Security headers, cookies and the browser security model

Secure SDLC, testing and Indian compliance

Key points

Formulas and examples

CVSS v3.1 Base Score = f(Exploitability, Impact); Exploitability = 8.22 × AV × AC × PR × UI, Impact (scope unchanged) = 6.42 × ISS, where ISS = 1 − (1−C)(1−I)(1−A); C, I, A are Confidentiality, Integrity, Availability impacts (None 0, Low 0.22, High 0.56). Score is 0-10, rounded up to one decimal. Base = 0 if ISS = 0, else roundup(min(Impact + Exploitability, 10)).
Risk = Likelihood × Impact (OWASP Risk Rating: Likelihood = average of threat-agent and vulnerability factors; Impact = average of technical and business factors; each factor 0-9; 0-<3 LOW, 3-<6 MEDIUM, 6-9 HIGH)
Password keyspace / offline cracking time: combinations N = CL (C = character-set size, L = length); time = N / (2 × guesses per second) for the average case
Entropy H = L × log₂C bits per password

Example 1 - SQL injection authentication bypass and its fix. Vulnerable PHP-style query:

$sql = "SELECT * FROM users WHERE user='" . $_POST['u'] .
       "' AND pass='" . $_POST['p'] . "'";

Input u = admin' -- and any password gives:

SELECT * FROM users WHERE user='admin' --' AND pass='x'

Everything after -- is a comment, so the password check disappears and the attacker logs in as admin. Input u = x' OR '1'='1 returns all rows. Fixed with a prepared statement:

$stmt = $pdo->prepare(
  "SELECT id, pass_hash FROM users WHERE user = ?");
$stmt->execute([$_POST['u']]);
$row = $stmt->fetch();
if ($row && password_verify($_POST['p'], $row['pass_hash'])) { /* login */ }

The driver sends the query plan and the data separately, so admin' -- is treated as a literal username string. Note password_verify with a bcrypt hash - never MD5.

Example 2 - CVSS v3.1 for an unauthenticated SQL injection giving full data read. Vector: AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N → AV 0.85, AC 0.77, PR 0.85, UI 0.85.

If the same flaw also allowed modification and denial of service (C:H/I:H/A:H): ISS = 1 − 0.44³ = 1 − 0.0852 = 0.9148; Impact = 6.42 × 0.9148 = 5.873; Base = roundup(3.887 + 5.873 = 9.760) = 9.8 → Critical.

Example 3 - OWASP risk rating of an IDOR on an invoice endpoint. Likelihood factors (0-9): skill 3, motive 9 (data), opportunity 9, size 9 (anonymous internet) → threat agent avg = 7.5; ease of discovery 7, ease of exploit 5, awareness 9, intrusion detection 8 (not logged) → vulnerability avg = 7.25. Likelihood = (7.5 + 7.25)/2 = 7.375 → HIGH. Impact factors: loss of confidentiality 7, integrity 3, availability 1, accountability 7 → technical avg = 4.5; financial damage 5, reputation 7, non-compliance 7 (DPDP), privacy violation 9 → business avg = 7.0. Impact = (4.5 + 7.0)/2 = 5.75 → MEDIUM, so overall risk = High likelihood × Medium impact = High - fix before release.

Example 4 - why password hashing choice decides breach severity. A dump of 2,00,000 password hashes is stolen. Attacker rig: 10 billion (10¹⁰) MD5 guesses/second, but only 10,000 (10⁴) bcrypt(cost 12) guesses/second.

Example 5 - SSRF reaching cloud metadata, and the allow-list fix. An image-preview feature calls GET /preview?url=<user URL> server-side. Attacker sends url=http://169.254.169.254/latest/meta-data/iam/security-credentials/; the server, running on a cloud VM, returns temporary IAM credentials, and the attacker then reads the storage bucket. Fix: accept only https, resolve the hostname, reject any address in 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 and ::1/fc00::/7, re-check after each redirect (or disable redirects), allow only the whitelisted CDN domains, and return a processed thumbnail rather than the raw response.

ControlStopsDoes not stop
Prepared statementsSQL/NoSQL injectionXSS, access control flaws
Output encoding + CSPXSSCSRF, SQLi
Anti-CSRF token + SameSiteCSRFXSS (which can read the token)
HttpOnly cookieCookie theft by scriptThe XSS itself (actions still possible)
HTTPS/TLS + HSTSSniffing, downgrade, tampering in transitAny server-side flaw
WAFKnown attack patterns, buys timeLogic flaws, IDOR, novel payloads
MFACredential stuffing, phishing of password aloneSession hijacking after login

Where it is used

Interview questions

Common mistakes

Related topics

Cryptography basics · Identity and access management · Ethical hacking and penetration testing · Network security: firewalls, VPN and IDS · Security operations: SOC and SIEM · IT governance, risk and compliance

Open in the Knowledge reader →Find jobs →