Skip to main content

More Info:

Check if custom role policies are present

Risk Level

Medium

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

How to Prevent

Using Console

To prevent IAM Custom Role Policies from being present in IAM using the AWS Management Console, follow these steps:
  1. Review Existing IAM Roles:
    • Navigate to the IAM Dashboard in the AWS Management Console.
    • Click on “Roles” in the left-hand menu.
    • Review the list of existing roles and identify any custom roles that have policies attached.
  2. Restrict Creation of Custom Roles:
    • Go to the “Policies” section in the IAM Dashboard.
    • Create or update a policy that restricts the creation of custom roles.
    • Attach this policy to IAM users or groups that should not have the ability to create custom roles.
  3. Enable AWS Config Rules:
    • Navigate to the AWS Config service in the AWS Management Console.
    • Set up AWS Config rules to monitor IAM role configurations.
    • Enable rules such as “iam-role-managed-policy-check” to ensure that only managed policies are attached to roles.
  4. Set Up CloudWatch Alarms:
    • Go to the CloudWatch service in the AWS Management Console.
    • Create a new alarm that triggers on specific IAM events, such as the creation of a custom role.
    • Configure the alarm to send notifications to administrators for immediate review and action.
By following these steps, you can effectively monitor and control the presence of IAM Custom Role Policies in your AWS environment.
To prevent IAM Custom Role Policies from being present in IAM using AWS CLI, you can follow these steps:
  1. List Existing IAM Roles: First, identify all the IAM roles in your AWS account to ensure you know which roles are currently configured.
  2. Check for Custom Policies Attached to Roles: For each role, check if there are any custom policies attached. This will help you identify roles that might have custom policies.
  3. Detach Custom Policies from Roles: If you find any custom policies attached to a role, detach them to ensure that no custom policies are present.
  4. Enforce Use of Managed Policies: Ensure that roles only use AWS managed policies or predefined policies by attaching them to the roles.
By following these steps, you can prevent the presence of custom role policies in IAM using AWS CLI.
To prevent IAM Custom Role Policies from being present in IAM using Python scripts, you can follow these steps:
  1. Set Up Environment and Install Required Libraries:
    • Ensure you have the necessary SDKs installed for AWS, Azure, and GCP.
    • For AWS, use boto3.
    • For Azure, use azure-identity and azure-mgmt-authorization.
    • For GCP, use google-cloud-iam.
  2. Authenticate and Initialize Clients:
    • Authenticate and initialize the respective clients for AWS, Azure, and GCP.
  3. Check for Existing Custom Roles:
    • Write scripts to list and check for existing custom roles in each cloud environment.
  4. Prevent Creation of Custom Roles:
    • Implement logic to prevent the creation of custom roles by monitoring and intercepting role creation requests.
Here are the Python scripts for each cloud provider:

AWS (Using boto3)

Azure (Using azure-identity and azure-mgmt-authorization)

GCP (Using google-cloud-iam)

Summary

  1. Set Up Environment and Install Required Libraries: Ensure you have the necessary SDKs installed.
  2. Authenticate and Initialize Clients: Authenticate and initialize the respective clients for AWS, Azure, and GCP.
  3. Check for Existing Custom Roles: Write scripts to list and check for existing custom roles in each cloud environment.
  4. Prevent Creation of Custom Roles: Implement logic to prevent the creation of custom roles by monitoring and intercepting role creation requests.
These scripts will help you monitor and prevent the creation of custom IAM roles in AWS, Azure, and GCP.

Additional Reading: