LLM Security: Patterns and Pitfalls
LLM applications fail when instructions are not isolated, context is unsanitized, tools are over-privileged, or outputs are trusted blindly. Use instruction isolation, input/output filters, retrieval hardening, tool allow-lists with least privilege, and human-in-the-loop for sensitive actions. Test continuously with reproducible attacks.
Key Facts
-
LLMs follow instructions and can be induced to override guardrails.
[1] -
Instruction isolation and strict tool scopes reduce impact.
[1] -
Retrieval must sanitize and constrain cross-domain content.
[1] -
Output validation prevents unsafe actions and data leakage.
[1] -
Regression testing is required after model/config changes.
[2]
Implementation Steps
- 01
Isolate system prompts → versioned prompt repo.
- 02
Sanitize retrieval → allow-list, strip directives.
- 03
Gate tools → scoped keys, approvals.
- 04
Validate outputs → regex/semantic checks.
- 05
Regressions → test suite results.
Glossary
References
-
[1]
NIST AI Risk Management Framework https://www.nist.gov/itl/ai-risk-management-framework
-
[2]
ISO 42001 AI Management Systems Standard https://www.iso.org/standard/78380.html
Machine-Readable Facts
[
{
"id": "f-override",
"claim": "LLMs can be induced to override intended instructions without isolation.",
"source": "https://www.nist.gov/itl/ai-risk-management-framework"
},
{
"id": "f-scope",
"claim": "Tool scopes and least privilege reduce blast radius in LLM apps.",
"source": "https://www.nist.gov/itl/ai-risk-management-framework"
},
{
"id": "f-regress",
"claim": "Security regressions occur after model or prompt changes; re-testing is required.",
"source": "https://www.iso.org/standard/78380.html"
}
]