PromptWAF
Check out the PromptWAF article.
I developed the PromptWAF detection layer for this project, designing and training separate binary classifiers for the main attack vectors and combining their outputs into a final Allow/Deny decision for malicious prompts.
Materials
Datasets
Training code
Github repository
Problem
Large Language Models (LLMs) are evolving into autonomous agents that directly integrate with external systems (such as databases and file systems) via frameworks like the Model Context Protocol (MCP) without adequate security controls. This unconstrained architecture enables Prompt Injection attacks to trigger critical infrastructure vulnerabilities, including Path Traversal, SQL Injection, and Command Injection.
Solution
To develop PromptWAF, an AI-based security module that detects and blocks malicious user inputs in real-time before they reach the LLM layer.
Method
Unlike traditional NLP processes, custom datasets were generated while preserving special characters. In total, 3 training and 3 test datasets were created for Path Traversal, SQL, and Command Injection attacks. After training initial baseline models, fine-tuning was applied to BERT-based models (DistilBERT, DeBERTa) for the final system.
Conclusion
By fine-tuning existing BERT models with the custom-generated datasets, detection rates were dramatically increased to establish the final models. Evaluations on our external test data demonstrated significant improvements compared to pre-fine-tuning baselines: accuracy surged from 64% to 100% in Path Traversal, from 81% to 96.83% in SQL Injection, and from 78% to 95.24% in Command Injection, proving the system's superiority against these specific vulnerabilities.