Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Defence-in-depth patterns preventing injection attacks across the full stack. Complements data-validation (which checks shape/type) by ensuring data is safe for its destination context (HTML, SQL, shell, URL).
Description
Covers XSS, SQL injection, command injection, URL redirect, and SSRF prevention patterns for the Next.js frontend and FastAPI backend. Enforces output encoding, parameterised queries, and safe subprocess handling aligned with OWASP Top 10 guidelines.
When to Apply
Positive Triggers
Rendering user-generated content in HTML
Constructing database queries with user input
Building shell commands or subprocess calls
Handling URL parameters or redirect targets
Reviewing code for OWASP Top 10 vulnerabilities
User mentions: "XSS", "injection", "sanitise", "security", "escape", "OWASP"
Negative Triggers
Validating data shape or type (use data-validation instead)
Configuring authentication or RBAC (use auth patterns directly)
Setting up CORS or rate limiting (already handled in middleware)
Core Principle
Validation checks what data IS. Sanitisation ensures data is SAFE for its destination.
โโโโโโโโโโโโโโโ
User Input โโโบ Validate โโโบ Sanitise โโโบ Use in Context
(shape) (safety) (HTML/SQL/shell/URL)
Attack Vector 1: Cross-Site Scripting (XSS)
The Threat
Untrusted data rendered as HTML can execute arbitrary JavaScript in the user's browser.
React's Built-In Protection
React escapes all JSX expressions by default. This is safe:
Untrusted data in shell commands can execute arbitrary system commands.
Safe Subprocess Calls
import subprocess
import shlex
# SAFE: List form (no shell interpretation)
subprocess.run(
["git", "log", "--oneline", "-n", str(count)],
capture_output=True, text=True
)
# SAFE: shlex.quote for unavoidable string commands
filename = shlex.quote(user_filename)
subprocess.run(f"wc -l {filename}", shell=True)
Dangerous Patterns (NEVER USE)
# DANGEROUS: Unquoted user input in shell
subprocess.run(f"cat {user_input}", shell=True)
# DANGEROUS: os.system with user inputimport os
os.system(f"rm {filename}")
Detection Rule
rg "os\.system\(|shell=True" apps/backend/src/
Attack Vector 4: URL/Redirect Injection
The Threat
Open redirects allow attackers to redirect users to malicious sites after login.
Command injection prevention verified (no shell=True with user input)
OWASP Top 10 input handling coverage reviewed
Redirect URLs validated against an allow-list
CSP headers configured in next.config.ts
Response Format
[AGENT_ACTIVATED]: Input Sanitisation
[PHASE]: {Audit | Implementation | Review}
[STATUS]: {in_progress | complete}
{security analysis or implementation guidance}
[NEXT_ACTION]: {what to do next}
Integration Points
Data Validation
data-validation runs first (checks shape), then input-sanitisation ensures safety:
Input โ data-validation (is it valid?) โ input-sanitisation (is it safe?) โ Use
Error Taxonomy
Sanitisation failures should use AUTH_PERMISSION_* or DATA_VALIDATION_* error codes. Never reveal internal details in error messages to untrusted clients.
Council of Logic (Turing Check)
Sanitisation functions must be O(n) โ no recursive regex or backtracking patterns that could cause ReDoS (Regular Expression Denial of Service).
Australian Localisation (en-AU)
Spelling: sanitisation, authorisation, defence, analyse, centre, colour
Compliance: Privacy Act 1988, Australian Cyber Security Centre (ACSC) guidelines
Tone: Direct, security-conscious โ state risks clearly