ges257/llm-security-harness
<div align="center">
Red Teaming Harness for Prompt Injection Vulnerability Assessment

</div>
Outcome
Keyword filter guardrail achieved 100% attack blocking with 0% over-refusal on a 50-case benchmark. Built a quantitative framework for evaluating LLM security with canary token detection, implementing three defense variants (baseline, regex, semantic) to demonstrate defense-in-depth value.
Technical Build
Designed canary token methodology for binary ground-truth measurement of prompt injection success. Implemented 25+ regex patterns covering 6 attack categories (instruction override, prompt extraction, jailbreak, delimiter attacks). Built LLM-based semantic classifier using Claude Haiku for intent-based detection with 0.7 confidence threshold.
Results
Key Finding: Claude's inherent robustness means 0% canary leaks even without guardrails. The keyword filter provides defense-in-depth with zero latency.
How It Works
User Input → Guardrail Layer → Claude API → Canary Detection
↓ ↓
[Block/Pass] [Canary in response?]Attack Categories
Plus 20 benign queries for over-refusal measurement.
Project Structure
llm-security-harness/
├── app/
│ ├── app.py # Streamlit dashboard (HF entry point)
│ ├── guardrails/ # Baseline, keyword, LLM classifier
│ ├── config.py # Canary token, API settings
│ ├── evaluator.py # Benchmark runner
│ ├── data/testcases.csv # 50 test cases
│ └── results/results.csv # Pre-computed benchmark
├── README.md
├── ARCHITECTURE.md # System diagrams
├── CHALLENGES.md # Problem-solving narrative
└── LEARNINGS.md # Insights and trade-offsUsage
# Install dependencies
pip install -r requirements.txt
# Configure API (optional - works offline with pre-computed results)
cp .env.example .env
# Edit .env with your ANTHROPIC_API_KEY
# Run Streamlit app
streamlit run app/app.pyDocumentation
- ARCHITECTURE.md - System design and data flow
- CHALLENGES.md - Problems solved and trade-offs
- LEARNINGS.md - Insights and recommendations
References
License
MIT
<div align="center">
Part of the AI/ML Portfolio
</div>
