Skip to main content

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

Metadata

Release files for llm-pentest 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-pentest 0.1.1
File Size Uploaded Provenance
llm_pentest-0.1.1.tar.gz 25.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-pentest 0.1.1
File Interpreter ABI Platform
llm_pentest-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 43.8 kB

Release files / llm_pentest-0.1.1.tar.gz

Download URL llm_pentest-0.1.1.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d28a72b547b4ecd57347a87c99512d211d0a074418f3fc9227d45751fdeda3ff
BLAKE2b-256 checksum
How to use checksums
e7b19874f8753ebc72d2326ff97a3de465ed3420d045f14ec58e2502e8ff44c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Release files / llm_pentest-0.1.1-py3-none-any.whl

Download URL llm_pentest-0.1.1-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6de695b71fee0af8a9acf550a8b24ff9e36f0f4f5a2da7bc31ea0be966cb0cff
BLAKE2b-256 checksum
How to use checksums
10bed284c2cbc77b67898c83c9d4e74b253423d923aac2a1e548cfb0c2e64f24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Security for llm-pentest 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llm_pentest-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page