AWS IAM Misconfigurations That Lead to Credential Leaks (And How to Fix Them)
June 9, 2026
Why IAM Misconfigurations Are a Top Cloud Security Risk
Leaked API keys grab headlines, but the quieter threat—overly permissive or poorly structured IAM configurations—is just as dangerous. A single misconfigured IAM role can give an attacker the same access as a stolen root credential, often without triggering any immediate alarms. The worst part: these misconfigurations frequently sit undetected for months because they don't look broken. Everything works—it just works for attackers too.
This guide walks through the most common AWS IAM misconfigurations that lead to credential exposure or privilege escalation, and gives you concrete steps to identify and fix each one.
1. Overly Permissive IAM Policies (The Wildcard Problem)
The fastest way to write a working IAM policy is to use * for both Action and Resource. It's also one of the most dangerous habits in cloud engineering.
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
This is effectively an admin policy. If the identity attached to this policy—a Lambda function, an EC2 instance role, or a CI/CD service account—is ever compromised, the attacker inherits full account access.
How to fix it
- Apply the principle of least privilege: enumerate only the specific actions a role needs (e.g.,
s3:GetObject, nots3:*). - Scope
Resourceto the specific ARN, not*. - Run
aws iam get-account-authorization-detailsand pipe the output into a review to audit all existing policies for wildcards. - Use AWS IAM Access Analyzer to surface policies that grant more access than intended.
2. Long-Lived IAM Access Keys Attached to Human Users
Programmatic access keys (an AKIA… key ID plus a secret) are static credentials. Unlike short-lived tokens, they don't expire unless you explicitly rotate or delete them. Many teams create these keys for developers or automation, then forget about them for years.
Long-lived keys attached to human IAM users compound the risk: if a developer accidentally commits the key to a repo, pastes it in Slack, or stores it in an unencrypted config file, it remains valid indefinitely until someone notices.
How to fix it
- Audit all active access keys:
aws iam generate-credential-report, then download and review the CSV for any key older than 90 days. - For human users, enforce federated identity (SSO via IAM Identity Center) instead of static keys entirely.
- For automation, migrate to IAM roles with instance profiles or OIDC-based short-lived tokens (e.g., GitHub Actions OIDC integration with AWS).
- Set a key rotation policy and enforce it with an AWS Config rule:
access-keys-rotated.
3. Hardcoded Credentials in Lambda Environment Variables
Lambda environment variables are a common shortcut for injecting configuration. But storing an AWS access key, a database password, or a third-party API token as a plain-text environment variable means that credential is visible to anyone with lambda:GetFunctionConfiguration permissions—a surprisingly broad set of people in many organizations.
How to fix it
- Store secrets in AWS Secrets Manager or Parameter Store (SecureString) and fetch them at runtime using the AWS SDK.
- Grant the Lambda execution role only
secretsmanager:GetSecretValueon the specific secret ARN—not on*. - If you must use environment variables, encrypt them with a customer-managed KMS key and restrict
kms:Decrypttightly. - Audit existing functions:
aws lambda list-functionsfollowed byaws lambda get-function-configuration --function-name <name>to inspect what's currently stored in plaintext.
4. Trust Policies That Are Too Broad
An IAM role's trust policy controls who can assume it. A common mistake is setting the principal to the entire AWS account ("AWS": "arn:aws:iam::123456789012:root") or, worse, to "*". This means any identity in the account—or even any authenticated AWS principal in the world—can assume the role if they can reach it.
How to fix it
- Scope trust policies to the exact IAM user, role, or service that needs to assume the role.
- Add a
Conditionblock withaws:PrincipalOrgIDorsts:ExternalIdfor cross-account roles. - Use IAM Access Analyzer regularly to flag roles with public or cross-account trust that you didn't intend.
5. Unused Roles and Keys That Were Never Cleaned Up
Every stale IAM identity is an attack surface. A role created for a deprecated microservice, a key generated for a contractor who left six months ago, or a service account from a decommissioned integration—any of these can be exploited if the corresponding credential ever surfaces in a leaked config or an old backup.
How to fix it
- Use IAM last-accessed information (
aws iam get-role --role-name <name>, look atRoleLastUsed) to identify roles that haven't been used in 60+ days. - Tag every IAM identity with an owner, team, and expiry date as part of your provisioning process.
- Implement a quarterly IAM access review as a SOC 2 CC6.3 control—it satisfies auditors and reduces your blast radius.
Mapping IAM Hygiene to SOC 2 and HIPAA
If your organization is pursuing SOC 2 Type II or HIPAA compliance, IAM hygiene isn't optional—it's directly mapped to specific controls:
- SOC 2 CC6.1 / CC6.3: Logical access controls and access reviews. Least-privilege IAM policies and regular role audits satisfy these directly.
- SOC 2 CC6.7: Transmission and disposal of data. Restricting which roles can access S3 buckets containing customer data is a key evidence artifact.
- HIPAA §164.312(a)(1) – Access Control: Requires unique user identification and emergency access procedures. Static shared keys fail this requirement; federated identity with MFA meets it.
- HIPAA §164.312(a)(2)(iv) – Encryption and Decryption: Storing PHI-adjacent secrets in Secrets Manager with KMS encryption supports this safeguard.
Auditors want evidence—not just intent. Automated scanning that produces a timestamped report of your IAM posture is far stronger than a manual checklist filled out once a year.
A Practical Starting Checklist
- Generate and review the IAM credential report today.
- Enable IAM Access Analyzer in every active region.
- Search your codebase and CI/CD environment variables for any string matching
AKIA[0-9A-Z]{16}—that's the pattern for AWS access key IDs. - Review Lambda and EC2 instance roles for wildcard policies.
- Delete or disable any access key or role with no activity in the past 90 days.
- Migrate static keys to OIDC or instance-profile-based short-lived credentials wherever possible.
IAM misconfigurations are often invisible until something goes wrong. A proactive scan—covering not just your IAM policies but also your repositories and .env files for exposed credentials—gives you a complete picture. You can run a free GhostCred scan to detect exposed secrets and IAM red flags across your environment in about 60 seconds, with findings mapped directly to SOC 2 and HIPAA controls.
Final Thoughts
IAM is infrastructure. Treat it with the same discipline you'd apply to network firewall rules or database access controls. The misconfigurations above aren't exotic edge cases—they appear in real production environments across companies of every size. The good news is that each one is fixable, often in under an hour, and the compounding effect of addressing all five significantly raises the cost for any attacker trying to move laterally through your AWS environment.
See what's exposed in your own code.
Run a free scan