Ensure access keys are rotated every 90 days or less
Description
Access keys consist of an access key ID and secret access key, which are used to sign programmatic requests to AWS. IAM users require access keys to make programmatic calls via the AWS CLI, SDKs, or APIs. It is recommended that all access keys be rotated regularly and at least every 90 days.
Rationale
Rotating access keys reduces the window of opportunity for a compromised or exposed key to be used. Regular rotation also limits the risk associated with lost, stolen, or improperly stored credentials.
Impact
Long-lived access keys increase the risk of unauthorized access if compromised, as they may remain valid indefinitely without detection.
Audit Procedure
Using AWS Console
- Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam
- Click on
Users - For each user, go to
Security Credentials - Review each key under
Access Keys - For each key with
Status = Active, ensure theCreateddate is within90 days
Using AWS CLI
- Run the following commands:
aws iam generate-credential-report
aws iam get-credential-report --query 'Content' --output text | base64 -d
- Review the following fields:
access_key_1_last_rotatedaccess_key_2_last_rotated
- Ensure all active keys have been rotated within
90 days
Expected Result
All active access keys should have a last_rotated date within the last 90 days. No access key should be older than 90 days.
Remediation
Using AWS Console
Perform the following to rotate access keys:
- Sign in to the AWS Management Console and open the IAM console (https://console.aws.amazon.com/iam)
- Click on
Users - Select the user
- Navigate to
Security credentials
Rotate Access Keys:
- Click
Create accesskey - Update all applications and tools to use the new access key
- After confirming successful use of the new key:
- Deactivate the old key
- Delete the old key when no longer needed
Using AWS CLI
- Create a new access key:
aws iam create-access-key --user-name <user-name>
Update all applications and tools to use the new access key
Check usage of the old key:
aws iam get-access-key-last-used --access-key-id <access-key-id>
- Deactivate the old key:
aws iam update-access-key --access-key-id <access-key-id> --status Inactive --user-name <user-name>
- After confirming no usage, delete the old key:
aws iam delete-access-key --access-key-id <access-key-id> --user-name <user-name>
Default Value
By default, AWS does not enforce access key rotation. Access keys remain valid until manually deactivated or deleted.
References
- CCE-78902-4
- https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#rotate-credentials
- https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_finding-unused.html
- https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html
- https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html
CIS Controls
| Controls Version | Control | IG 1 | IG 2 | IG 3 |
|---|---|---|---|---|
| v8 | 5.1 Establish and Maintain an Inventory of Accounts - Establish and maintain an inventory of all accounts managed in the enterprise. The inventory must include both user and administrator accounts. The inventory, at a minimum, should contain the person's name, username, start/stop dates, and department. Validate that all active accounts are authorized, on a recurring schedule at a minimum quarterly, or more frequently. | x | x | x |
| v7 | 16.1 Maintain an Inventory of Authentication Systems - Maintain an inventory of each of the organization's authentication systems, including those located onsite or at a remote service provider. | x | x |
MITRE ATT&CK Mappings
| Techniques / Sub-techniques | Tactics | Mitigations |
|---|---|---|
| T1078.004 | TA0006 | M1018 |
Profile
Level 1 | Automated