Audit Bench
Challenge on lesson: Checkpoint: Security Audit
Write THREE functions. 1) classify(snippet) — given a one-line code description, name the vulnerability class: contains "innerHTML" or "document.write" => "xss"; contains string concatenation into "SELECT" or "query(" => "sql-injection"; contains "exec(" or "exec("" => "command-injection"; contains "/api/" + an id read without an ownership check description => "idor"; otherwise "none". 2) defenseFor(threat) — map: "xss" => "output-encoding", "sql-injection" => "parameterized-queries", "command-injection" => "execfile-allowlist", "idor" => "ownership-check", "csrf" => "samesite-token", unknown => "defense-in-depth". 3) corsVerdict(allowOrigin, credentials)` — return "invalid" when allowOrigin is "*" AND credentials is true; "ok" when allowOrigin is a concrete origin; otherwise "risky".
Difficulty: intermediate
Back to lesson: Checkpoint: Security Audit