5.3 KiB
Prompt Scan — LLM Vulnerability Testing Platform
Overview
Build a deliberately vulnerable AI/LLM chatbot application that exposes all ten OWASP Top 10 for Large Language Model Applications vulnerabilities as live, exploitable HTTP endpoints. The platform provides a controlled target environment for security professionals, penetration testers, and students to practice LLM-specific attack techniques — prompt injection, insecure output handling, model DoS, plugin exploitation, and more — without risk to production systems.
Step-by-Step Instructions
-
Understand the OWASP Top 10 for LLM Applications by studying each risk category: LLM01 (Prompt Injection) attacks manipulate model behaviour through crafted input; LLM02 (Insecure Output Handling) occurs when raw LLM output is rendered or executed without sanitisation; LLM03 (Training Data Poisoning) injects malicious content into the model's context; LLM04 (Model Denial of Service) exhausts API quotas; LLM05 (Supply Chain) arises from untrusted plugins; LLM06 (Sensitive Information Disclosure) leaks credentials and API keys; LLM07 (Insecure Plugin Design) enables arbitrary code execution; LLM08 (Excessive Agency) grants unrestricted system permissions; LLM09 (Overreliance) accepts unvalidated output as ground truth; LLM10 (Model Theft) exposes model architecture and prompts.
-
Design the architecture with a Flask backend that intentionally disables every security control. Create a
Configclass that stores and exposes the OpenAI API key, admin credentials, and system prompt through a public endpoint, implementing LLM06 at the infrastructure level. -
Implement the vulnerable OpenAI client wrapping the SDK with deliberate flaws: pass user input directly without sanitisation (LLM01), return full metadata including system prompt (LLM06/LLM10), expose
generate_long_responsewithmax_tokens=4000and no rate limiting (LLM04), and trackrequest_countfor usage pattern disclosure (LLM10). -
Build the injectable SQLite database helper with three SQL injection classes: string-interpolated
search_usersenabling' OR 1=1--attacks,update_useraccepting arbitrary field/value parameters, andexecute_raw_sqlrunning any SQL statement. Seed with fake users and a secrets table containing plaintext credentials. -
Create the dangerous plugin system with
command_executor.pyusingsubprocess.run(shell=True)with no whitelist (LLM07/LLM08), andfile_reader.pyreading any path without validation. Add aload_external_pluginendpoint accepting aplugin_urlto demonstrate LLM05. -
Implement Flask route handlers mapping each OWASP category to exploitable endpoints:
/api/chat(LLM01/02/04/06),/api/config(LLM06 full dump),/api/prompt-injection(LLM01),/api/dos/long-response(LLM04),/api/plugin/execute(LLM07/08),/api/admin/delete-user/<id>unauthenticated (LLM08),/api/system/infodumpingos.environ(LLM06). -
Build the web interface as a single HTML page using Bootstrap. Render LLM responses with
innerHTMLso XSS payloads execute in the browser (LLM02). Add a vulnerability panel with all exploitable endpoints and a config viewer calling/api/config. -
Document every vulnerability in the
learn/directory:owasp-llm-overview.mdexplaining each risk,attack-walkthrough.mdwith curl commands, andmitigations.mdwith concrete fixes. -
Containerise with Docker using
uvfor dependency management, binding only to127.0.0.1:5000, withHEALTHCHECKon/healthanddata/mounted as a volume. -
Validate by running every payload in
tests/attack_payloads.json, confirming all ten OWASP LLM categories are reproducible, and verifying Docker isolation.
Key Concepts to Learn
- OWASP Top 10 for Large Language Model Applications
- Prompt injection — direct, indirect, and role manipulation
- LLM output handling and XSS/SQLi/RCE attack vectors
- Rate limiting, token budgets, and denial-of-service mitigation
- Plugin architecture security and principle of least privilege
- Secrets management and environment variable hygiene
- Supply chain risks in AI/ML applications
- Model metadata disclosure and model theft vectors
Deliverables
- Flask backend with all ten OWASP LLM vulnerabilities as live endpoints
- Vulnerable OpenAI client, SQLite helper, and plugin system
- Docker Compose environment with
uvand volume isolation learn/directory with OWASP overview, attack walkthrough, and mitigationstests/attack_payloads.jsonwith documented payloads for all ten categories- Complete README with architecture diagram, API reference, and safety warnings