The CIS AWS Foundations Benchmark from the Center for Internet Security is a set of configuration best practices for AWS. Its first section covers identity and access management. This guide checks the main IAM controls with the AWS CLI. Control numbers below are from version 5.0.0, the version AWS Security Hub recommends, with version 3.0.0's in parentheses. Version 5.0.0 dropped 3.0.0's control 1.3, so every IAM control after it moved down one; AWS publishes the full mapping between versions.
Passing these checks is evidence, not certification: only an assessment against the official benchmark text can tell you that.
Start with the credential report
Many controls come from the IAM credential report, a CSV of every user and their passwords, access keys and MFA devices. IAM regenerates it at most every four hours (AWS: credential reports):
aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 --decode > credential-report.csv
The columns used below are password_enabled, password_last_used, mfa_active, access_key_1_active, access_key_1_last_rotated, access_key_1_last_used_date and the same for key 2 (column reference). The root user is the row named <root_account>.
The root user
1.3 (1.4): No root user access key exists. 1.4 (1.5): MFA is enabled for the root user. get-account-summary reports both (GetAccountSummary):
aws iam get-account-summary \
--query 'SummaryMap.{RootAccessKeys: AccountAccessKeysPresent, RootMFA: AccountMFAEnabled}'
You want RootAccessKeys to be 0 and RootMFA to be 1.
1.6 (1.7): Eliminate use of the root user for daily tasks. In the credential report, check the root row's password_last_used and access_key_*_last_used_date.
Passwords
1.7 (1.8): Minimum password length of 14. 1.8 (1.9): Prevent password reuse.
aws iam get-account-password-policy \
--query 'PasswordPolicy.{MinLength: MinimumPasswordLength, Reuse: PasswordReusePrevention}'
If the command returns NoSuchEntity, the account has no password policy at all (GetAccountPasswordPolicy).
Users and their credentials
1.9 (1.10): MFA for every IAM user with a console password. Users with password_enabled true and mfa_active false:
awk -F, 'NR > 1 && tolower($4) == "true" && tolower($8) == "false" { print $1 }' credential-report.csv
1.11 (1.12): Credentials unused for 45 days or more are disabled. Compare password_last_used and each key's access_key_N_last_used_date (for active keys) with today's date.
1.12 (1.13): Only one active access key per user. Users with both access_key_1_active and access_key_2_active true.
1.13 (1.14): Access keys rotated every 90 days or less. Active keys whose access_key_N_last_rotated is more than 90 days ago.
1.14 (1.15): Users receive permissions only through groups. Users with attached or inline policies of their own:
for u in $(aws iam list-users --query 'Users[].UserName' --output text); do
n=$(( $(aws iam list-attached-user-policies --user-name "$u" --query 'length(AttachedPolicies)') \
+ $(aws iam list-user-policies --user-name "$u" --query 'length(PolicyNames)') ))
[ "$n" -gt 0 ] && echo "$u: $n policies attached directly"
done
(ListAttachedUserPolicies, ListUserPolicies)
Policies and analyzers
1.15 (1.16): No policies with full "*:*" administrative privileges. Look for customer-managed policies whose default version allows "Action": "*" on "Resource": "*", for example with get-account-authorization-details and jq, as in the PassRole guide.
1.19 (1.20): IAM Access Analyzer is enabled in every Region. External access analyzers only cover the Region they're created in (AWS), so check each Region you use:
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
echo "$r: $(aws accessanalyzer list-analyzers --region "$r" --query 'analyzers[?status==`ACTIVE`].name' --output text)"
done
Root MFA type, support role, certificates and contacts
1.5 (1.6): Hardware MFA for the root user. A virtual MFA device assigned to the root user means it isn't a hardware key. This lists one if there is one (ListVirtualMFADevices):
aws iam list-virtual-mfa-devices --assignment-status Assigned \
--query "VirtualMFADevices[?ends_with(SerialNumber, 'root-account-mfa-device')].SerialNumber"
1.10 (1.11): No access keys set up with a console user. Users with a console password and an active key that has never been used:
awk -F, 'NR > 1 && tolower($4) == "true" &&
((tolower($9) == "true" && $11 == "N/A") || (tolower($14) == "true" && $16 == "N/A")) { print $1 }' credential-report.csv
1.16 (1.17): A support role exists. Someone should have the AWS-managed AWSSupportAccess policy, ideally a role (ListEntitiesForPolicy):
aws iam list-entities-for-policy --policy-arn arn:aws:iam::aws:policy/AWSSupportAccess
1.18 (1.19): No expired server certificates in IAM. Compare each Expiration with today (ListServerCertificates):
aws iam list-server-certificates \
--query 'ServerCertificateMetadataList[].[ServerCertificateName, Expiration]' --output text
1.2: A security contact is registered. ResourceNotFoundException means there isn't one (GetAlternateContact):
aws account get-alternate-contact --alternate-contact-type SECURITY --query 'AlternateContact.Title'
1.20 (1.21): Users are managed centrally, through identity federation or AWS Organizations, rather than as IAM users in each account. IAM Identity Center is AWS's recommended way to do that (AWS: IAM Identity Center).
Beyond IAM: the monitoring alarms
Section 4 of both versions asks for a CloudWatch alarm on fifteen kinds of high-risk event, from root user activity (4.3) and IAM policy changes (4.4) to AWS Organizations changes (4.15). Security Hub lists these as manual checks (AWS). Each one is a chain, and every link has to be there:
- A multi-Region trail that's logging sends events to a CloudWatch Logs log group:
aws cloudtrail describe-trails --query 'trailList[].[Name, CloudWatchLogsLogGroupArn]'. - A metric filter on that log group matches the events CIS lists:
aws logs describe-metric-filters --log-group-name <log-group>. - An alarm watches the filter's metric:
aws cloudwatch describe-alarms --query "MetricAlarms[?MetricName=='<metric>']". - The alarm's SNS topic has someone subscribed:
aws sns get-topic-attributes --topic-arn <topic> --query Attributes.SubscriptionsConfirmed.
For an organization trail, the log group, filters and alarms are in the account the trail sends its logs to.
Doing this in AccessLens
AccessLens runs these checks in every account you add and maps its findings to CIS AWS Foundations 5.0.0 and 3.0.0 controls (and to SOC 2, ISO 27001, NIST 800-53, PCI DSS 4.0.1 and HIPAA Security Rule subsets):
| CIS 5.0.0 | CIS 3.0.0 | AccessLens rule |
|---|---|---|
| 1.2 | 1.2 | NO_SECURITY_CONTACT |
| 1.3 | 1.4 | ROOT_ACCESS_KEYS_PRESENT |
| 1.4 | 1.5 | ROOT_ACCOUNT_NO_MFA |
| 1.5 | 1.6 | ROOT_HARDWARE_MFA_MISSING |
| 1.6 | 1.7 | ROOT_ACCOUNT_RECENT_USE |
| 1.7, 1.8 | 1.8, 1.9 | PASSWORD_POLICY_MISSING, PASSWORD_POLICY_WEAK |
| 1.9 | 1.10 | USER_WITHOUT_MFA, MFA_NOT_ENFORCED_BY_POLICY |
| 1.10 | 1.11 | ACCESS_KEY_CREATED_AT_SETUP |
| 1.11 | 1.12 | UNUSED_ACCESS_KEY, UNUSED_CONSOLE_PASSWORD |
| 1.12 | 1.13 | MULTIPLE_ACTIVE_ACCESS_KEYS |
| 1.13 | 1.14 | OLD_ACCESS_KEY |
| 1.14 | 1.15 | USER_DIRECT_POLICY_ATTACHMENT |
| 1.15 | 1.16 | FULL_ADMIN_POLICY |
| 1.16 | 1.17 | NO_SUPPORT_ROLE |
| 1.17 | 1.18 | EC2_INSTANCE_NO_ROLE |
| 1.18 | 1.19 | EXPIRED_SERVER_CERTIFICATE |
| 1.19 | 1.20 | ACCESS_ANALYZER_NOT_ENABLED, ACCESS_ANALYZER_INACTIVE |
| 1.20 | 1.21 | ACCOUNT_NOT_IN_ORGANIZATION, IDENTITY_CENTER_NO_PERMISSION_SETS |
| 1.21 | 1.22 | CLOUDSHELL_FULL_ACCESS_ATTACHED |
| 4.1 to 4.15 | 4.1 to 4.15 | One rule per alarm, such as NO_ALARM_ROOT_USAGE and NO_ALARM_IAM_POLICY_CHANGES, each saying which link of the chain is missing, plus CLOUDTRAIL_NO_CLOUDWATCH_LOGS when no trail sends to CloudWatch Logs |
The compliance mapping report lists each control with its active findings, Every control in AccessLens's CIS 3.0.0 and 5.0.0 mappings has at least one rule, including the storage, logging and networking controls this guide doesn't cover (such as 5.0.0's 2.2.4, RDS Multi-AZ). Like this guide, it's a mapping to help with evidence, not an attestation.