PS Product SecurityKnowledge Base

๐Ÿงฉ Secure Coding Review Lab Scenarios by Language

Use this page when: you want ready-to-run exercises that convert the KBโ€™s vulnerable/safer snippets into practice.

How to use these scenarios

For each lab:

  1. show only the vulnerable snippet first;
  2. ask participants to identify the defect class;
  3. ask for likely business impact;
  4. ask for the minimum safe fix direction;
  5. compare with the linked example page.

PHP scenarios

PHP Lab 1 โ€” concatenated login query

  • defect family: injection;
  • prompt: which user-controlled value changes the meaning of the query?
  • follow-up: what would you require in PR review before merge?
  • compare with: PHP Vulnerability Examples and Fixes

PHP Lab 2 โ€” unsafe upload to public path

  • defect family: unsafe file handling;
  • prompt: what attacker goals become possible if the upload lands under a served path?
  • follow-up: what retrieval architecture would you prefer instead?
  • compare with: PHP Vulnerability Examples and Fixes

Python scenarios

Python Lab 1 โ€” shell command built from request data

  • defect family: command execution;
  • prompt: could a safer design avoid the shell entirely?
  • follow-up: where should validation happen if this becomes a worker job later?
  • compare with: Python Vulnerability Examples and Fixes

Python Lab 2 โ€” IDOR in record lookup

  • defect family: broken object-level authorization;
  • prompt: what ownership proof is missing?
  • follow-up: should this be enforced in the query, service layer, or both?
  • compare with: Python Vulnerability Examples and Fixes

Go scenarios

Go Lab 1 โ€” direct row fetch by object id

Go Lab 2 โ€” outbound fetch from untrusted URL

Java scenarios

Java Lab 1 โ€” unsafe XML / parser configuration

Java Lab 2 โ€” unsafe object deserialization or trust in serialized input

JavaScript scenarios

JavaScript Lab 1 โ€” reflected XSS in templated output

JavaScript Lab 2 โ€” dangerous redirect or URL fetch

TypeScript scenarios

TypeScript Lab 1 โ€” runtime trust hidden behind types

TypeScript Lab 2 โ€” typed ORM query with missing tenant scope

SQL scenarios

SQL Lab 1 โ€” dynamic ORDER BY / filter abuse

  • defect family: query manipulation;
  • prompt: which parts of the statement can safely be dynamic and how should they be constrained?
  • compare with: SQL Vulnerability Examples and Fixes

SQL Lab 2 โ€” missing tenant predicate in reporting query

Facilitator close-out template

End each lab with three outputs:

  • one review comment the team would actually write;
  • one safer coding rule for that stack;
  • one prevention mechanism (test, lint rule, framework helper, or gate).

Use with


Author attribution: Ivan Piskunov, 2026 - Educational and defensive-engineering use.