Online admissions open for the SEO, web development and networking & cybersecurity courses. Enquire for the next batch.

OWASP Top 10 Explained: The 2021 Risks, Examples and Defences

6 min read Updated By the SkillNewton team

What is the OWASP Top 10?

The OWASP Top 10 is an awareness document from the Open Worldwide Application Security Project that ranks the most critical security risks to web applications. The 2021 edition lists ten categories, from A01 Broken Access Control to A10 Server-Side Request Forgery. Developers, testers and auditors use it as a shared starting point for secure coding, testing and review.

What the OWASP Top 10 is, and what it is not

OWASP is a non-profit foundation that publishes free, open security material, including the Top 10, the Web Security Testing Guide (WSTG) and the Application Security Verification Standard (ASVS). The Top 10 groups many individual weaknesses, catalogued as CWEs (Common Weakness Enumeration entries), into ten broad risk categories. The 2021 ranking combined contributed testing data with a community survey.

The list is an awareness document, not a complete standard. Passing a Top 10 checklist does not make an application secure; for a detailed set of requirements, teams use ASVS. OWASP revises the list every few years, so a newer edition may have been published after 2021. Check owasp.org for the current edition before quoting category numbers in a report or policy.

Key terms

  • Vulnerability: a weakness that an attacker can use to cause harm.
  • CWE: an identifier for a type of weakness, such as CWE-89 for SQL injection.
  • Attack surface: every input, endpoint and integration an attacker can reach.
  • Defence in depth: several independent controls, so one failure does not expose everything.

The ten categories at a glance (2021 edition)

IDCategoryTypical exampleCore defence
A01Broken Access ControlChanging ?id=101 to ?id=102 shows another customer's invoiceCheck ownership and role on the server for every request; deny by default
A02Cryptographic FailuresPasswords stored as plain MD5; login page served over HTTPTLS everywhere, strong password hashing, encrypt sensitive data at rest
A03InjectionSQL injection through a search box; cross-site scripting (XSS) is grouped here in 2021Parameterised queries, output encoding, input validation
A04Insecure DesignA password reset that relies on easily guessed security questionsThreat modelling and secure design patterns before coding
A05Security MisconfigurationDebug mode on in production, default admin accounts, verbose errorsHardened, repeatable configuration and regular review
A06Vulnerable and Outdated ComponentsAn old library version with a published CVEInventory dependencies, patch and remove unused ones
A07Identification and Authentication FailuresNo rate limit on login, so passwords can be brute-forcedMFA, rate limiting, secure session handling
A08Software and Data Integrity FailuresUnsigned updates or unsafe deserialisation of user dataVerify signatures and checksums; protect the CI/CD pipeline
A09Security Logging and Monitoring FailuresRepeated failed logins never logged or alertedLog security events centrally and alert on them
A10Server-Side Request Forgery (SSRF)A URL preview feature fetches an internal metadata addressAllow-list destinations; block internal ranges

A01 to A03: access control, cryptography and injection

Broken access control tops the 2021 list. It covers insecure direct object references (IDOR), missing function-level checks, such as an admin page that only hides its link, and permissive CORS settings. The fix is to enforce authorisation on the server for every request, not in the browser. The difference between proving identity and granting rights is explained in authentication and authorisation.

Cryptographic failures means sensitive data is exposed because encryption is missing, weak or misused. Serve every page over HTTPS, hash passwords with a slow algorithm such as bcrypt or Argon2 (in PHP, password_hash()), and never invent your own encryption. The encryption vs hashing guide shows which to use when.

Injection happens when untrusted input is mixed into a command or query. The defence is to keep code and data separate. In PHP, a PDO prepared statement sends the query and the value separately, so input can never change the SQL structure:

<?php
// Vulnerable: input is pasted into the SQL string
// $sql = "SELECT * FROM users WHERE email = '" . $_GET['email'] . "'";

// Safe: placeholder plus bound value
$pdo  = new PDO('mysql:host=localhost;dbname=shop;charset=utf8mb4', 'app', getenv('DB_PASS'), [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$stmt = $pdo->prepare('SELECT id, name FROM users WHERE email = ?');
$stmt->execute([$_GET['email'] ?? '']);
$user = $stmt->fetch(PDO::FETCH_ASSOC);

// Output encoding prevents XSS when the value is printed in HTML
echo htmlspecialchars($user['name'] ?? '', ENT_QUOTES, 'UTF-8');

A04 to A07: design, configuration, components and login

Insecure design was new in 2021. It covers flaws that perfect code cannot fix because the logic itself is unsafe, such as a booking system that lets one user reserve every seat without limits. Threat modelling during design, abuse-case testing and sensible business limits address it.

Security misconfiguration includes default passwords, directory listing, stack traces shown to users, unnecessary services and missing security headers. Build servers from a documented baseline and review them regularly, as described in security auditing.

Vulnerable and outdated components refers to libraries, frameworks and server software with known flaws. Keep an inventory (for PHP, composer.lock), run composer audit to check it against published advisories, and subscribe to security notices for the software you run.

Identification and authentication failures include weak password rules, credential stuffing with no rate limit, session IDs in URLs and sessions that never expire. Add multi-factor authentication, limit login attempts, regenerate the session ID after login and set cookies with Secure, HttpOnly and SameSite.

A08 to A10: integrity, logging and SSRF

Software and data integrity failures occur when code or data is trusted without verification: auto-updates without signatures, packages pulled from untrusted sources, or PHP unserialize() called on user input. Verify checksums and signatures, protect build pipelines and use JSON instead of native serialisation for untrusted data.

Security logging and monitoring failures mean attacks go unnoticed. Log logins, failed logins, access-control failures and high-value transactions with a timestamp, user and source address, send logs to a central store and alert on suspicious patterns. Without logs, incident response has nothing to work with.

Server-side request forgery happens when an application fetches a URL supplied by a user. An attacker points it at internal addresses, such as http://169.254.169.254/, the instance metadata service on major cloud platforms. Allow-list permitted hosts, resolve and check the destination address, block private and link-local ranges, and require session tokens for metadata access (IMDSv2 on AWS).

Practical exercise: test a deliberately vulnerable app

Use an intentionally vulnerable training application, such as OWASP Juice Shop or DVWA, running on your own machine. Never test a site you do not own or have written permission to test.

  1. Run the application locally, for example in Docker, bound to 127.0.0.1 only.
  2. Find one broken access control flaw by changing an ID in a URL or API request.
  3. Find one injection flaw (SQL injection or XSS) and write down the exact input that triggered it.
  4. For each flaw, name the Top 10 category and describe the code fix in one or two sentences.
  5. Review the response headers in browser developer tools and list any missing security headers.

You are done when you have a short table of at least three findings, each with its category, evidence and fix. Secure PHP coding is covered further in the PHP security guide and the Advanced PHP course.

Common mistakes

  • Treating the Top 10 as a complete checklist instead of an awareness starting point.
  • Hiding admin links in the interface while leaving the admin endpoints unprotected on the server.
  • Escaping SQL input by hand instead of using parameterised queries.
  • Quoting 2021 category numbers in a new policy without checking owasp.org for a newer edition.
  • Logging passwords, session tokens or full card numbers while trying to fix A09.

Frequently asked questions

How often does OWASP update the Top 10?

Editions have appeared every few years, including 2013, 2017 and 2021. OWASP announces new editions on owasp.org, so check there for the current list.

Where did cross-site scripting go in the 2021 list?

XSS was merged into A03 Injection in 2021, because it is also caused by untrusted data being interpreted as code, in this case by the browser.

Is there an OWASP Top 10 for APIs?

Yes. OWASP publishes a separate API Security Top 10, with risks such as broken object level authorisation. It complements the web list for anyone building REST APIs.

Do I need security tools to apply the Top 10?

No. Many categories, such as access control and insecure design, are found through code review and manual testing. Scanners help with misconfiguration and outdated components.

Want to Learn This Properly?

The Advanced PHP Web Development & Full-Stack Application Development (Online) turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

Protected by reCAPTCHA. Google Privacy and Terms apply.

We reply by email or phone within working hours. No spam.