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 for LLMs that detects and blocks prompt injection attacks using four defense layers. The tool, built with Python and FastAPI, claims 100% attack detection with zero false positives in benchmarks and includes features like API key authentication, rate limiting, and a dashboard UI.

read1 min views1 publishedJul 13, 2026
I built a prompt injection defense middleware for LLMs (Python/FastAPI)
Image: source

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 Β· β€”