Skip to main content

Security testing toolkit for LLM-based systems

Project description

LLM Pentest

CI Python License: MIT OWASP

Security testing toolkit for LLM-based systems — chatbots, RAG pipelines, and AI agents.

Tests for prompt injection, data exfiltration, tool abuse, and jailbreaking.

Install

# One-liner (macOS/Linux — auto-detects OS and arch)
curl -fsSL https://raw.githubusercontent.com/jcazako/llm-pentest/main/install.sh | bash

# Homebrew (macOS/Linux)
brew tap jcazako/tap && brew install llm-pentest

# pip / pipx
pip install llm-pentest
pipx install llm-pentest

# From source
git clone https://github.com/jcazako/llm-pentest && cd llm-pentest
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_pentest-0.1.1.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_pentest-0.1.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file llm_pentest-0.1.1.tar.gz.

File metadata

  • Download URL: llm_pentest-0.1.1.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_pentest-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d28a72b547b4ecd57347a87c99512d211d0a074418f3fc9227d45751fdeda3ff
MD5 91f161ebf2b2ea685b053b65c4a28afd
BLAKE2b-256 e7b19874f8753ebc72d2326ff97a3de465ed3420d045f14ec58e2502e8ff44c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_pentest-0.1.1.tar.gz:

Publisher: publish.yml on jcazako/llm-pentest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_pentest-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llm_pentest-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_pentest-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6de695b71fee0af8a9acf550a8b24ff9e36f0f4f5a2da7bc31ea0be966cb0cff
MD5 c9efae79bb497b7139eafdc8c5bdf851
BLAKE2b-256 10bed284c2cbc77b67898c83c9d4e74b253423d923aac2a1e548cfb0c2e64f24

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_pentest-0.1.1-py3-none-any.whl:

Publisher: publish.yml on jcazako/llm-pentest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page