LLMScan - AI Security Scanner

English | 日本語 (Japanese)
Local Static Application Security Testing (SAST) for AI & Web Applications
LLMScan analyzes Python, TypeScript, JavaScript, and PHP source code in real time as you edit. It traces data flow from untrusted sources to dangerous sinks, detecting both traditional web vulnerabilities (OWASP Top 10) and LLM-specific security threats (OWASP LLM Top 10 - LLM05: Insecure Output Handling).
All scans run 100% locally inside your editor using Tree-sitter WebAssembly. Zero code is sent to external servers, making it fully safe for proprietary codebases and untrusted workspaces.
Optional AI triage — v2.1.0
Static analysis remains local and works without an API key. Optional AI triage is disabled until configured, requires a trusted workspace, and never runs automatically. The CLI uses AI only with --triage (v2.1.0; see the repository README).
- Run LLMScan: Configure AI Triage (API Key / Provider). Select OpenAI, Anthropic or Ollama, enter a model ID supported by your account/server, and confirm the complete API endpoint URL. Cloud endpoints require HTTPS; local Ollama can use
http://127.0.0.1:11434/api/chat. OpenAI uses the Chat Completions JSON API; Anthropic uses Messages; Ollama uses native Chat. Model access and API charges depend on your provider.
- API keys are kept in VS Code SecretStorage. Provider, model and endpoint are stored in extension global state, independent of repository settings. To remove them, rerun configuration and choose Delete configuration and keys.
- Right-click a sidebar finding and choose Triage Finding with AI / Preview Patch. Inspect the preview and confirm sending to the displayed endpoint. The payload contains the finding, trace messages and a short snippet bounded to its enclosing function (up to eight surrounding lines on each side); top-level findings send target lines only. File path metadata is omitted. Known keys, credential assignments, bearer tokens and private-key blocks are masked on a best-effort basis; inspect for remaining sensitive content. Editing the preview does not alter the payload: cancel and edit the source instead.
- Read the advisory verdict (
true_positive, false_positive, needs_review) and reasoning. Review the proposed change in VS Code's Diff editor, then explicitly choose Apply proposed patch. Nothing is saved or executed automatically. Changed source documents are rejected; rerun triage. Patches involving masked target secrets are withheld to avoid overwriting real credentials with placeholders.
AI output can be incorrect or manipulated by source comments. Findings and baselines are never automatically suppressed or changed by the verdict. Re-test and review every patch. Requests time out after 30 seconds. Authentication, rate-limit and provider failures leave your source untouched; check the configured URL, model and key before retrying. For local operation use a locally hosted Ollama model and loopback endpoint; remote endpoints follow their provider's data policies.
🌟 Key Features
- Injection Vulnerability Detection (OWASP A05):
SQL Injection (Raw ORM & parameterized queries), Command Injection (
exec, spawn, shell=True), Code Injection (eval, new Function), Insecure Deserialization (pickle, unserialize, yaml.unsafe_load), Cross-Site Scripting (XSS), Server-Side Template Injection (SSTI), and Path Traversal / File Inclusion.
- OWASP LLM05 (Insecure Output Handling) & Agentic Security:
Tracks responses from OpenAI, Anthropic, Gemini, Ollama, LangChain, LlamaIndex, and Vercel AI SDK, as well as AI Agent tool calls (
tool_call.function.arguments, tool_input) and Model Context Protocol (MCP) tool handlers (request.params.arguments) directly to dangerous sinks (innerHTML, sqlite3.execute, subprocess.run, eval).
- Cross-File Taint Analysis (
ProjectIndex):
Automatically indexes function summaries across files in your workspace to track LLM outputs, user inputs, custom sanitizers, and sink wrappers across module boundaries.
- Interactive Tree View, Dataflow Graph & Activity Bar:
Dedicated Activity Bar icon (
llm.svg), sidebar view with severity badges, and an interactive Dataflow Taint Path Webview ($(type-hierarchy-sub)) where clicking any node jumps directly to the source line.
- Intelligent Taint Tracking & Sanitizers:
Built-in understanding of safe sanitizers: Zod schema validation, Yup, Pydantic, cryptographic hash digests (
hashlib, crypto.createHash, bin2hex), and type coercion (+x, Number(), int(), filter_var).
- Actionable Hovers & 1-Click Safe Refactoring QuickFixes:
Hover over any wavy line to see the vulnerability explanation, language-specific remediation examples, complete taint propagation trace, and OWASP/CWE references. Automatically refactor common vulnerabilities (
shell=True -> shell=False, eval() -> ast.literal_eval() / JSON.parse(), yaml.load() -> yaml.safe_load(), .innerHTML -> .textContent) or insert reason-enforced suppression comments with one click (QuickFix).
- Custom Rules & Baseline Support:
Define custom
sources, sinks, and sanitizers in .llmscan.yml, and create .llmscan-baseline.json to suppress legacy technical debt and only alert on newly introduced vulnerabilities.
📖 Usage
| Feature |
Action |
| Real-time Diagnostics |
Automatically scans active files and highlights vulnerabilities in the Problems panel and editor squiggly lines. |
| Interactive Dataflow Graph |
Click the $(type-hierarchy-sub) icon on any finding in the sidebar to open the visual taint path flowchart and click nodes to jump to code lines. |
| Dataflow Trace |
Under "Related Information", view the complete path: Source -> Assignment -> Sink. |
| Detailed Explanation |
Hover over findings to view why it is dangerous, safe remediation code, and CWE links. |
| One-Click Safe Auto-Fix |
Click the QuickFix lightbulb to safely refactor dangerous calls or insert # llmscan-ignore[RULE]: TODO Reason. |
| Copy for AI Fix |
Click the $(copy) button in the sidebar title to copy all findings formatted as an AI remediation prompt (Markdown) directly to clipboard. |
| Open Report in Tab |
Click the $(output) button in the sidebar title to open the findings report in a new Markdown editor tab. |
| Clear Scan Results |
Click the $(clear-all) button to clear whole-workspace scan results and reset the view back to only open files. |
| Workspace Scan |
Click the Scan Workspace button or $(refresh) icon, or run LLMScan: Scan entire workspace from the Command Palette. |
| Baseline / Reset |
Run Create baseline to ignore existing alerts, or Clear baseline to restore and view all findings again. |
⚙️ Configuration
You can configure options in .llmscan.yml at the repository root (shared with the CI CLI) or via VS Code Settings:
# .llmscan.yml
minConfidence: medium # low | medium | high
failOn: high # Failure threshold for CI CLI
baseline: .llmscan-baseline.json
exclude:
- "**/tests/**"
- "**/generated/**"
sanitizers: # Custom sanitization functions defined in your project
javascript: ["mySanitizer"]
python: ["app.security.sanitize_query"]
php: ["clean_input"]
sources: # Custom untrusted input or LLM response sources
python:
- pattern: "my_llm.ask"
kind: llm # user | llm
label: "Custom LLM response"
sinks: # Custom dangerous sink functions
python:
- pattern: "legacy_db.run_raw"
ruleId: "PY-SQLI-001"
category: sqli
severity: high
VS Code Settings (settings.json)
llmscan.enable: Enable or disable LLMScan security analysis. (Default: true)
llmscan.minConfidence: Filter findings by minimum confidence level (low, medium, high).
llmscan.showBaselined: Whether to display existing findings recorded in the baseline file. (Default: false)
🛡️ Supported Rules
| Rule ID |
Category |
Severity |
{PY,JS,PHP}-SQLI-001 |
SQL Injection |
High |
{PY,JS,PHP}-CMDI-001 |
OS Command Injection |
Critical |
{PY,JS,PHP}-CODEI-001 |
Code Injection (eval / new Function) |
Critical |
{PY,JS,PHP}-DESER-001 |
Insecure Deserialization (pickle, unserialize) |
High |
{PY,JS}-SSTI-001 |
Server-Side Template Injection |
High |
{PY,JS,PHP}-XSS-001 |
Cross-Site Scripting (innerHTML, echo) |
Medium |
PHP-FILEINC-001 |
File Inclusion (include, require) |
High |
{PY,JS,PHP}-SSRF-001 |
Server-Side Request Forgery (fetch, requests.get) |
High |
{PY,JS,PHP}-PATH-001 |
Path Traversal (fs.readFile, open) |
High |
LLM01-PROMPTI-001 |
OWASP LLM01 System Prompt Injection |
High |
LLM02-SECRET-001 |
OWASP LLM02 Hardcoded API Key / Secret |
High |
LLM05-*-001 |
OWASP LLM05 Insecure LLM Output Handling |
Critical / High |
LLMSCAN-SUPPRESS-001 |
Suppression comment without reason |
Low |
🔒 Privacy & Local Processing
LLMScan is built on local Tree-sitter WebAssembly grammar parsers. No source code, file paths, or telemetry are ever transmitted across the network. It functions completely offline and in air-gapped environments.
📄 License
Apache License 2.0
| |