OWASP Top 10 Explained with Practical Examples

Security2026-11-16TryQuickToolBox

You've probably heard of the OWASP Top 10—the list of the most critical web application security risks. But knowing the names isn't enough. To truly protect your applications, you need to see how these vulnerabilities manifest in real code and understand the concrete steps to fix them.

In this article, we'll walk through each OWASP Top 10 category with practical examples. You'll see vulnerable code snippets, learn why they're dangerous, and get actionable mitigation strategies. Whether you're a developer, tester, or security engineer, this guide will help you write safer code and spot weaknesses before attackers do.

1. Broken Access Control

Broken access control occurs when users can act outside their intended permissions—accessing other users' data, performing admin actions, or viewing sensitive files. It's the #1 risk because it's common and impactful.

Example: Insecure Direct Object Reference (IDOR)

// Vulnerable: User can change the ID and view any invoice
app.get('/invoice/:id', (req, res) => {
  const invoice = db.getInvoice(req.params.id);
  res.json(invoice);
});

An attacker simply changes the id parameter to access other users' invoices.

Mitigation

2. Cryptographic Failures

Previously called "Sensitive Data Exposure," this category covers failures related to protecting data in transit and at rest. Common issues include using weak algorithms, hardcoding secrets, or transmitting data over HTTP.

Example: Storing Passwords in Plaintext

# Vulnerable: Plaintext password storage
user.password = request.form['password']
db.save(user)

If the database is breached, all passwords are exposed.

Mitigation

3. Injection

Injection flaws occur when untrusted data is sent to an interpreter as part of a command or query. SQL injection, NoSQL injection, OS command injection, and ORM injection are all too common.

Example: SQL Injection

// Vulnerable: String concatenation
const query = "SELECT * FROM users WHERE username = '" + username + "'";
db.query(query);

An attacker can input ' OR '1'='1 to bypass authentication.

Mitigation

4. Insecure Design

Insecure design refers to missing or ineffective security controls in the design phase. It's not about implementation bugs but architectural flaws.

Example: No Rate Limiting on Login

Without rate limiting, attackers can brute-force passwords or perform credential stuffing.

Mitigation

5. Security Misconfiguration

This is the most common issue—default accounts, unnecessary features enabled, verbose error messages, missing security headers, etc.

Example: Exposing Stack Traces

app.use((err, req, res, next) => {
  res.status(500).send(err.stack); // Leaks sensitive info
});

Mitigation

6. Vulnerable and Outdated Components

Using libraries, frameworks, or software with known vulnerabilities is a major risk. Attackers exploit unpatched systems.

Example: Using an Old Version of Lodash

Older versions of Lodash had prototype pollution vulnerabilities.

Mitigation

7. Identification and Authentication Failures

Weak authentication mechanisms allow attackers to compromise passwords, keys, or session tokens.

Example: Predictable Session IDs

// Vulnerable: Session ID based on timestamp
const sessionId = Date.now().toString();

Attackers can guess or brute-force session IDs.

Mitigation

8. Software and Data Integrity Failures

This category focuses on code and infrastructure that doesn't protect against integrity violations—like using untrusted CDNs, insecure deserialization, or CI/CD pipelines without integrity checks.

Example: Insecure Deserialization

// Vulnerable: Deserializing untrusted data
$data = unserialize($_COOKIE['data']);

Attackers can inject malicious objects leading to remote code execution.

Mitigation

9. Security Logging and Monitoring Failures

Without adequate logging and monitoring, breaches go undetected. This includes missing logs, unclear logs, or not monitoring them.

Example: No Logging of Failed Logins

Brute-force attacks go unnoticed.

Mitigation

10. Server-Side Request Forgery (SSRF)

SSRF occurs when an attacker can make the server perform requests to internal resources. This can lead to data leakage or internal network scanning.

Example: Fetching a URL from User Input

// Vulnerable: Fetches any URL
app.get('/fetch', (req, res) => {
  fetch(req.query.url).then(data => res.send(data));
});

An attacker can request internal metadata endpoints (e.g., http://169.254.169.254/).

Mitigation

Comparison Table: OWASP Top 10 at a Glance

Risk Common Example Quick Mitigation
Broken Access Control IDOR Server-side access checks
Cryptographic Failures Plaintext passwords Use bcrypt/Argon2
Injection SQL injection Parameterized queries
Insecure Design No rate limiting Threat modeling
Security Misconfiguration Stack traces Harden configs
Vulnerable Components Old Lodash Regular updates
Auth Failures Weak session IDs MFA, strong IDs
Integrity Failures Insecure deserialization Use JSON, verify signatures
Logging Failures No failed login logs Centralized logging
SSRF Fetching internal URLs URL allowlists

FAQ

What is the OWASP Top 10?

The OWASP Top 10 is a regularly updated list of the most critical web application security risks, published by the Open Web Application Security Project (OWASP). It serves as a baseline for developers and security professionals to prioritize security efforts.

How often is the OWASP Top 10 updated?

OWASP updates the list every few years based on data from security firms and community feedback. The most recent version is from 2021, with a new release expected in the coming years.

Can I use the OWASP Top 10 as a checklist?

While it's a great starting point, the OWASP Top 10 is not exhaustive. It's meant to raise awareness and guide prioritization. For a comprehensive security program, combine it with other OWASP resources like the Application Security Verification Standard (ASVS) and proactive controls.

Want to quickly analyze your Nginx logs for signs of attacks like SQL injection or brute force? Try our Nginx Log Analyzer to visualize and detect suspicious patterns.