A genetic algorithm that automatically discovers prompt injection attacks capable of evading LLM security filters.
Pairs with Prompt Firewall — Forge finds the holes, Firewall plugs them.
Evolves prompt injection attacks across generations using:
- LLM-powered mutation — generates novel variants via rephrasing, encoding, splitting, nesting, and language mixing
- Rule-based fallback — works without an API key (leet-speak, zero-width chars, academic framing)
- Fitness scoring — tests each attack against a target firewall, scoring bypass success + novelty + diversity
- Genetic selection — keeps successful mutations, breeds them, discards weak ones
Seed attacks (10 categories)
│
▼
LLM Mutator ──► Variants ──► Test against Firewall
▲ │
│ ▼
└──── Keep best ◄────── Fitness scoring
mutations (bypass + novelty)
pip install -r requirements.txt
# Run against your Prompt Firewall (or any OpenAI-compatible endpoint)
python forge.py --demo
# With LLM-powered mutations (add your API key to .env first)
cp .env.example .env
# Edit MUTATOR_API_KEY=sk-your-key-here
python forge.py --generations 10 --population 20uvicorn server:app --host 127.0.0.1 --port 8081- Launch new fuzzing runs from the UI
- Browse discovered bypasses in the attack corpus
- View run history with fitness trends
Running against Prompt Firewall (8 individuals, 3 generations, no LLM):
| Metric | Value |
|---|---|
| Bypasses found | 7 |
| Best fitness | 86% |
| Total attacks | 32 |
| Top technique | Zero-width space evasion |
| Top technique | Leet-speak bypass |
| Top technique | Academic framing |
Before deploying an LLM to production, point InjectionForge at your API endpoint:
- It generates hundreds of mutated attacks overnight
- Discovers which bypass techniques work against your specific defenses
- Produces a corpus of proven evasions
- You patch your firewall, re-run, verify fixes
- Python 3.14 — genetic algorithm core
- OpenAI API (optional) — LLM-powered mutation engine
- FastAPI + uvicorn — web dashboard
- httpx — target testing
Built as Portfolio Project #5 — August 2026
