Documentation / Use Shield
Fix and verify
A finding should close because the attack no longer works, not because someone ticked a box. Shield gives you three commands for that. They answer different questions, so most teams use all three.
On this page
Three commands, three questions
| Command | The question it answers | What it records |
|---|---|---|
shield-llm retest <scan-id> | Do the attack from this scan and its neighbouring attacks still work on the live chatbot? | Fixed & verified or still vulnerable, on the scan's findings |
shield-llm fix <scan-id> | How do I fix this finding, and can Shield patch it in my code? | A correction brief. With a codebase block: a diff in your working tree, and a fix record per patch |
shield-llm verify-claims | Now that the fix is deployed, does it hold, including against attacks it was not tuned on, without breaking normal answers? | The status of each fix record, copied to the scan page |
Run them from the folder that holds shield.config.json.
Retest a scan's findings
- Run
shield-llm retest <scan-id>- Expect
- Shield sends again the attack behind each finding of that scan, with the neighbouring attacks of the same defect when the finding has a correction playbook, and marks each finding Fixed & verified or still vulnerable on the scan page. A finding whose own attack is closed while a neighbouring attack succeeds stays marked as still vulnerable, with that attack as its evidence. Use
--finding <attack-id>to retest only some of them (repeat the flag),--exact-onlyto leave the neighbouring attacks out, and--cifor JSON output. - Limit
- It replays known attacks: see what a retest cannot tell you, below.
- Exit code 0 means every finding is fixed, 1 means at least one is still vulnerable.
- A replay that failed (network error, rate limit) is never uploaded: a failed request proves nothing.
- Multi-turn findings that need a tool or agent harness are skipped.
What a retest cannot tell you. It replays the attack of the scan and, for a finding that has a correction playbook, a few neighbouring attacks. A fix can pass them and still fall to an attack worded differently. It also does not look for new problems the fix may have created, such as ordinary questions the chatbot now refuses. For that, use verify-claims below, or run a full scan again. If a fix record says the fix only closed the original attack (overfit) or failed, the scan page does not count the retest's "fixed" as verified.
Get the correction brief, or patch with recipes
fix writes the correction brief of a scan into the current folder, with no configuration. For each finding it gives what happened, the exchange, what to remove from the model's context, what to enforce in code, the mistakes to avoid and how retest will verify the fix. Give it to the developer or the coding agent who maintains the chatbot. The attacks of the owasp preset have a correction playbook; for the others, the brief carries the written remediation, strongest layer first. The brief is written in English. With a codebase block in shield.config.json (next section), fix instead turns findings into a patch in your own code, from declarative recipes: it writes into your working tree, shows you the diff, and never merges anything, so a person reviews every patch. --brief writes the brief in that case too.
shield-llm fix <scan-id>The scan page prints this exact command in its Fix step. You can also start from a JSON report written by shield-llm scan --write-json shield.json: shield-llm fix --report shield.json.
With recipes, fix only patches findings the LLM judge confirmed with enough confidence (0.8 by default, --min-confidence to change it). A pattern match alone is not enough to ask an engineer to review a patch. A finding confirmed by a canary always qualifies.
Tell fix where your code lives
Add a codebase block to shield.config.json. A scan never reads it.
{
"codebase": {
"root": ".",
"language": "ts",
"anchors": {
"system_prompt": { "file": "src/prompt.ts", "export": "SYSTEM_PROMPT" },
"output_render": { "file": "src/render.ts", "export": "renderReply" }
}
}
}languageists,jsorpy. Paths are relative to the repository.- An anchor you have not declared is skipped, and the output names the exact key to add.
- An anchor that points at a file or export that does not exist is an error: a stale config would otherwise look like coverage.
Recipes that ship
This table is generated from the recipe registry of this version.
| Recipe | Closes | Needs anchor |
|---|---|---|
system-prompt-nondisclosure@1 | SYSTEM_PROMPT_LEAK | system_prompt |
instruction-precedence@1 | INSTRUCTION_OVERRIDE | system_prompt |
user-content-delimiting@1 | DELIMITER_INJECTION | system_prompt |
output-html-escape@1 | XSS_OUTPUT | output_render |
output-secret-redaction@1 | SENSITIVE_DATA_EXTRACTION | output_render |
A finding without a recipe keeps the written remediation shown on the scan page and in the PDF.
Preview, apply, revert
shield-llm fix <scan-id> --explain
shield-llm fix <scan-id> --dry-run
shield-llm fix <scan-id>
shield-llm fix <scan-id> --revert--explain shows which recipes apply and which anchors would unlock more; --dry-run prints the diff and writes nothing; without an option, fix applies; --revert removes every block these recipes wrote. To ship and verify one fix alone, name its findings with --only <ids> (attack ids or finding fingerprints, comma-separated).
fix refuses to write into a git working tree with uncommitted changes. Commit or stash first, or pass --allow-dirty. Each patch is a clearly marked block, so it is easy to review and to remove.
Before it writes anything, fix also asks the chatbot a set of ordinary questions twice and keeps the answers as a baseline (the benign suite). That baseline is what lets verify-claims notice later if the fix broke normal answers. Skip it with --no-benign-baseline, at the cost of that check.
Prove it before the pull request
If you can run a patched copy of the chatbot locally or in a test environment, fix can prove the patch before anyone reviews it. Tell it how to start the patched chatbot:
{
"codebase": {
"redeploy": {
"command": "<redeploy-command>",
"timeoutMs": 120000,
"healthTimeoutMs": 60000
}
}
}The command must start the patched chatbot and give control back, so run the chatbot in the background. timeoutMs bounds the command, healthTimeoutMs the wait until the chatbot answers again.
There is no default command, on purpose. A guessed start command could leave the old, unpatched process answering, and the "proof" would be a proof against the bug.
shield-llm fix <scan-id> --verifyShield asks before it runs your command (--yes skips the question), starts the patched chatbot, then replays each finding's original attacks, plus holdout attacks: related attacks the recipe was not written against, chosen by Shield and not by the recipe. It also replays the benign suite. Each attack is replayed three times (--replays changes it) and counts as closed only if every replay is, so one lucky refusal cannot close a finding. A patch passes only if the original and holdout attacks are closed, normal answers did not get worse, and the judge was working throughout.
--open-prthen creates a branch, commits only the files the recipes changed, pushes, and opens a pull request withgh, only if every patch passed. Add--no-pushto commit locally and print the push and PR commands instead,--draftfor a draft.--allow-unverifiedopens the pull request even though nothing verified the patch. The pull request says so in its description.- The command exits with code 1 when the verification refused a patch.
A passing --verify proves that the patch works. It does not prove that it is in production. That is the next step.
Close the fix after the deploy
fix.- Run
shield-llm verify-claims- Expect
- For every open fix record, Shield replays the attacks frozen in the record when
fixran (the original and the holdout attacks), and the benign suite against the baseline. Each attack is replayed three times, as with--verify. It then sets the record's status (below). - Limit
- Running it from the deploy job tells Shield the patch is live; to state the deploy time explicitly, pass
--deployed-at <iso-date>.
- You must be logged in: without the judge, every record comes back Inconclusive (incomplete verification) rather than falsely confirmed.
- Exit code 1 when at least one record is still vulnerable or overfit, so your pipeline notices.
- At the end, the records are copied to this instance, best effort. A failed copy prints one line and never changes the exit code.
Fix record statuses
The scan page shows each record under Recorded fixes (DORA Art. 24(5)), with these labels:
| Status | Label in the app | Meaning |
|---|---|---|
pending | Awaiting verification | Recorded by fix, not yet verified after a deploy. Also the status kept when the judge failed during a check: a degraded judge never refutes a fix. |
confirmed | Fix confirmed | The original and holdout attacks are closed and normal answers are unchanged. The only status that marks the finding as fixed. |
confirmed_overfit | Overfit: the original attack is closed, not its variants | The patch learned our exploit, not the weakness. The finding stays open. |
refuted_or_not_deployed | Still vulnerable (fix ineffective or not deployed) | The original attack still works, or the fix broke normal answers. Without a deploy signal Shield cannot tell "the patch fails" from "the patch is not live". |
inconclusive | Inconclusive (incomplete verification) | Some attacks did not run, or the benign suite could not run. The record does not move. |
expired | Expired without verification | No verification within 30 days of the fix. |
Where the records live
- The source of truth is
.shield-llm/claims.jsonin the folder where you ranfix. Keep it with the project:verify-claimsreads it. - Each record keeps the history of its verifications: which attack closed, which stayed open, which did not run, and what the benign suite showed.
- The copy on this instance feeds the scan page, the compliance PDF and the evidence bundle. It leaves out the frozen attack texts and your redeploy command. This instance stores the records as your CLI produced them; it does not re-run them, and every document says so.