Lesson 04 AI-Assisted Code Auditing
Theme:

Answers

Reference answers for Lesson 04.

Part 1 — Lab Answers

Exercise 1 — Python Web App Audit

Expected classes of findings

Exercise 2 — Node.js API Audit

Expected findings

Exercise 3 — Legacy C Auth Audit

Expected findings

At least one finding should be exploitability-rated "likely RCE" given sufficient size controls.

Exercise 4 — Config Leak Audit

Expected findings

Final Exercise — Audit Report

Expected cross-file chain

A secret found in config-leak.yaml is used as a signing key or DB password in vulnerable-webapp.py, which itself has an SQL injection that could exfiltrate more data. A great audit connects at least two files.


Part 2 — Homework Answers

Task 1 — False-Positive Calibration

Expected precision

For typical lab content AI precision lands around 70-85%. The most common FP pattern is flagging any use of a sensitive function (like eval()) as a bug, even when the input is a trusted constant. Misses usually involve business-logic flaws with no syntactic fingerprint.

Task 2 — Patch & Verify

Expected patch quality

Root-cause fixes replace the dangerous primitive (parameterized queries instead of string concat, shlex.quote instead of raw input). Symptom fixes (regex blacklist, escaping on output) are a sign the audit was not internalized.

Task 3 — Semgrep Rule Authoring

Expected rule shape

A YAML file with pattern-either or pattern clauses matching the dangerous call site, plus a metavariable-pattern filter to cut false positives when the argument is a string literal.