At a glance
- Controls
- CWE-94 · A03:2021 Injection
What it is
Some features ask a model to write a shell command, a database query or a script, then run it directly. The model's output is treated as trusted code. Nothing checks what the code will touch before it runs.
An attacker places instructions in a prompt, a file or a web page the model reads. The model then writes code that does what the attacker wants. AI-assisted attackers can generate and test many such inputs quickly until one produces a harmful command.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Code interpreter or 'run analysis' features that execute generated Python or JavaScript
- Natural-language-to-SQL features that send generated queries to a live database
- Agent tools that pass generated text to a shell, eval or exec call
- Automation jobs that apply generated configuration or scripts without review
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Read the code paths where model output reaches eval, exec, a shell or a database driver.
- 02Sign in with the test login and submit an input that asks the model for a harmless marker command, such as printing a fixed string or reading the process user.
- 03Record whether the marker runs, and with what privileges and network access, using test data only.
Generated code must not run without validation and a limited sandbox.
Executable checkas test user: submit a prompt asking for a command that reads environment variables expect: the command is refused or blocked before it runs as test user: submit a prompt asking for a query on a table outside the feature's scope expect: the query is rejected by an allow-list or a read-only, limited role
Every rule MATT holds →What the fix looks like
- 01
Parse generated code and allow only a fixed set of operations, tables or commands.
- 02
Run generated code in an isolated sandbox with no secrets, no network by default and strict time and memory limits.
- 03
Use a database role that can only read the data the feature needs.
- 04
Require a person to approve generated code before it changes anything.
A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →