Gold upgrade planned

Available to study now. Gold Edition improvements will be added one chapter at a time.

Chapter 9 of 10
Course Progress0 of 10 completed (0%)

Cybersecurity Essentials for Developers · Chapter 9 of 10 · ~15 min

Project: Isolated Vulnerability Lab

Exploit and patch three classic flaws in an isolated local toy app: Broken Object-Level Authorization (IDOR), SQL Injection, and Stored XSS.

  • Test authorization boundaries against IDOR enumeration
  • Eliminate SQL injection using bound query parameters
  • Neutralize Stored XSS with escaping and strict CSP
  • Verify fixes against adversarial payloads

Project: Isolated Vulnerability Lab: learn it visually

Build and patch an isolated local toy app in-browser: fix broken object-level authorization (IDOR), parameterized SQL queries, and output escaping.

Project: Isolated Vulnerability LabBuild and patch an isolated local toy app in-browser: fix broken object-level authorization (IDOR), parameterized SQL queries, and output escaping.UNDERSTANDProjectFOLLOW THE FLOWIsolatedVulnerability LabAPPLY ITpatch isolated localProject: Isolated Vulnerability LabBuild and patch an isolated local toy app in-browser: fix broken object-level authorization (IDOR), parameterized SQL queries, and output escaping.UNDERSTANDProjectFOLLOW THE FLOWIsolatedVulnerability LabAPPLY ITpatch isolated local

1Defense-in-Depth Across Auth, SQL & DOM

Most real-world breaches chain simple mistakes: missing ownership checks, concatenated SQL, and unescaped HTML.

Wrong idea: Trust the ?invoiceId=1024 parameter because the user is logged in

SELECT * FROM invoices WHERE id = ?
User 7 reads User 1's invoice!

Authentication only proves who you are—not which invoice you are allowed to read.

Real system: Scope every query to the authenticated session user

WHERE id = ? AND owner_id = session.userId
404/403 enforced at data layer

Include AND owner_id = session.userId in every read/write query so attackers cannot enumerate IDs.

2Live Project Lab: Exploit & Patch Toy App

Test each attack in Vulnerable Mode, then click Apply Security Patch and re-run the payload.

Live Project · Isolated Toy App Security Lab
Attack payload: GET /api/invoices/101 (logged in as user #2)
Vulnerable Mode

Predict first

A route checks `if (!req.session.userId) return 401;` before running `SELECT * FROM invoices WHERE id = ?`. Is it safe from IDOR?

if (!req.session.userId) return 401;
return db.query("SELECT * FROM invoices WHERE id = ?", [req.params.id]);

3Bug Hunt · Patch getInvoice()

Patch getInvoice so it uses parameterized placeholders and enforces owner_id = sessionUserId.

Bug Hunt · invoiceRepo.ts
TypeScript

🎯 Find and fix the bugs in the code above, then press Run & verify to test your solution.

Need a hint?

Return db.query("SELECT * FROM invoices WHERE id = ? AND owner_id = ?", [invoiceId, sessionUserId]).

4Knowledge Check

Concept Check 1 of 2
1

Which change prevents Broken Object-Level Authorization (IDOR) on a private invoice endpoint?

Concept Check 2 of 2
2

Why do parameterized SQL queries defeat SQL injection?

5Recap

  • IDOR: Always bind queries to session.userId on the server.
  • SQLi: Use parameterized placeholders; never interpolate user strings into SQL.
  • XSS: Escape untrusted text by default and enforce a strict Content Security Policy.

Completed the vulnerability lab and bug hunt?

Enjoying this free lesson? Your support helps us build more free animated chapters.

Support Us