Skip to main content

Triage and Remediation

How to Prevent

Using Console

To prevent users from having inline policies in AWS IAM using the AWS Management Console, follow these steps:
  1. Navigate to IAM Dashboard:
    • Sign in to the AWS Management Console.
    • In the navigation bar, select “Services” and then choose “IAM” to open the IAM dashboard.
  2. Review User Policies:
    • In the IAM dashboard, select “Users” from the navigation pane.
    • Click on each user to review their permissions.
    • Under the “Permissions” tab, check for any inline policies attached directly to the user.
  3. Remove Inline Policies:
    • For each user with an inline policy, click on the “Inline Policies” section.
    • Select the inline policy and choose “Delete Policy” to remove it.
  4. Use Managed Policies:
    • Instead of using inline policies, attach AWS managed policies or create and attach customer-managed policies.
    • Go to the “Permissions” tab for each user, click “Add permissions,” and then choose “Attach policies directly.”
    • Select the appropriate managed policies and click “Next: Review” and then “Add permissions.”
By following these steps, you can ensure that users do not have inline policies, promoting better policy management and security practices.
To prevent users from having inline policies in IAM using AWS CLI, you can follow these steps:
  1. Create a Managed Policy:
    • Instead of using inline policies, create a managed policy that can be attached to multiple users, groups, or roles.
    • Use the following command to create a managed policy:
  2. Attach Managed Policy to Users:
    • Attach the newly created managed policy to the users who need it.
    • Use the following command to attach the policy to a user:
  3. List Inline Policies for Users:
    • Regularly check for any inline policies attached to users to ensure compliance.
    • Use the following command to list inline policies for a specific user:
  4. Set Up IAM Policy to Restrict Inline Policies:
    • Create an IAM policy that denies the creation of inline policies for users.
    • Use the following command to create a policy that restricts inline policies:
By following these steps, you can prevent users from having inline policies in IAM using AWS CLI.
To prevent users from having inline policies in IAM using Python scripts, you can follow these steps:

1. AWS (Boto3 Library)

Step 1: Install Boto3 Ensure you have the Boto3 library installed. You can install it using pip if you haven’t already:
Step 2: List Users and Check for Inline Policies Use the following script to list all IAM users and check if they have any inline policies. If they do, you can log or take appropriate action.

2. Azure (Azure SDK for Python)

Step 1: Install Azure Identity and Management Libraries Ensure you have the Azure Identity and Management libraries installed:
Step 2: List Users and Check for Inline Policies Use the following script to list all users and check if they have any inline policies.

3. GCP (Google Cloud Client Library for Python)

Step 1: Install Google Cloud IAM Library Ensure you have the Google Cloud IAM library installed:
Step 2: List Users and Check for Inline Policies Use the following script to list all users and check if they have any inline policies.

Summary

  1. AWS: Use Boto3 to list users and check for inline policies.
  2. Azure: Use Azure SDK to list users and check for role assignments.
  3. GCP: Use Google Cloud IAM library to list service accounts and check for IAM policies.
These scripts will help you identify users with inline policies, allowing you to take further action to prevent such configurations.