{"slug": "i-built-a-prompt-injection-defense-middleware-for-llms-python-fastapi", "title": "I built a prompt injection defense middleware for LLMs (Python/FastAPI)", "summary": "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.", "body_md": "**Production-grade LLM prompt injection defense middleware.**\n\nPromptShield sits between your users and your AI model, detecting and blocking adversarial attacks before they cause damage.\n\nPromptShield runs every user input through 4 layers of defense:\n\n| Layer | Name | What It Does |\n|---|---|---|\n| 1 | Input Classifier | Detects malicious prompt patterns |\n| 2 | Context Sanitizer | Strips injected instructions from user input |\n| 3 | Prompt Integrity Checker | Validates prompt structure hasn't been tampered with |\n| 4 | Output Monitor | Scans AI responses for signs of successful injection |\n\n- ✅ 100% attack detection, zero false positives (benchmark tested)\n- ⚙️ Tunable aggression dial —\n`permissive`\n\n→`balanced`\n\n→`strict`\n\n→`paranoid`\n\n- 🔑 API key authentication + rate limiting\n- 📊 Audit logging and dashboard UI\n- 🐍 Python SDK for easy integration\n- 🐳 Docker support\n\n```\ngit clone https://github.com/JustiNoel/LLM-Prompt-Injection.git\ncd LLM-Prompt-Injection\ndocker-compose up\n```\n\nPython · FastAPI · Google Gemini · Docker\n\nBuilt by [Justin Noel](https://github.com/JustiNoel)", "url": "https://wpnews.pro/news/i-built-a-prompt-injection-defense-middleware-for-llms-python-fastapi", "canonical_source": "https://github.com/JustiNoel/LLM-Prompt-Injection", "published_at": "2026-07-13 16:54:16+00:00", "updated_at": "2026-07-13 17:05:19.280427+00:00", "lang": "en", "topics": ["ai-safety", "ai-tools", "developer-tools", "large-language-models", "artificial-intelligence"], "entities": ["Justin Noel", "PromptShield", "FastAPI", "Google Gemini", "Docker", "Python"], "alternates": {"html": "https://wpnews.pro/news/i-built-a-prompt-injection-defense-middleware-for-llms-python-fastapi", "markdown": "https://wpnews.pro/news/i-built-a-prompt-injection-defense-middleware-for-llms-python-fastapi.md", "text": "https://wpnews.pro/news/i-built-a-prompt-injection-defense-middleware-for-llms-python-fastapi.txt", "jsonld": "https://wpnews.pro/news/i-built-a-prompt-injection-defense-middleware-for-llms-python-fastapi.jsonld"}}