Agents and AutomationLesson 40 of 72

Module 5 · Permissions, injection and blast radius

Give it the smallest key that works

In this lesson

  • 8 min read
  • 5 reading sections
  • Knowledge check
  • Lesson 3 of 9 in this chapter

This chapter’s goalDraw the permission boundary for an automation: name what it may touch, what somebody writing into its inputs could make it do, and which actions must stop for a person.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
The union of what its credentials allowA person’s login, borrowedEvery table that person can read, passwordhashes includedSends as them, so the audit log names a humanfor four hundred rows changed at 2amPayroll, because the person who wrote thescript sits in financeRevoked only by disabling their account, sonobody revokes itStill running after they change teams, andafter they leaveA service account per automation, per environmentSELECT granted on three views, not on alltablesIts own mailbox with an empty contacts listA fine-grained token scoped to one repositoryand two permissionsstatement_timeout of ten seconds, so a crossjoin is cancelled not enduredDefault privileges set, so tomorrow’s tablesare covered without widening the roleAn agent’s power is not what its prompt says. Write the union out as plain sentences and the designreview usually finishes itself.
An agent's power is not what its prompt says. Write the union out as plain sentences and the design review usually finishes itself.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 6Free · no account needed
Lesson steps

Write down the union

An agent’s power is not what its prompt says. It is the union of the permissions of every credential its tools hold. Write that union out as a list of plain sentences (can read all customer rows including password hashes; can send email as support@; can reach any host on the internet) and the design review usually finishes itself.

A read-only database role, concretely

SQL
CREATE ROLE agent_ro LOGIN PASSWORD 'use-a-generated-one';
GRANT CONNECT ON DATABASE app TO agent_ro;
GRANT USAGE ON SCHEMA public TO agent_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO agent_ro;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT ON TABLES TO agent_ro;
ALTER ROLE agent_ro SET statement_timeout = '10s';

Two lines there are the ones people miss.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Context Engineering exam.

Stuck on something?Ask Mai, your AI tutor

How to cite: Addaly (2026) ‘Give it the smallest key that works’, in Agents and Automation. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/agents-and-automation/least-privilege-for-agents (Accessed: 29 November 2026).