Control: 1.6 Ensure access keys are rotated every 90 days or less
Description
An access key consists of an access key ID and a secret, which are used to sign programmatic requests that you make to Alibaba Cloud. RAM users need their own access keys to make programmatic calls to Alibaba Cloud from the Alibaba Cloud SDKs, CLIs, or direct HTTP/HTTPS calls using the APIs for individual Alibaba Cloud services. It is recommended that all access keys be regularly rotated.
Remediation
Perform the following to determine if access keys are rotated within 90 days:
From Console
- Logon to RAM console.
- In the left-side navigation pane, click
UsersunderIdentities. - In the
User Logon Name/Display Namecolumn, click the username of the target RAM user. - In the
User AccessKeyssection, clickCreate AccessKey. - Click
OKto create a new AccessKy pair for rotation. - Update all applications and systems to use the new AccessKey pair.
- Disable the original AccessKey pair by following below steps:
- Log on to RAM console.
- In the left-side navigation pane, click
UsersunderIdentities. - On the
Userspage, click username of the target RAM user in theUser Logon Name/Display Namecolumn. - In the
User AccessKeyssection, find the targetAccessKeypair and click Disable.
- Confirm that your applications and systems are working.
- Delete the original AccessKey pair by following below steps:
- Log on to RAM console.
- In the left-side navigation pane, click Users under Identities.
- In the
User Logon Name/Display Namecolumn, click the username of the target RAM user. - In the User
AccessKeyssection, find the target access keys and ClickDelete. - In the dialog box that appears, select I am aware of the risk and confirm the deletion.
- Click OK.
From Command Line
- Run the following command to delete an access key:
aliyun ram DeleteAccessKey --UserAccessKeyId <access_key_ID> --UserName <ram_user >
- Run the following command to disable an active access key:
aliyun ram UpdateAccessKey --UserAccessKeyId <access_key_ID> --Status Inactive --UserName <ram_user>
- Run the following command to delete an access key:
aliyun ram DeleteAccessKey --UserAccessKeyId <access_key_ID> --UserName <ram_user >
Usage
Run the control in your terminal:
powerpipe control run alicloud_compliance.control.cis_v100_1_6Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run alicloud_compliance.control.cis_v100_1_6 --shareSQL
This control uses a named query:
select 'acs:ram::' || account_id || ':user/' || user_name || '/accesskey/' || access_key_id as resource, case when create_date <= (current_date - interval '90' day) then 'alarm' else 'ok' end as status, user_name || ' ' || access_key_id || ' created ' || to_char(create_date , 'DD-Mon-YYYY') || ' (' || extract(day from current_timestamp - create_date) || ' days).' as reason , account_id as account_idfrom alicloud_ram_access_key;