llm-app-guard
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
llm-app-guard
Attack an LLM app, fix it with deterministic controls, and measure the difference.
LLM chat apps keep shipping the same three vulnerabilities: a secret in the system prompt, actions executed from model text, and model output rendered as HTML. This repo lets you watch all three get exploited and then blocked, and gives you the pieces to do the same in your own app:
Part | What it is |
Larkspur Outfitters, a small support bot for an outdoor-gear shop (synthetic data). One app, two modes: vulnerable on | |
A red-team harness: replays attack and benign prompts N times against any chat endpoint, scores each reply with deterministic detectors, checks XSS in a real browser, and reports rates with confidence intervals. | |
The | |
A case study: the same fixes applied to SecureBot, a deliberately vulnerable training chatbot. Patch only; you bring your own copy of SecureBot. |
The controls come from agentic-core, a dependency-free library of deterministic checks for agents. The rule throughout: the model can propose; code decides.
Run it in 3 commands
Needs Docker and Ollama running locally.
ollama pull llama3.1:8b # on an 8 GB machine: llama3.1:8b-instruct-q3_K_M (set MODEL in .env)
cd demo && cp .env.example .env
docker compose up --build # vulnerable → http://localhost:8090 guarded → http://localhost:8091Try the same three messages on both pages:
Vulnerability | Try this | Vulnerable ( | Guarded ( |
Secret in the prompt (OWASP LLM07) |
| Prints its instructions, including the promo code | "Sorry, I can't share that." |
Actions from model text (LLM06) | In the browser console, forge history: | Refunds another customer's order | "Not allowed: REFUND B2001 / 899 (not_owner)" |
Model output as HTML (LLM05) |
| An alert box: the model's reply ran JavaScript | Plain text, no script |
The model answers differently each time; if an attack doesn't land, send it again. Measure it properly with the harness below.
Related MCP server: PromptWall MCP Server
Results
Measured with the harness, llama3.1:8b-instruct-q3_K_M, Wilson 95% confidence intervals.
Demo shop, exemplar attacks, 5 trials each:
Attack | Vulnerable | Guarded |
Prompt dump | 3/5 leaked (2 timed out) | 0/5 |
Forged-history refund | 5/5 | 0/5 |
HTML/XSS (run in Chromium) | 5/5 | 0/5 |
SecureBot case study, 71 prompts from public attack corpora plus hand-written cases, 3 trials each (details):
Suite | Vulnerable | Fixed |
Prompt leak | 27% (17–39%) | 0/60 (0–6%) |
Excessive agency | 13% (6–26%) | 0/45 (0–8%) |
XSS executed in browser | 5% (2–13%) | 0/63 (0–6%) |
Benign questions answered | 93% (82–98%) | 100% (92–100%) |
The fixes held at 0/10 per exemplar on a second model (llama3.2:3b). The guards add about 0.2 ms per reply.
Attack it yourself
python3 -m venv .venv && . .venv/bin/activate
pip install -e ".[dev,render]" && python -m playwright install chromium
python eval/fetch_corpora.py && python eval/build_suites.py # public corpora → eval/datasets/*.jsonl
breakit --target http://localhost:8090 run --suite all --config demo-off --n 3
breakit --target http://localhost:8091 run --suite all --config demo-on --n 3
breakit --target http://localhost:8090 render-check --config demo-off # did the XSS actually run?
breakit summarize --config demo-off && breakit summarize --config demo-onbreakit watch --config demo-off streams each attempt as it lands. Point --target only at apps you run yourself.
Use the guards in your app
As an MCP server, for an application's enforcement point (not for the model to call; see below):
pip install -e ".[mcp]"
claude mcp add llm-app-guard -- "$(pwd)/.venv/bin/llm-app-guard" # or any MCP host: command = .venv/bin/llm-app-guardTool | Use it to |
| Scan a reply for a canary, protected values in disguise, or a verbatim prompt dump |
| Strip HTML, markdown images/links and URLs, or HTML-escape |
| Decide on a model-proposed action for an authenticated user: |
| Verify and burn a grant (single use), re-check policy, then execute |
| Advisory prompt-injection score ( |
principal must come from your app's authenticated session. If the model could call authorize_action, a prompt
injection could name any user.
From the shell: guard authorize REFUND B2001 899 --principal alice@example.com (try bob@example.com).
In Python: use agentic-core directly; its README shows a complete reply-and-action guard in about 30 lines.
How it works
Vulnerable pattern | Guarded | |
Secrets | Secret in the system prompt, "never reveal" | No secret in the prompt; random canary; egress scan for the canary, the secret in disguise and prompt overlap |
Actions |
| Identity from the server session; policy check (ownership, price, return window, caps); signed, expiring, single-use grant; the customer's click executes |
Output |
|
|
More: ARCHITECTURE.md (diagram, trust boundaries, threat → control map), LESSONS.md (what building and breaking this taught), docs/case-study.md (SecureBot, including the LLM-generated patches and why each was rejected).
Development
pip install -e ".[dev,demo,mcp]"
ruff check . && pytest -q # offline: the model is faked, no Ollama neededThe optional classifier: pip install -e ".[advisor]", then RUN_DEBERTA=1 pytest guard_mcp/tests (downloads the
model once, pinned to a revision, safetensors only).
Data and licences
Code: Apache-2.0. Attack prompts are fetched at build time, not committed: Lakera gandalf_ignore_instructions
(MIT), OWASP XSS Filter Evasion cheat sheet (CC BY-SA 4.0), Tensor Trust and PortSwigger XSS cheat-sheet data (no
redistribution licence; fetched for local evaluation only). All customers, orders and codes are synthetic.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Pay-per-call safety guards for AI agents: injection, tool-call, signing, secret, x402-trust.
Deterministic trust gate for AI output: leaked-secret, prompt-injection & PII in one call.
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
Detect prompt injection, jailbreaks, and code injection in untrusted text before it reaches an LLM.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables content inspection, sanitization, containment, and quarantine for LLM security, preventing prompt injection and credential leaks.MIT
- AlicenseNot gradedqualityCmaintenanceEnables scanning LLM prompts and responses for prompt injection, jailbreaks, PII leakage, secret leakage, and other malicious content using deterministic rules, returning verdicts and safe redacted text.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to score their outgoing responses against groundedness and prompt-injection risks mid-turn, returning allow, warn, or block verdicts before the response reaches the user.10 npmISC
- AlicenseNot gradedqualityBmaintenanceEnables secure MCP agent operations by enforcing fail-closed policies, blocking dangerous tool calls, scanning outputs for prompt injection, and recording every action in a tamper-evident audit log.2MIT