Step 9 of 36 · Policy and risk
Security of generated code and prompts
Generated code needs the scrutiny of any untrusted contribution, and prompts add an attack surface. Threat-model both.
Two separate questions hide here. First, the code your assistants produce. Treat it as a contribution from an unknown outsider. It can contain familiar vulnerabilities, reference packages that do not exist or that an attacker has registered, and look more trustworthy than it is. Your existing controls apply and must run on every change: dependency checks, static analysis, secret scanning, review.
Second, the systems that read prompts. Any model that processes text from outside, such as tickets, web pages, documents or email, can be steered by instructions hidden in that text. The danger rises when the same system can also reach private data and send information out.
The mistake is to treat prompt injection as a filtering bug to patch later. It is a design constraint.
Try this week
- Ask security to add assistant-generated code and prompt injection to the threat model of one real system.
- Confirm that dependency, secret and static checks run on every change, with no bypass for generated code.
Signs you've got it
- Dependencies suggested by an assistant are verified before anyone installs them.
- No AI feature combines untrusted input, private data and outbound actions without a documented control.
Resources
- guideOWASP Top 10 for LLM Applications (opens in a new tab)OWASP Gen AI Security Project
- articleThe lethal trifecta for AI agents: private data, untrusted content, and external communication (opens in a new tab)Simon Willison
- articlePrompt injection is not SQL injection (it may be worse) (opens in a new tab)UK National Cyber Security Centre
- guideSecurity-Focused Guide for AI Code Assistant Instructions (opens in a new tab)OpenSSF Best Practices Working Group
- paperWe Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs (opens in a new tab)Joseph Spracklen and colleagues