cd /news/ai-safety/i-built-a-prompt-injection-defense-m… · home topics ai-safety article
[ARTICLE · art-57641] src=github.com ↗ pub= topic=ai-safety verified=true sentiment=↑ positive

I built a prompt injection defense middleware for LLMs (Python/FastAPI)

Developer Justin Noel released PromptShield, an open-source middleware built with Python and FastAPI that defends large language models against prompt injection attacks through four detection layers, claiming 100% attack detection with zero false positives in benchmark tests. The tool includes API key authentication, rate limiting, audit logging, a dashboard UI, and Docker support, and is available on GitHub.

read1 min views61 publishedJul 13, 2026
I built a prompt injection defense middleware for LLMs (Python/FastAPI)
Image: Michielbdejong (auto-discovered)

Production-grade LLM prompt injection defense middleware.

PromptShield sits between your users and your AI model, detecting and blocking adversarial attacks before they cause damage.

PromptShield runs every user input through 4 layers of defense:

Layer Name What It Does
1 Input Classifier Detects malicious prompt patterns
2 Context Sanitizer Strips injected instructions from user input
3 Prompt Integrity Checker Validates prompt structure hasn't been tampered with
4 Output Monitor Scans AI responses for signs of successful injection
  • ✅ 100% attack detection, zero false positives (benchmark tested)
  • ⚙️ Tunable aggression dial — permissive

balanced

strict

paranoid

  • 🔑 API key authentication + rate limiting
  • 📊 Audit logging and dashboard UI
  • 🐍 Python SDK for easy integration
  • 🐳 Docker support
git clone https://github.com/JustiNoel/LLM-Prompt-Injection.git
cd LLM-Prompt-Injection
docker-compose up

Python · FastAPI · Google Gemini · Docker

Built by Justin Noel

── more in #ai-safety 4 stories · sorted by recency
── more on @justin noel 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-built-a-prompt-inj…] indexed:0 read:1min 2026-07-13 ·