OWASP Top 10
A complete guide to the OWASP Top 10: the industry ranking of critical web application security risks and how to eliminate them.
If you wanted to protect a building against fires, you would start by learning the most common hazards identified by safety experts: unattended stoves, overloaded electrical outlets, and blocked exits. Addressing that checklist eliminates the majority of fire risks. The OWASP Top 10 serves that same purpose for web application security. Created by the Open Web Application Security Project (OWASP), a respected non-profit global security community, the OWASP Top 10 is an industry-standard guide that ranks the ten most critical security risks facing web applications today. It gives developers, engineers, and security teams a clear, shared list of what to look for and how to build safer software.
Definition
The OWASP Top 10 is a widely recognized awareness document that ranks the ten most critical security risks facing web applications and APIs, providing developers with clear guidance on common vulnerabilities and how to avoid them.
Why It Matters
Software security can seem overwhelming when approached without a clear plan. The OWASP Top 10 narrows down thousands of possible security flaws into the ten areas that cause the most real-world harm. Major security standards and compliance frameworks, including PCI-DSS for payment systems and SOC 2, require teams to protect their applications against the vulnerabilities listed in the OWASP Top 10. Learning these categories helps developers build secure habits from the start.
How It Works
The current OWASP Top 10 highlights the most common weaknesses found in modern web applications: 1. A01: Broken Access Control: Users can access features or data they should not have permission to see, such as regular users viewing administrative pages or modifying other accounts by changing an ID in the URL. Defense: Check permissions on the server for every single request and follow the Principle of Least Privilege. 2. A02: Cryptographic Failures: Failing to protect sensitive data properly, such as transmitting credit card details over unencrypted HTTP, storing passwords with outdated hashing algorithms (like MD5), or leaving cryptographic keys hardcoded in source code. Defense: Enforce HTTPS with TLS 1.3 everywhere, use strong encryption like AES-256-GCM, and use modern password hashing algorithms like Argon2id or bcrypt. 3. A03: Injection: User input is interpreted directly as database commands or system instructions. This category includes SQL Injection and Cross-Site Scripting (XSS). Defense: Use parameterized queries (prepared statements) and proper context-aware output encoding. 4. A04: Insecure Design: Security flaws that happen during the planning and architecture phase, before code is written, such as forgetting to design password recovery limits or account lockout rules. Defense: Perform threat modeling during design and build security requirements into feature specifications. 5. A05: Security Misconfiguration: Leaving default passwords unchanged, keeping unnecessary debug features enabled in production, or leaving cloud storage buckets accessible to the public internet. Defense: Use hardened baseline server configurations, disable unnecessary features, and automate deployments with Infrastructure as Code. 6. A06: Vulnerable and Outdated Components: Using third-party open-source libraries or software packages that contain known security bugs. Defense: Regularly scan software dependencies using automated tools like Dependabot, Snyk, or Trivy, and keep packages updated. 7. A07: Identification and Authentication Failures: Allowing weak or easily guessed passwords, failing to protect against automated login attempts, or missing multi-factor authentication. Defense: Require strong passwords, enforce multi-factor authentication (MFA), and rate-limit login attempts. 8. A08: Software and Data Integrity Failures: Relying on software updates, plugins, or libraries without verifying their integrity and authenticity, leaving systems vulnerable to supply chain attacks. Defense: Verify digital signatures and package checksums before running automated deployment pipelines. 9. A09: Security Logging and Monitoring Failures: Failing to record security events (like failed logins or unauthorized access attempts) or failing to alert administrators when suspicious spikes occur. Defense: Maintain centralized logging and configure alerts so teams can respond quickly when an attack begins. 10. A10: Server-Side Request Forgery (SSRF): A flaw where a web server is tricked into making a network request to an internal system or cloud service that should not be reachable from the internet. Defense: Validate and restrict user-supplied URLs to an allowlist of approved domains and block requests to internal private IP ranges.
The OWASP Top 10 Web Application Security Categories
Key Points
- Broken Access Control (A01) is currently the most frequent and critical web vulnerability category.
- The OWASP Top 10 provides a practical, consensus-driven foundation for application security.
- Major compliance standards (such as PCI-DSS and SOC 2) require protection against OWASP Top 10 risks.
- Security must be considered during initial system design (Insecure Design), not just added at the end.
- Automated security scans in continuous integration help prevent known flaws from entering production.
Steps
Run an OWASP Top 10 Assessment
Review your application architecture against the ten categories to identify which areas need immediate attention.
Integrate Automated Scanners in CI/CD
Add automated code scanners and dependency checkers to your deployment pipeline to catch common flaws before code reaches production.
Use Standard, Vetted Security Libraries
Rely on established, well-tested libraries for authentication, password hashing, and token handling instead of writing custom security code.
Conduct Regular Security Reviews
Perform peer code reviews and schedule periodic penetration tests to catch logic flaws and configuration oversights before releases.
Examples
The Vehicle Safety Rating Analogy
Before cars are sold to the public, safety boards test them against standard crash tests, checking brakes, airbags, seatbelts, and steering controls. The OWASP Top 10 is like that vehicle safety inspection checklist for web software: it ensures your application has the necessary protections in place before real users rely on it.
Real-World Examples
The Capital One Cloud Data Incident (2019)
An attacker exploited a Server-Side Request Forgery (SSRF, Category A10) flaw in a misconfigured web application firewall running on cloud infrastructure. This allowed the attacker to reach an internal cloud metadata address (169.254.169.254) and retrieve temporary access keys, which were then used to access customer records stored in cloud storage buckets.
Technical Examples
// ─── VULNERABLE CODE (SSRF Vulnerable) ─────────────────────────────
// Allows an attacker to submit: avatarUrl = "http://169.254.169.254/latest/meta-data/"
app.post("/api/fetch-avatar", async (req, res) => {
const userUrl = req.body.avatarUrl;
// DANGEROUS: Server fetches any URL provided by the user without validation!
const response = await fetch(userUrl);
const data = await response.buffer();
res.send(data);
});
// ─── SECURE CODE (SSRF Defense via Domain Allowlisting) ────────────
import { URL } from "url";
const ALLOWED_IMAGE_DOMAINS = ["images.unsplash.com", "cdn.mycompany.com"];
app.post("/api/fetch-avatar", async (req, res) => {
try {
const parsedUrl = new URL(req.body.avatarUrl);
// 1. Only allow secure HTTPS requests
if (parsedUrl.protocol !== "https:") {
return res.status(400).json({ error: "Only HTTPS protocol is permitted." });
}
// 2. Restrict to approved image domains (blocks internal IPs like 169.254.169.254)
if (!ALLOWED_IMAGE_DOMAINS.includes(parsedUrl.hostname)) {
return res.status(403).json({ error: "Domain not authorized for image download." });
}
const response = await fetch(parsedUrl.toString());
const data = await response.buffer();
res.send(data);
} catch (err) {
res.status(400).json({ error: "Invalid URL provided." });
}
});A01: Broken Access Control vs A03: Injection
| Aspect | A01: Broken Access Control | A03: Injection |
|---|---|---|
| Core Root Cause | Missing or incorrect authorization checks on endpoints or records | User input is executed directly as code or database commands |
| Attacker Goal | View other users' private records or perform administrative actions | Extract database tables, alter records, or execute server commands |
| Primary Solution | Enforce server-side role and record ownership verification | Use prepared statements, parameterized queries, and output encoding |
| OWASP Position | #1 most common web vulnerability | #3 most critical web vulnerability |
Cloud Metadata Protection: IMDSv2
Advantages
- Shared Industry Standard: Provides developers, auditors, and leadership with a common vocabulary and set of priorities.
- High Defensive Value: Addressing the Top 10 eliminates the vulnerabilities most commonly targeted by automated attack tools.
- Helps Meet Compliance Requirements: Demonstrating adherence to OWASP guidelines supports standards like PCI-DSS and SOC 2.
Limitations
- Not a Total Security Solution: The Top 10 focuses on common technical flaws, but applications also need protection against custom business logic errors.
- Periodic Updates: The rankings evolve over time as new threat patterns emerge, requiring teams to refresh their security practices regularly.
Interview Questions
What is Server-Side Request Forgery (SSRF) and how do you prevent it?
Server-Side Request Forgery (SSRF) happens when a web application takes a URL from a user and makes an HTTP request to that URL without proper validation. Attackers can use this to make the server query internal network services or cloud metadata endpoints (like 169.254.169.254) that are not exposed to the public internet. It is prevented by enforcing an allowlist of permitted destination domains, requiring HTTPS, and blocking requests to private and link-local IP addresses.
Practice Questions
- Review the 10 categories: Which two categories does your current project protect against best, and which two need more attention?
- Explain how automated dependency scanners like Dependabot address category A06 (Vulnerable and Outdated Components).
