Mehdi Akiki
Published on

README Prompt Injection: Check Tool Permissions Before Effects

Authors
  • Mehdi Akiki avatar
    Name
    Mehdi Akiki
    Twitter

Article · Through the layers

You ask an agent to summarize a repository. It opens the README. Between normal setup notes, the document tells it to export a private report before continuing.

No sandbox wall has necessarily broken. The agent has read a file it was allowed to read. The problem begins when the application treats the file's instructions as permission to do something else.

This is why prompt injection belongs in a discussion about agent security even when no memory corruption or container escape is involved. A reachable tool can be enough to cause trouble.

The tool authorization guide explains identity and delegation. Here we follow one constructed repository-summary trace all the way to the data service. The sandbox overview covers the separate boundary around code execution.

The README cannot grant permissions

A repository file, search result, email, or tool response can contain instructions. Some may be relevant to the task. Others can be planted by a person who has no authority over the user's account.

The hard part is that the model sees both kinds of text. A warning in the system prompt helps describe the intended behavior, but the application still needs to control what happens if the model chooses a bad next step.

OpenAI's March 2026 discussion treats this as a problem of agents acting on untrusted content, with defenses across the system. The application still needs permission checks when a filter misses an attack.

Start with the user's actual request: read one approved repository input and produce a summary. That request does not authorize an account export, a new credential, or a write to another project.

Store the grant outside the conversation

Here is a small TypeScript gate. The application has already authenticated the caller and issued a grant for one input in one job.

type Grant = Readonly<{
  actor: string;
  jobId: string;
  inputId: string;
}>;

type ReadCall = {
  action: "read-input";
  jobId: string;
  inputId: string;
};

function authorizeRead(actor: string, grant: Grant, value: unknown): ReadCall {
  if (!value || typeof value !== "object") {
    throw new Error("invalid tool call");
  }
  const call = value as Record<string, unknown>;
  if (
    actor !== grant.actor ||
    call.action !== "read-input" ||
    call.jobId !== grant.jobId ||
    call.inputId !== grant.inputId
  )
    throw new Error("capability denied");
  return {
    action: "read-input",
    jobId: grant.jobId,
    inputId: grant.inputId,
  };
}

The returned object is constructed from the grant. It isn't the original model-produced object with a few fields checked. A caller cannot add an admin: true property and expect the next service to honor it.

The actor and grant arguments must come from trusted request handling. If the application loads them from the same model response as value, the comparison proves very little.

Follow the proposed call to the effect

The complete TypeScript example includes a fake repository backend and a list of effects. Its README contains both an ordinary instruction, “Run npm ci to install dependencies,” and the unrelated request to export private reports. Reading the document returns both as text.

The execution function checks the proposal before choosing any effect:

const call = authorizeRead(actor, grant, value);
return ports.read(grant, call);

The backend checks the trusted context against its permitted input before returning the README. The summarizer has one executable operation. It doesn't expose a general dispatcher that can select an export function because the proposal happens to name it.

The constructed sequence has these expected observations:

ProposalGate resultDownstream effect
Read the approved READMEAllowedOne input read
Export all private reportsDeniedNone
Read as a different actorDeniedNone
Read a different inputDeniedNone
Approved read with an extra admin propertyRebuilt from the grantOne read, with no admin property forwarded

The selfcheck asserts the exact effect list and forwarded read objects, rather than checking only an error message. A denial after an export had already run would fail that assertion. It also checks that the legitimate installation instruction remains available as source text. The permission repair doesn't depend on deleting every instruction-shaped sentence from the document.

There is no model call here, so this doesn't measure how often a model follows hostile text. The proposed export is supplied directly. This checks the application's response if a model makes that decision, whether prompted by a README, a search result, or a plain mistake.

That separation is useful. You can test authorization deterministically, then run a separate evaluation with representative documents to study model behavior. An unreliable injection attempt shouldn't be the only way to exercise a critical permission check.

An allowed tool can still be too broad

Suppose the gate permits reading an entire account because the summary tool originally needed access to one repository. The model might stay within the tool schema while reaching far more information than the user intended.

Narrow the resource as well as the action. Give the job an input identifier chosen by the application. Check the underlying data access against the same grant. A correctly checked frontend tool is not enough if an internal service accepts arbitrary resource IDs.

For necessary writes, bind approval to the destination and proposed change. A vague “continue” should not become permission for every future external action in the conversation.

Keep the document available as evidence for the summary. Deleting every sentence that sounds like an instruction can also remove legitimate installation notes or quoted examples. The gate doesn't have to decide whether each sentence is malicious. Its job is to preserve the user's permission scope regardless of what the model reads. Separately, the product can show the suspicious passage and explain why a proposed action needs a new decision from the user.

Evaluate the document and the permission system separately

A separate model evaluation can use representative repository documents, including harmless quoted attacks and normal setup instructions. Record the proposed calls and the answer quality. A summarizer that denies every read or discards all installation notes has not met the user's goal. Keep that evaluation separate from the deterministic question of whether a forbidden effect can run.

Authorization also cannot make every allowed output truthful. The README might still persuade the model to write a misleading summary while using only permitted reads. That needs its own model and output evaluation. This example protects the boundary from a proposed action to a private-data effect; it doesn't claim to solve every form of prompt injection.

If a README changes the requested job, the application can still answer no. That answer needs to come from the permission system, even on the day the model is persuaded by the document.