PromptShield is a real-time security gateway for LLM-powered applications that detects and blocks malicious prompts before they reach the AI model. It protects against common LLM-specific threats such as prompt injection, jailbreaks, system prompt extraction, data exfiltration, and obfuscation. Every prompt passes through a rule-based, regex-driven detection engine that checks five threat categories and assigns a risk score from 0–100. Based on the score, PromptShield either Allows the prompt (0–29), Sanitizes suspicious phrases (30–59), or Blocks it (60–100). High-risk prompts are stopped before the LLM is called, ensuring a block-before-LLM security layer. Approved prompts are forwarded to the Groq API using the llama-3.1-8b-instant model. The system includes a FastAPI REST backend with Swagger documentation and a Gradio dashboard for live verdicts, request logs, and attack statistics. The backend is deployed on Vercel and the dashboard on Replit, making the project fully live and testable. We chose a rule-based approach for our hackathon MVP because it is fast, lightweight, free, and fully explainable without requiring a second AI model. Current limitations include the absence of semantic/ML detection, persistent storage, authentication, and rate limiting, with these planned as future improvements along with multilingual detection and automated red-team evaluation. PromptShield demonstrates how a lightweight and transparent security gateway can provide meaningful protection against common prompt-based attacks in real time. Built for the AI Infra Summit Hackathon by Sana Arshad (BS Cyber Security, UET Lahore) and Minahel Javed (BS Artificial Intelligence, UET Lahore).
Category tags: