Ensure IAM users receive permissions only through groups
Description
IAM users are granted access to services, functions, and data through IAM policies. There are four ways to assign policies to a user:
- Attach an inline (user) policy directly to the user
- Attach a managed policy directly to the user
- Add the user to an IAM group with attached policies
- Add the user to an IAM group with inline policies
Only assigning permissions through IAM groups is recommended.
Rationale
Assigning IAM policies through groups centralizes permissions management and aligns access with organizational roles. This reduces complexity and lowers the likelihood of excessive or inconsistent permissions.
Impact
Directly assigning policies to users increases the risk of misconfigured or excessive permissions and makes access management more difficult to audit and maintain.
Audit Procedure
Using AWS CLI
- Run the following command to list all IAM users:
aws iam list-users --query 'Users[*].UserName' --output text
- For each user returned, run:
aws iam list-attached-user-policies --user-name <user-name>
aws iam list-user-policies --user-name <user-name>
- If any policies are returned, the user has either:
- A directly attached managed policy, or
- An inline policy
Expected Result
For each IAM user, both list-attached-user-policies and list-user-policies should return empty results. All permissions should be assigned through IAM groups only.
Remediation
Using AWS Console
Create and configure a group:
- Sign in to the AWS Management Console and open the IAM console (https://console.aws.amazon.com/iam/)
- In the navigation pane, click
User Groupsand then clickCreate Group - Enter a group name and click
Next - Select the appropriate policies
- Click
Create Group
Add users to the group:
- Navigate to
User Groups - Select the group
- Click
Add usersto group - Select users and click
Add users
Remove direct user policies:
- Navigate to
Users - Select the user
- Go to the
Permissionstab - Remove any directly attached policies
Using AWS CLI
- Create a group:
aws iam create-group --group-name <group-name>
- Attach a policy to the group:
aws iam attach-group-policy --group-name <group-name> --policy-arn <policy-arn>
- Add user to group:
aws iam add-user-to-group --user-name <user-name> --group-name <group-name>
- Detach managed policies from user:
aws iam detach-user-policy --user-name <user-name> --policy-arn <policy-arn>
- Delete inline policies from user:
aws iam delete-user-policy --user-name <user-name> --policy-name <policy-name>
Default Value
By default, AWS allows IAM policies to be attached directly to users, groups, or roles. There are no restrictions preventing direct user policies unless enforced through organizational standards.
References
- http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html
- http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html
- CCE-78912-3
CIS Controls
| Controls Version | Control | IG 1 | IG 2 | IG 3 |
|---|---|---|---|---|
| v8 | 6.8 Define and Maintain Role-Based Access Control - Define and maintain role-based access control, through determining and documenting the access rights necessary for each role within the enterprise to successfully carry out its assigned duties. Perform access control reviews of enterprise assets to validate that all privileges are authorized, on a recurring schedule at a minimum annually, or more frequently. | 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 | TA0007, TA0008, TA0043 | M1018 |
Profile
Level 1 | Automated