Agent Wranglers

INF-18Required

Give every role the least it needs

Write every role's permissions in code, limited to named actions on named resources. Never grant every action on every resource, except to the break-glass role.

How to do it

Start from the actions the service calls and the resources it touches. Name them, such as s3:GetObject on one bucket. Use the cloud's access analysis, such as IAM Access Analyzer or Google's IAM recommender, to find permissions unused for 90 days and remove them. Give the rebuild drill and yearly jobs their own roles, tagged purpose = drill or purpose = yearly, and leave those out of the 90-day check. Some actions accept only * as the resource, such as ec2:DescribeInstances. Name each such action in its own statement with * as the resource. Grant roles to groups, never to single people. Which person holds which group is the role matrix in Keep roles as code. App keys follow the same limit in Give each key the least power.

Examples

Terraform example

data "aws_iam_policy_document" "invoice_reader" {
  statement {
    actions   = ["s3:GetObject"]
    resources = ["arn:aws:s3:::example-shop-invoices/*"]
  }
}

How to check

A code scan, such as Checkov, finds no statement that allows * actions or a whole service, such as s3:*, on * resources. The break-glass role is the only exception. Every statement with * as the resource names only actions that accept no narrower resource. The access analyzer lists no unused permission older than 90 days, outside roles tagged purpose = drill or purpose = yearly.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/infrastructure/identity-and-access/least-privilege-roles">Agent Wranglers infrastructure and environments playbook</a>. In code you write, add a comment next to it with the same link.