awesome-everything RU
↑ Back to the climb

Security

OWASP Top 10: code and config reading

Crux Read real code, config, and log snippets — an access-control check, an SSRF fetch, a CORS config — name the OWASP category, and pick the fix a senior makes first.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Vulnerabilities live in code and config, not in the abstract. Read each snippet the way you would in a pull request, name the OWASP category, and choose the fix a senior reaches for first — the root cause, not the bolt-on.

Goal

Practise the review loop: read the handler or config, spot which Top 10 category it maps to, predict the exploit, and reach for the structural fix before any perimeter patch.

Snippet 1 — the ownership check

// GET /api/invoices/:id
app.get("/api/invoices/:id", requireLogin, async (req, res) => {
  const invoice = await db.invoice.findUnique({
    where: { id: Number(req.params.id) },
  });
  if (!invoice) return res.status(404).end();
  res.json(invoice);   // returns whatever row matched the id
});
Quiz

requireLogin runs, so the caller is authenticated. What is the vulnerability, and what is the minimal correct fix?

Snippet 2 — the URL fetcher

// POST /api/preview  { "url": "..." }
app.post("/api/preview", async (req, res) => {
  const r = await fetch(req.body.url);     // fetch whatever the client sent
  const html = await r.text();
  res.send(extractOpenGraph(html));        // server returns the fetched content
});
Quiz

What class of bug is this, what is the highest-impact exploit, and what is the right defense?

Snippet 3 — the CORS config

app.use(cors({
  origin: req.headers.origin,   // reflect whatever Origin the request sent
  credentials: true,            // allow cookies to be sent cross-origin
}));
Quiz

Reflecting the request Origin while allowing credentials — what does this actually permit, and how do you fix it?

Snippet 4 — the log line

2026-05-29T11:42:08Z WARN auth login failed user=alice@corp.com
  pw=hunter2 ip=203.0.113.9 ua="Mozilla/5.0" attempt=5 within=30s
Quiz

Two findings are visible in this single log line. Which pair is correct?

Recap

Every finding reads back to a category and a root-cause fix: an authenticated handler with no ownership check is IDOR/Broken Access Control (scope to owner_id); a server fetching a client-supplied URL is SSRF (allowlist plus private-range rejection plus IMDS lockdown); reflecting the request Origin with credentials is a CORS Security Misconfiguration (allowlist trusted origins); and a log line carrying a plaintext password with rapid repeated failures is a sensitive-data leak plus an auth/logging gap. Read code and config like a reviewer — name the cause, then fix the cause.

Continue the climb ↑OWASP Top 10: audit and harden a vulnerable service
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.