Security testing toolkit for LLM-based systems
Project description
LLM Pentest
Security testing toolkit for LLM-based systems — chatbots, RAG pipelines, and AI agents.
Tests for prompt injection, data exfiltration, tool abuse, and jailbreaking.
Install
pip install -e .
Quick Start
# Interactive setup
llm-pentest init
# Or use a built-in profile
llm-pentest scan --profile openai
# Or provide a config file
cp examples/target.yaml my-target.yaml
llm-pentest scan -c my-target.yaml
Usage
# List payloads and chains
llm-pentest payloads
# Scan specific category
llm-pentest scan -c target.yaml --category prompt_injection
# Scan single payload
llm-pentest scan -c target.yaml --payload pi-001
# Parallel scanning (5 concurrent requests)
llm-pentest scan -c target.yaml -n 5
# Only fail CI on high/critical findings
llm-pentest scan -c target.yaml --fail-on high
# Use a profile instead of config file
llm-pentest scan --profile openai --model gpt-4o
# HTML report
llm-pentest scan -c target.yaml --format html -o report.html
# SARIF report (GitHub Code Scanning compatible)
llm-pentest scan -c target.yaml --format sarif -o report.sarif
# Baseline comparison
llm-pentest scan -c target.yaml -o baseline.json
# ... fix vulnerabilities ...
llm-pentest scan -c target.yaml -o current.json --baseline baseline.json
# Standalone diff
llm-pentest diff -b baseline.json --current current.json
# Custom detection hooks
llm-pentest scan -c target.yaml --hooks my_hooks.py
# LLM-as-judge for better detection accuracy
llm-pentest scan -c target.yaml --judge-endpoint https://api.openai.com/v1/chat/completions --judge-key $OPENAI_API_KEY
# Dry run (no requests sent)
llm-pentest scan -c target.yaml --dry-run
Target Profiles
Built-in profiles for common providers (llm-pentest profiles):
| Profile | Endpoint | Default Model |
|---|---|---|
openai |
api.openai.com | gpt-4o-mini |
anthropic |
api.anthropic.com | claude-sonnet-4-20250514 |
ollama |
localhost:11434 | llama3 |
Attack Categories
| Category | Payloads | OWASP | Description |
|---|---|---|---|
prompt_injection |
pi-001 to pi-009 | LLM01 | System prompt extraction, instruction override, encoding bypass, indirect injection |
data_exfiltration |
de-001 to de-005 | LLM06 | RAG context leak, credential extraction, PII harvesting |
tool_abuse |
ta-001 to ta-004 | LLM07, LLM08 | Unauthorized tool use, parameter injection, CoT hijacking, DoS |
jailbreak |
jb-001 to jb-004 | LLM01 | Role-play, hypothetical framing, token smuggling, persona splitting |
Attack Chains
Chains compose multiple payloads into multi-step attack sequences:
- id: chain-001
name: "Jailbreak then Extract Credentials"
steps:
- payload_id: jb-001
prompt_index: 0
- payload_id: de-002
prompt_index: 0
Custom Payloads
Drop YAML files into payloads/ or pass --payloads-dir:
- id: custom-001
name: "My Custom Attack"
category: prompt_injection
severity: high
owasp: ["LLM01"]
prompts:
- "Your attack prompt here"
detection:
- pattern: "expected response pattern"
confidence: 0.8
Custom Detection Hooks
Write Python functions for domain-specific detection:
# my_hooks.py — any function named detect_* is auto-registered
def detect_internal_data(payload, prompt, response):
if "internal-project-name" in response.lower():
return "Leaked internal project name"
return None
llm-pentest scan -c target.yaml --hooks my_hooks.py
CI/CD Integration
# Fail only on high/critical findings
llm-pentest scan -c target.yaml --fail-on high || echo "Vulnerabilities found!"
# SARIF for GitHub Code Scanning
llm-pentest scan -c target.yaml --format sarif -o results.sarif
# Baseline regression check
llm-pentest scan -c target.yaml --baseline previous.json --fail-on high
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_pentest-0.1.0.tar.gz.
File metadata
- Download URL: llm_pentest-0.1.0.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b0798c732600509046ba7b89ce2c0c7e1535af6c8f613b348353acbc4909887
|
|
| MD5 |
d1f8ccbde3e03ad0b3d757f037b8820b
|
|
| BLAKE2b-256 |
1055cb0dfbfef945959013588f34883fedb0b8f562b786a2ef5f1bb520b3c8ee
|
Provenance
The following attestation bundles were made for llm_pentest-0.1.0.tar.gz:
Publisher:
publish.yml on jcazako/llm-pentest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_pentest-0.1.0.tar.gz -
Subject digest:
6b0798c732600509046ba7b89ce2c0c7e1535af6c8f613b348353acbc4909887 - Sigstore transparency entry: 1004873149
- Sigstore integration time:
-
Permalink:
jcazako/llm-pentest@c1d6f8f46fd268d2fcb621c9a706a55cb2437905 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jcazako
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1d6f8f46fd268d2fcb621c9a706a55cb2437905 -
Trigger Event:
release
-
Statement type:
File details
Details for the file llm_pentest-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llm_pentest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afdbbe532641cbed33898087468e091b4d8e4b3f64f90449c72a33353308f072
|
|
| MD5 |
fdbfab577d378de4034e25337e5e5fdb
|
|
| BLAKE2b-256 |
beefd938d8be970a873cebe3e484ccd742f0df04986fb05007b84999bcb8e017
|
Provenance
The following attestation bundles were made for llm_pentest-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on jcazako/llm-pentest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_pentest-0.1.0-py3-none-any.whl -
Subject digest:
afdbbe532641cbed33898087468e091b4d8e4b3f64f90449c72a33353308f072 - Sigstore transparency entry: 1004873150
- Sigstore integration time:
-
Permalink:
jcazako/llm-pentest@c1d6f8f46fd268d2fcb621c9a706a55cb2437905 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jcazako
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c1d6f8f46fd268d2fcb621c9a706a55cb2437905 -
Trigger Event:
release
-
Statement type: