Long-Lived IAM Access Keys Not Rotated

IAM users hold long-term access keys that have not been rotated for a long time, extending the period in which a leaked key can still be used.

SeverityMedium
CVSS 3.14.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N Open in the calculator
CVSS 4.06.3 CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-324: Use of a Key Past its Expiration Date
OWASP Top 10A04:2025 Cryptographic Failures
MITRE ATT&CKT1078.004 Cloud Accounts, T1552.001 Credentials In Files
CategorySecurity Misconfiguration

Description

IAM user access keys are long-term credentials: an access key ID and secret access key that remain valid until they are deactivated or deleted. One or more active keys have not been rotated within the period set by the organisation's policy, commonly 90 days, as in the CIS AWS Foundations Benchmark. Keys that have not been used for months, and users with two active keys, are often found alongside them.

Long-lived keys tend to spread. They are copied into scripts, CI/CD variables, configuration files, developers' workstations and sometimes source code repositories, where they remain usable long after the person or system that needed them has moved on. Without rotation, a key exposed at any point in that history may still work: an attacker who finds an old key, in a repository, a backup, a decommissioned server or a former employee's device, can call AWS APIs with the user's permissions from anywhere, without MFA unless policies require it. The calls are recorded in CloudTrail, but are hard to tell apart from the key's legitimate use unless source addresses are monitored. The impact depends on the user's permissions: keys belonging to administrative or automation users can give control of the account, while narrowly scoped keys limit what can be done.

The issue is identified from the IAM credential report, which records access_key_1_last_rotated and access_key_1_last_used_date (and the same for the second key) for each user, or with aws iam list-access-keys and aws iam get-access-key-last-used. Prowler, ScoutSuite and Security Hub report keys older than 90 days and keys that are not used.

Remediation

Prefer short-term credentials, and rotate or remove the long-term keys that remain:

  • Replace access keys wherever possible: IAM roles for workloads running on AWS, IAM Identity Center for people using the CLI, OIDC federation for CI/CD systems such as GitHub Actions, and IAM Roles Anywhere for servers outside AWS.
  • Delete keys that are not used, finding them from access_key_1_last_used_date in the credential report or from IAM Access Analyzer unused access findings.
  • Rotate keys that must remain: create a second key, update every place the old key is used, deactivate the old key, confirm that nothing has failed, then delete it.
  • Keep remaining keys in a secrets manager rather than in files or pipeline variables, and give each key's user only the permissions it needs.
  • Monitor key age, for example with the AWS Config managed rule access-keys-rotated, and alert when a key exceeds the agreed period.

Confirm the fix with a new credential report showing no active key older than the agreed period and no active keys that are unused.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More AWS Findings

Every AWS finding