CWE-94AI-written & agentic codeSeverity · High

Model output executed

A product runs commands, queries or scripts written by a model with no check on what they do. Anyone who can influence the model's input can then run code.

At a glance

Controls
CWE-94 · A03:2021 Injection
Typical severityHigh
ReferenceCWE-94
OWASP Top 10A03: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.

  1. 01Read the code paths where model output reaches eval, exec, a shell or a database driver.
  2. 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.
  3. 03Record whether the marker runs, and with what privileges and network access, using test data only.
The rule, in plain English

Generated code must not run without validation and a limited sandbox.

Executable check

as 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

  1. 01

    Parse generated code and allow only a fixed set of operations, tables or commands.

  2. 02

    Run generated code in an isolated sandbox with no secrets, no network by default and strict time and memory limits.

  3. 03

    Use a database role that can only read the data the feature needs.

  4. 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? →

ExploitOps discovery call

Understand where your security loop breaks.

A call with a MATT co-founder to understand your product and whether an ExploitOps Review is worth doing. If there is a real need, we scope one with the research team.

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02