11 Detectors, One patterns.yaml: Hardening LLM Apps with resk-llm
TL;DR
resk-llm is a Python toolkit from resk that bundles 11 detectors for common LLM attacks: prompt injection, jailbreak, PII exfiltration, memory poisoning, and goal hijack. It ships as FastAPI middleware and is configured through a simple patterns.yaml file. The project is young, but the design is refreshingly direct: drop in the middleware, point it at your patterns, and start filtering malicious traffic.
Why LLM security needs middleware
LLM applications are not just APIs. They sit between untrusted user input and your prompts, memory, tools, and data. A single malicious prompt can leak PII, override system instructions, or poison a conversation history. Most teams add security after an incident. resk-llm tries to make the first line of defense a one-line addition to your FastAPI app.
The toolkit covers five attack categories with 11 detectors. That includes prompt injection and jailbreak attempts, PII exfiltration, memory poisoning, and goal hijack. Instead of forcing you into a SaaS dashboard or a heavyweight policy engine, resk-llm uses a local YAML file. You can see exactly what patterns are being matched and extend them for your own use cases.
What you get
resk-llm includes 11 detectors that map to five threat categories:
- Prompt injection: attempts to override the original system prompt.
- Jailbreak: attempts to bypass safety rules and restrictions.
- PII exfiltration: attempts to extract personal data from the model or memory.
- Memory poisoning: attempts to corrupt the conversation history or stored context.
- Goal hijack: attempts to redirect the model toward a different objective.
Each detector is a pattern matcher. The patterns live in patterns.yaml, so you can inspect, extend, and version them like any other code. This is a big advantage over black-box security services.
The real numbers
I looked at the PyPI download stats for resk-llm. The numbers are modest, and that is worth being honest about.
| Metric | Value |
|---|---|
| Downloads in the last day | 1 |
| Downloads in the last week | 4 |
| Downloads in the last month | 60 |
| Detectors included | 11 |
| Configuration format | patterns.yaml |
A project with 60 monthly downloads is not yet a proven enterprise standard. But early adoption is exactly when you can shape the tool to fit your stack. The low numbers also mean the API is still small enough to understand quickly.
Minimal FastAPI integration
The pitch is drop-in middleware for production Python stacks. A minimal setup looks like this:
from fastapi import FastAPI
from resk_llm import LLMSecurityMiddleware
app = FastAPI()
app.add_middleware(
LLMSecurityMiddleware,
config="patterns.yaml",
)
Once the middleware is installed, incoming requests pass through the detectors defined in patterns.yaml. You can start with the built-in patterns and then tune them for your specific prompts, data flows, and risk tolerance.
This is not a replacement for input validation, rate limiting, or human review. It is an additional layer that catches known attack shapes before they reach your model.
Honest limitations
resk-llm is an early-stage open source project. The download numbers are low, so community feedback and battle-testing are still limited. A patterns-based approach is effective against known attack patterns, but it will not catch every novel or heavily obfuscated attack. You should treat it as one layer in a broader security strategy, not as a complete solution.
The FastAPI middleware integration is convenient, but if your stack is not FastAPI-based, you will need to adapt the toolkit to your own framework. The project also assumes you can maintain a patterns.yaml file; teams that prefer a UI or a managed service may find this too manual.
Finally, no chart data was available for this post, so the numbers above are the only public signals I have. Use them as a starting point, not as a growth guarantee.
Conclusion
LLM security is still a young discipline. Tools like resk-llm matter because they make it easy to start. Eleven detectors, one YAML file, and a FastAPI middleware class give you a concrete foundation for protecting prompts, memory, and data.
Try it today:
- Install the package:
pip install resk-llm - Read the source and contribute: github.com/Resk-Security/Resk-LLM
- Explore enterprise AI security tools: resk.fr — AI Security Tools for Enterprise
The best time to add LLM security is before your first incident. resk-llm makes that step small enough to take today.
Top comments (0)