ARQ Português

Security // Volume 5 of the series

63 IAM users, 41 active keys and 9 belonging to former employees: least privilege at scale on AWS

By André Romão Quinhoneiro · All articles

In a fictional but all-too-common inventory, a company with 14 AWS accounts found 63 IAM users and 41 active access keys. Of those, 17 hadn't been used in over 90 days, 9 belonged to people who had left the company, and 3 had administrator permissions. One of them was sitting in a public repository.

Least privilege in one account is one thing. Across dozens of accounts, with many teams, pipelines and vendors, it's another. This post summarizes chapter 3 of Cloud Security Architecture on AWS, from the From Journey to Practice series.

One rule before anything else

No long-term credentials unless there is no alternative, and then only as a recorded exception. Temporary credentials expire on their own. A key forgotten in a repository keeps working until someone disables it.

Three kinds of identity, three treatments

Kind Examples How it should authenticate
People Developers, operations, security Company identity provider, with MFA, receiving temporary credentials
Company systems ECS, Lambda, pipeline Role attached to the resource or pipeline federation, no stored key
Third parties Vendor tool Role in another account with conditions; keys only as an exception

People: central identity, distributed access

With AWS IAM Identity Center, each person exists in one place, signs in once with MFA, picks an account and a role, and gets temporary credentials. When they leave, they're disabled in the identity provider and lose access to every account at once.

The common mistake is creating a permission set per person or per request. Soon there are hundreds and nobody can review them. The alternative is a small catalog by job function (read-only, development, production operations, security audit, incident response, platform admin), always assigned to groups, never to individuals.

And notice: nobody has standing admin access in production. Production changes come through the pipeline; emergency human actions use temporary, logged access.

Attributes instead of lists

With 9 teams and dozens of accounts, one policy per combination doesn't scale. Attribute-based access control (ABAC) compares a person's attribute with a resource tag:

{
  "Effect": "Allow",
  "Action": ["ecs:UpdateService", "ecs:DescribeServices"],
  "Resource": "*",
  "Condition": {
    "StringEquals": {
      "aws:ResourceTag/team": "${aws:PrincipalTag/team}"
    }
  }
}

The cost: tags become security controls. Whoever can change a resource's tag can change who has access to it, so changing security tags must be restricted too.

Systems: one role per application

Applications get credentials from the role attached to the resource, rotated automatically. The scaling trap is a shared "app-role" holding the sum of every app's permissions: a flaw in any one app grants access to everything.

For external pipelines like GitHub Actions, use OIDC federation and restrict the role's trust:

"Condition": {
  "StringEquals": {
    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
    "token.actions.githubusercontent.com:sub": "repo:company/platform:environment:production"
  }
}

Without the sub condition, any repository on the same provider could try to assume the role.

Third parties: a role with an external ID

For vendors, prefer a role in your account that their account can assume, with an external ID (which prevents the confused deputy problem) and minimal scope.

Know the permission layers

An API call goes through SCPs, RCPs, permission boundaries, session policies, identity policies and resource policies. Simplified rule: the action is allowed only if no layer explicitly denies it and it is allowed within every ceiling. An explicit deny in any layer beats any allow. For cross-account access and resource policies, check the policy evaluation logic in the official documentation and test with the simulation tools.


The full path, from multi-account landing zones to detection, incident response and governance, with case studies and labs, is in Cloud Security Architecture on AWS, volume 5 of the From Journey to Practice series: https://www.amazon.com/dp/B0H7PGZ9PN

How many long-term access keys exist in your company's accounts today? Can anyone answer without looking?

This post summarizes a chapter of Cloud Security Architecture on AWS, volume 5 of the From Journey to Practice series.