Autonomous Red Teaming Agent for LLM Security Assessment
PromptShield is a comprehensive security testing framework that autonomously assesses the robustness and safety of Large Language Model (LLM) API endpoints through systematic red teaming operations.
- Progressive Testing: Early-stopping strategy that finds minimum working jailbreak strength
- Batch Testing: Parallel execution for comprehensive coverage
- Rate Limiting: Built-in token bucket rate limiter prevents API throttling
- Retry Logic: Automatic retry with exponential backoff for transient failures
- Rule-Based Detection: 12 pre-configured regex patterns for common jailbreak techniques
- Heuristic Scoring: Pattern analysis for multi-step instructions, action verbs, technical jargon
- Judge LLM: AI-powered classification for ambiguous cases with few-shot examples
- Explainable Results: Every decision includes matched rules and reasoning
- Real-time Dashboards: Live progress tracking with KPIs
- Interactive Charts: Donut charts, bar charts, time series with Chart.js
- Drill-down Analysis: View full prompts, responses, and judge reasoning
- Export Capabilities: JSON reports with comprehensive metrics
- RedTeam (2,000 prompts): Professional red team scenarios
- JailBreakV (28,000 prompts): Sophisticated jailbreak methodologies
- Malignant Prompts: General harmful content generation attempts
- CySecBench: Technical security testing prompts
- Node.js 18 or higher
- npm package manager
- OpenRouter API key (or enable mock mode for testing)
# Backend
cd backend
npm install
cp .env.example .env
# Edit .env: Set OPENROUTER_API_KEY or enable MOCK_PROVIDER_ENABLED=true
npm run dev
# Frontend (new terminal)
cd frontend
npm install
npm run devOpen http://localhost:5173 in your browser.
For detailed setup instructions, see SETUP.md
Configure and start a security assessment:
- Select test mode (progressive or batch)
- Choose datasets and filters
- Set concurrency and rate limits
- Monitor real-time progress
- Loads prompts from selected datasets
- Sends prompts to target LLM via OpenRouter
- Collects responses with metadata (latency, tokens, cost)
- Manages rate limiting and retries
Stage 1: Rule-Based Detection
- Checks 12 regex patterns for common jailbreak indicators
- Examples: explicit instructions, role manipulation, filter bypass
Stage 2: Heuristic Scoring
- Analyzes patterns: multi-step instructions, action verbs, technical jargon
- Detects disclaimer language and absence of refusals
Stage 3: Judge LLM (for ambiguous cases)
- Calls judge LLM with few-shot examples for borderline cases
- Returns structured JSON classification with confidence scores
- Ensemble decision combines all stages
- KPI cards: jailbreaks detected, success rate, latency, cost
- Interactive charts: label distribution, strength breakdown, time series
- Detailed table: paginated results with drill-down capabilities
- Export options: JSON reports for further analysis
backend/
├── src/
│ ├── config/ # Environment configuration
│ ├── storage/ # In-memory storage + file persistence
│ ├── judge/ # Hybrid judge pipeline + rules
│ ├── providers/ # OpenRouter integration + rate limiting
│ ├── worker/ # Job queue + progressive/batch modes
│ ├── routes/ # API endpoints
│ └── utils/ # Logger and utilities
├── data/ # Persisted jobs and results
└── logs/ # Application logs
frontend/
├── src/
│ ├── Home.jsx # Landing page
│ ├── PromptBrowser.jsx # Dataset explorer
│ ├── JobsList.jsx # Test jobs list
│ ├── Analysis.jsx # Detailed analysis dashboard
│ └── App.jsx # Application router
└── public/
└── data/processed/ # JSONL datasets
POST /api/test/start
{
"jobName": "Security Audit",
"mode": "progressive",
"datasetSources": ["RedTeam", "JailBreakV"],
"concurrency": 5,
"stopOnFirstSuccess": true
}GET /api/test/status/:jobIdGET /api/test/result/:jobId?page=1&pageSize=50GET /api/report/:jobId/jsonFull API documentation: backend/README.md
Tests prompts in strength order (weak → moderate → strong) with early-stopping when a jailbreak is detected.
Benefits:
- Cost-effective: minimizes API calls by 50-70%
- Finds minimum working strength per prompt
- Ideal for initial assessments
Tests all prompts exhaustively in parallel batches.
Benefits:
- Maximum throughput
- Complete coverage
- Suitable for comprehensive audits
12 pre-configured patterns detect common jailbreak techniques:
- Explicit jailbreak instructions
- Role manipulation (DAN, evil personas)
- System prompt leaks
- Filter bypass language
- Encoded harmful content
- Multi-turn jailbreak patterns
Customize: Edit backend/src/judge/rules.json to add custom rules.
Analyzes response patterns for:
- Multi-step numbered instructions
- Action verb density
- Technical jargon presence
- Disclaimer language
- Refusal keyword absence
For ambiguous cases (score 0.3-0.7):
- Constructs prompt with few-shot examples
- Calls judge LLM (default: Claude-3-Haiku)
- Parses JSON classification with confidence scores
- Ensemble decision uses LLM result if confidence ≥ 0.8
# Server Configuration
PORT=3001
NODE_ENV=development
# OpenRouter API
OPENROUTER_API_KEY=your-api-key-here
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet # Target model to test
# Judge LLM
JUDGE_LLM_MODEL=anthropic/claude-3-haiku # Model for classification
JUDGE_LLM_MAX_TOKENS=500
# Worker Settings
WORKER_CONCURRENCY=5
WORKER_MAX_RETRIES=3
PROVIDER_RATE_LIMIT_RPM=50
# Mock Mode (testing without API costs)
MOCK_PROVIDER_ENABLED=trueSee SETUP.md for complete configuration guide.
# Build and run with Docker Compose
docker-compose up -dAccess at:
- Frontend: http://localhost
- Backend API: http://localhost:3001
PromptShield is designed for legitimate security research and defensive purposes only.
Requirements:
- Obtain proper authorization before testing any LLM systems
- Respect terms of service of target platforms
- Use responsibly for defensive security improvement
- Follow ethical guidelines for AI safety research
- API keys stored server-side only (never exposed to frontend)
- Results stored locally with no external transmission
- Optional data retention policies available
- Supports secure key management practices
Contributions are welcome! Areas for improvement:
- PDF report generation with Puppeteer
- PostgreSQL/Redis integration for production
- Custom prompt upload functionality
- Scheduled/periodic scans
- Webhook notifications
- Additional judge rules and heuristics
- Multi-model comparison testing
- Human review UI for ambiguous cases
- SETUP.md - Complete setup and configuration guide
- SYSTEM_OVERVIEW.md - Technical architecture details
- IMPLEMENTATION_SUMMARY.md - Component overview
- backend/README.md - Backend API reference
This project is licensed under the MIT License - see the LICENSE file for details.
- Security research community for adversarial prompt methodologies
- Dataset contributors: RedTeam, JailBreakV, CySecBench, Malignant prompts
- OpenRouter for unified LLM API access
- Open source community for foundational tools
- Issues: GitHub Issues
- Documentation: See docs/ directory
- Email: security@promptshield.app
Built for the AI safety community