This rule ensures that IAM users are granted permissions solely through groups, enhancing security measures.
Rule | Ensure IAM Users Receive Permissions Only Through Groups |
Framework | cis_v130 |
Severity | ✔ Medium |
Ensure IAM Users Receive Permissions Only Through Groups for cis_v130
Description
This rule refers to a security best practice from the Center for Internet Security (CIS) benchmarks version 1.3.0, specifically designed for AWS IAM (Identity and Access Management) configurations. The practice ensures that IAM users do not receive permissions directly through individual user policies but instead inherit them through membership in IAM groups. This model promotes better management of permissions and adherence to the principle of least privilege by categorizing permissions into groups with specific roles or access requirements.
Troubleshooting Steps
If there is a violation of this rule, it means that one or more IAM users have been assigned permissions directly rather than through a group. The following steps can be used to troubleshoot and correct the issue:
List Users with Direct Permissions:
Review User Policies:
Create or Identify Appropriate IAM Groups:
Recreate Permissions in the Groups:
Attach Users to Their Relevant Groups:
Remove Directly Attached Policies:
Necessary AWS CLI Commands
Here are the command-line steps to identify users with directly attached policies and to remediate the rule:
List IAM Users with Attached Policies:
aws iam list-users | \ awk '/UserName/{print $2}' | \ xargs -I {} aws iam list-attached-user-policies --user-name {} | \ grep PolicyArn
This command sequence lists all users with their attached policy ARNs.
Create IAM Group with Required Permissions:
aws iam create-group --group-name YourGroupName
Replace
YourGroupName
with the desired name for the IAM group that will contain the appropriate permissions.Attach Policy to Group:
aws iam attach-group-policy --group-name YourGroupName --policy-arn arn:aws:iam::aws:policy/PolicyName
Replace
YourGroupName
with your group's name and PolicyName
with the relevant policy to attach to the group.Add User to Group:
aws iam add-user-to-group --group-name YourGroupName --user-name UserName
Replace
YourGroupName
with the group's name and UserName
with the user's name.Detach Directly Attached User Policies:
aws iam detach-user-policy --user-name UserName --policy-arn arn:aws:iam::aws:policy/PolicyName
Replace
UserName
with the user's name and PolicyName
with the policy to be detached from the user.Remove Inline Policies:
aws iam delete-user-policy --user-name UserName --policy-name InlinePolicyName
Replace
UserName
with the user's name and InlinePolicyName
with the inline policy to be removed.Step by Step Guide for Remediation
Follow these steps to ensure IAM users receive permissions only through groups:
Audit Current IAM Users and Policies: Utilize the necessary AWS CLI commands to list all users with their attached policies.
Group Creation and Configuration: Identify the required roles and permissions, then create IAM groups aligning with each set of responsibilities.
Policy Attachment: Attach the relevant policies to the newly created IAM groups, ensuring they replicate the permissions formerly assigned directly to users.
User Group Association: Add IAM users to their respective newly created groups to provide them with the necessary permissions.
Remove Direct Assignments: Detach any directly attached policies from the users and remove any inline policies, leaving the users with permissions solely from their group memberships.
By following these detailed descriptions and steps, you can maintain a more secure AWS IAM setup that aligns with CIS benchmarks for the segregation of privileges and streamline access management within your organization, thus enhancing overall security posture.