Day 11 of 1460 minShell WalkerHands-on lab

Day 11: Excessive Agency and Least Privilege for Coding Agents

Taught by Mr Elite Updated

By the end of today you can

  • Explain excessive functionality, permissions and autonomy with one example of each
  • Estimate the blast radius of an agent from its permission file
  • Rewrite a permissive agent configuration into a minimal allowlist
  • Justify each removed permission in one sentence

Warm-up

Answer from memory first, then tap to check. Recalling yesterday is what makes it stick.

In a confused deputy attack, whose authority does the agent use, and for whom?

It uses its own authority on behalf of a caller who lacks that authority.

Where should the user's identity come from when a tool call is checked?

From the session, never from a field the model writes.

Picture a coding agent asked to fix one failing test in a payments service. It reads the issue, and buried in the issue text is a hidden instruction. Yesterday you saw that an agent can be steered into using power it holds. Today we ask a more useful question: how much power does it hold in the first place?

You cannot make an agent immune to injection. You can make sure that when one lands, there is almost nothing worth stealing or breaking. That is least privilege, and it is the control that works even when every other control fails.

Three ways an agent has too much

The OWASP community calls this problem excessive agency. It means the agent can do more than its task needs, and there are three separate ways that happens. I find it easiest to check each one on its own, because the fix for each is different.

Excessive functionality
The agent has tools it does not need, such as a shell and a web fetcher when it only edits files.
Excessive permissions
A tool the agent does need runs with more rights than the task requires, such as a database login with admin rights when the task only reads one table.
Excessive autonomy
The agent takes risky actions with no human check, such as pushing code or deleting files unprompted.

A fix-a-test task needs to read source files, edit a few files, and run the test command. That is all. Anything beyond that is risk with no benefit, and the risk is easy to miss because the extra power sits unused on a normal day.

Here is how I tell the three apart at a glance. If I would delete the tool entirely, it is functionality. If I would keep the tool but shrink what it can touch, it is permissions. If I would keep both but put a person in front of the action, it is autonomy.

Quick check

A coding agent only edits files, but it also has a tool that sends HTTP requests to any URL. Which problem is this?

Blast radius thinking

Blast radius is how much damage follows if the agent is hijacked. Do not ask whether it will be hijacked. Assume it will, then ask what the attacker gets. That changes how you read a permission file, because you stop reading it as a list of features and start reading it as a list of things an attacker could do.

For each permission, I ask three things. What is the worst thing this lets an attacker do? Does the task actually need it? Could a narrower version do the same job? A permission that fails the second question goes. One that fails only the third gets narrowed.

Take the entry run:*. The worst case is that an attacker runs any command as you: read your keys, upload them, delete the repository. The task needs only the test command, so this fails question two and is removed. Now take write:**. The task does need to write, but only under src, so it fails question three and is narrowed to write:src/**.

Scoped credentials, sandboxes and allowlists

There are three practical tools. A scoped credential is a token that can do one narrow thing, such as read one repository, and expires soon. A sandbox is a walled-off place to run commands, such as a container with no network and no access to your home folder. An allowlist names what is permitted and denies everything else.

Scoped credentials matter because agents often inherit whatever token is lying around in the environment. If that token is your personal one, a hijacked agent acts as you everywhere. If it is a read-only token for one repository that expires in an hour, a stolen copy is nearly worthless.

Prefer allowlists to denylists. A denylist tries to name every bad command and always misses one. An allowlist only needs you to know the few good ones.

Many coding agents keep this in a settings file. The exact names differ by product, so treat the next snippet as a typical shape rather than a specific tool's syntax.

json
{
  "allow": ["read:src/**", "write:src/**", "run:pytest tests/"],
  "deny": ["read:.env", "read:~/.ssh/**", "run:curl *", "run:git push *"],
  "network": false,
  "ask_before": ["write:**"]
}
A minimal permission file: narrow reads and writes, one test command, no network, secrets denied, and a prompt before writes.

The sandbox idea is easy to see for yourself if you have Docker installed. This is optional and harmless. It starts a throwaway container with networking switched off and tries to fetch a web page from inside it.

bash
docker run --rm --network none alpine wget -T 3 -O- http://example.com
Runs a disposable container with no network. The --rm flag deletes it afterwards. Expect the request to fail with a message like: wget: bad address 'example.com'.

That failure is the point. Whatever command an injected instruction runs inside such a box, it has no route to send your data out. If you do not have Docker, skip this and read the output above, since the lab covers the same idea.

Quick check

Why is an allowlist usually safer than a denylist?

Watch me do it: audit a permissive config

Let me show you the method on a file on your own machine. Nothing here touches any real system. We build a deliberately over-permissive config, then shrink it, and I will say what you should see at each step. You need a terminal and the jq tool, which checks JSON. If jq is missing, install it with sudo apt install jq on Debian or Ubuntu, or brew install jq on a Mac.

bash
mkdir -p ~/day11 && cd ~/day11
cat > before.json <<'EOF'
{
  "allow": ["read:**", "write:**", "run:*"],
  "network": true,
  "ask_before": []
}
EOF
cat before.json
Creates before.json with allow-everything settings. The last command prints it back so you can confirm it saved.
bash
cat > after.json <<'EOF'
{
  "allow": ["read:src/**", "read:tests/**", "write:src/**", "run:pytest tests/"],
  "deny": ["read:.env", "read:~/.ssh/**"],
  "network": false,
  "ask_before": ["write:**"]
}
EOF
diff before.json after.json; jq . after.json > /dev/null && echo valid
Writes the minimal file, shows the differences, and uses jq to confirm it is valid JSON. You should see the diff and then the word valid.

Look at what the diff tells you. The three wide allow entries are gone, network flipped from true to false, and two new safeguards appeared. Every line in that diff should map to a reason you can say out loud. That is the habit I want you to build.

Lab: Coding Agent Blast Radius

Now you do it against the real thing. The lab gives you an agent that is about to fix a failing test in a payments service. The issue it reads contains a hidden instruction, and its permissions allow everything. Your job is to tighten the permissions so the task still works but the hidden instruction cannot do harm. Work only inside the lab environment.

Use the same method you just practised. Read first, score each permission, cut the widest ones, then rerun to prove the task still passes. If you cut too much and the test fix breaks, that is useful information about which permission the task truly needs. Add that one back in its narrowest form, and keep notes as you go because the mission uses them.

Your turn

Coding Agent Blast Radius

This lab puts blast radius thinking into practice on a realistic setup. You act as the security engineer: read the issue, judge what the task truly needs, and cut the rest, so the same injection that would have worked now hits a wall.

Open the lab in a new tab

What to try

What to notice

  • Which single permission would have turned the injection into real damage
  • Whether narrowing a path or command was enough, or the whole tool had to go
  • What the agent does when it is denied an action it was told to take

If it did not work

Removing permissions until the task breaks, then adding them all back

Remove one at a time and rerun the task. Restore only the specific one that failed, in its narrowest form.

Using a denylist of dangerous commands

Switch to an allowlist of the exact commands the task needs. Anything unlisted is then blocked.

Narrowing the agent but leaving a broad token in the environment

Check environment variables and config files for credentials the agent can read, and replace them with scoped, short-lived ones.

Relying on the approval prompt instead of removing the capability

Remove what is not needed. Approval prompts can be spoofed or clicked through, as we will see on Day 12.

Recap

  • Excessive agency has three parts: functionality, permissions and autonomy
  • Assume hijack and measure blast radius, not likelihood
  • Allowlists fail safe, denylists fail open
  • Scoped, short-lived credentials limit what a stolen token is worth
  • Sandboxes with no network stop many exfiltration routes outright
  • Every removed permission should have a one-sentence reason

Cheat sheet

Blast radius
Damage possible if the agent is hijacked
Allowlist
Only named actions permitted, all else denied
Scoped credential
Token limited to one narrow task and a short life
Sandbox
Isolated environment, ideally no network and no home folder
ask_before
Actions that need human confirmation
diff before after
Shows exactly what you removed
jq . file.json
Checks that a JSON file is valid

Before the next day

Mission: Permission before and after

Finish the lab, then record what you changed and why. A permission change you cannot justify in one sentence is a change you do not yet understand, and the justification is what a reviewer will want to read.

About 30 min

You are done when: A day11 folder with before and after permission settings and day11-permissions.md holding one justification sentence per removal.

Want more? Add a short section on which remaining permission is the riskiest and what sandbox or scoped credential would shrink it further.

Quiz

4 questions. Your score is saved with your progress.

1. An agent edits files, but its database login has admin rights. Which problem is this?

2. Why does blast radius thinking assume the agent will be hijacked?

3. Which setting best limits data exfiltration from a coding agent's shell?

4. Your agent still needs to run tests. What is the best way to permit that?

Finish the day

Mark the day complete to save your progress.

Go to Day 12

Next: Day 12 looks at human approval prompts. Today you removed what the agent did not need. Tomorrow we test the approvals on what remains and see how they can be spoofed.

Tell someone you are doing this:WhatsAppXLinkedIn

Your notes

Private to this device. Write what you want to remember from today.