In the cloud, the perimeter that matters most is identity, and AWS is no exception: most relevant attack paths go through permissions that are too broad. For example, think of an application that uses a role with administrative access, an old access key leaked in a repository, or a user who kept piling up policies without anyone reviewing them. With loose IAM, a single entry point is enough to compromise the whole account.
You can structure IAM around least privilege without stalling operations, as long as you start with the basics of credentials and MFA and know the privilege escalation paths, the ones where a harmless-looking permission turns into full access. Then comes the periodic review, which has to fit the team routine or it will be abandoned. The goal is to shrink the blast radius of any compromised credential and keep access auditable. Chasing the perfect configuration usually goes wrong, because it becomes impossible to maintain.
Least privilege in practice
Least privilege means granting only the permissions a specific task requires, and nothing beyond that. The first step is taking policies like AdministratorAccess out of everyday use and replacing long-lived credentials with temporary roles. Applications running on EC2, ECS, or Lambda should assume roles and never carry embedded access keys.
Conditions let you restrict the context in which a permission applies. You can require MFA for sensitive actions, for example, or limit a role to a network source or a specific tag. A stolen credential then loses much of its value, because it only works inside the expected context. A condition snippet that requires MFA looks like this:
"Effect": "Deny","Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" }}For actions that should never happen, use an explicit deny. A Deny always wins over an Allow, so a policy that denies disabling audit trails, deleting KMS keys, or changing organization controls keeps protecting the environment even when another policy grants the permission by mistake.
Privilege escalation paths
With least privilege, taking AdministratorAccess out of circulation is only the beginning. Some permissions look harmless on their own but let a limited identity turn itself into an administrator. A policy can look restricted and still contain one of these paths, so it pays to know them. The goal here is defensive: knowing where they are so you can close them.
- Anyone who can attach policies to themselves, with iam:AttachUserPolicy or iam:PutUserPolicy, can grant themselves any permission
- With iam:CreatePolicyVersion and SetDefaultPolicyVersion, an identity can rewrite a policy that is already attached
- iam:PassRole combined with permission to create resources (Lambda, EC2, ECS) lets an identity inherit a more powerful role
- iam:CreateAccessKey on another user generates credentials for an identity with more access
- Anyone who can change the trust policy of an administrative role can assume it from an identity they control
Note that all these cases have something in common: the identity can change its own authorization or pass along a privileged role. The fix follows the same logic. Restrict the actions in the iam namespace and put conditions on iam:PassRole, so that only the expected roles can be passed. IAM Access Analyzer helps on both ends: it validates policies and generates new ones from actual usage, which lets you find overly broad grants before they become an escalation path.
Credentials, MFA, and federation
Long-lived access keys are the most dangerous asset in IAM. They leak in repositories, logs, and container images, and they do not expire on their own: a leaked key keeps working until someone deactivates it. For human access, prefer federation through IAM Identity Center, with temporary sessions. For machine access, use roles. When an access key is unavoidable, rotate it periodically and keep an eye on its last-used date.
MFA should be mandatory on the root account and on all privileged human access. The root account should have no access keys and should only come into play for the tasks that require root, always with strong MFA and with the credentials stored in a safe place.
Continuous permission review
Without review, permissions only grow: every project adds something and nobody takes anything away. IAM Access Analyzer flags unintended external access, and last accessed information shows permissions that were granted and never used. Policies that have never been exercised are natural candidates for removal.
- Prefer policies managed by the organization over inline policies scattered across identities
- Use permission boundaries to set a ceiling for whoever creates roles
- Apply SCPs to block dangerous actions in every account of the organization
- Treat wildcards in Action and Resource as exceptions, with the justification on record
Detecting abuse as well as preventing it
Prevention and detection go together. Set up alerts for the CloudTrail events that often signal escalation or preparation for persistent access, such as access key creation, policy attachment, changes to the trust policy of a role, root account use, and repeated AssumeRole failures. Ideally, the escalation path is already closed. When something gets through anyway, a fast alert is what shortens the response time.
Practical checklist
- Enable MFA on the root account and remove the root access keys
- Require MFA for all privileged human access
- Replace users with access keys by federation through IAM Identity Center
- Have applications assume roles instead of carrying access keys
- Take AdministratorAccess out of everyday use
- Restrict the actions in the iam namespace and limit iam:PassRole to the expected roles
- Explicitly deny the actions that should never happen, such as disabling auditing
- Apply permission boundaries to whoever creates identities
- Define SCPs that block dangerous actions across the organization
- Review permissions with last accessed data and remove what was never used
- Run IAM Access Analyzer to find unintended external access
- Create alerts for key creation and policy changes recorded in CloudTrail
- Rotate and monitor the use of any access keys that still exist
Best practices
- Model access by role and job function, not person by person
- Use conditions (MFA, source, tag) to restrict the context of roles
- Prefer temporary sessions over long-lived credentials
- Document the reason for any broad permission that has to exist
- Keep policies versioned as code and apply only changes that were reviewed and approved
- Watch CloudTrail for user and key creation and for policy changes
Common mistakes
- Applications with embedded access keys
- The key ends up leaking in a repository or an image and gives persistent access that is hard to detect.
- AdministratorAccess for day-to-day tasks
- Any compromise turns into full control of the account.
- Root account with active access keys
- It exposes the highest level of privilege, which cannot be limited by policy.
- Wildcards in Action and Resource by default
- They grant much more than necessary and make auditing harder.
- Permissions that are never reviewed
- Forgotten access piles up and widens the blast radius of any incident.
Authorship and review
Cesar Gargiulo
CEO and founder of GUARDIASEC. Technical and editorial lead for the content published in this library.
Published on . Found a technical error? Write to [email protected] and we will correct it and keep a record of the change.