StoicBuilder

HandbookXIV the VallumLeast privilege

XIVthe Vallum, Defend it

Least privilege

1 min readUpdated 28 November

In plain words

Least privilege means every account, service, token and agent gets only the permissions its job requires, for only as long as it needs them, so a mistake or a stolen key can do limited damage.

Where you see it

Harbor's invoice worker connects to Postgres as the database owner, so a bug in it could drop any table. A role that can read orders and write invoices, and nothing else, turns that disaster into a failed query.

migrations/0042_invoice_worker_role.sqldatabase
create role invoice_worker login; -- password set from the secret managergrant select on orders, customers to invoice_worker;grant select, insert, update on invoices to invoice_worker;-- no delete, no other tables, no schema changes
The worker can do its job and nothing else. If it's ever compromised, so is only this much.

What goes wrong

  1. One master key for everything

    When every service shares the admin database login or a cloud key with full access, a leak anywhere is a leak everywhere. Give each service its own credentials, scoped to what it touches.

  2. Access that only ever grows

    People change teams and keep their production access, and old tokens keep working years later. Review access every quarter, and make tokens expire by default.

  3. Agents with all of your permissions

    An agent running with your cloud credentials or the database owner login can do anything you can, including by mistake. Give it a scoped role, read-only where possible, and approve destructive commands yourself.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
List every credential this system uses, including database roles, cloud IAM roles, API keys and CI tokens, and what each can actually do, then compare that with what the code needs. Propose narrower roles and policies for each, starting with anything that can delete data or change permissions.

Quick check

Sign in to earn +10 XP for it

Harbor's invoice worker is compromised through a vulnerable dependency. Which setup limits the damage most?

Got a prompt that touches least privilege?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.