Triage and Remediation
How to Prevent
Using Console
Using Console
To prevent User Console Access Inactive in IAM using the AWS Management Console, follow these steps:
-
Enable Multi-Factor Authentication (MFA):
- Navigate to the IAM dashboard.
- Select “Users” from the left-hand menu.
- Click on the username of the user you want to enable MFA for.
- Under the “Security credentials” tab, click on “Manage” next to “Assigned MFA device.”
- Follow the prompts to assign an MFA device to the user.
-
Set Up Password Policies:
- Go to the IAM dashboard.
- Click on “Account settings” in the left-hand menu.
- Under “Password policy,” click on “Set password policy.”
- Configure the password policy to enforce strong passwords, password expiration, and password reuse prevention.
-
Regularly Review and Rotate Access Keys:
- In the IAM dashboard, select “Users” from the left-hand menu.
- Click on the username of the user whose access keys you want to review.
- Under the “Security credentials” tab, review the access keys and rotate them regularly.
- Ensure that old access keys are deactivated and deleted.
-
Monitor and Audit User Activity:
- Enable AWS CloudTrail to log all API calls made in your account.
- Go to the CloudTrail dashboard.
- Click on “Trails” in the left-hand menu and ensure a trail is created and enabled.
- Configure CloudTrail to send logs to an S3 bucket and enable log file validation.
- Regularly review CloudTrail logs to monitor user activity and detect any inactive or suspicious behavior.
Using CLI
Using CLI
To prevent User Console Access Inactive in IAM using AWS CLI, you can follow these steps:
-
Create an IAM Policy to Enforce MFA:
Ensure that users are required to use Multi-Factor Authentication (MFA) to access the AWS Management Console. This can help in reducing the risk of inactive user accounts being compromised.
-
Attach the Policy to All Users:
Attach the newly created policy to all IAM users to enforce MFA.
-
Set Password Policy:
Set a strong password policy to ensure that users have to change their passwords regularly, which can help in identifying inactive users.
-
Enable CloudTrail Logging:
Enable AWS CloudTrail to log all IAM activities. This will help in monitoring user activities and identifying inactive users.
Using Python
Using Python
To prevent User Console Access Inactive in IAM using Python scripts, you can follow these steps:These scripts will help you monitor and deactivate inactive user console access across AWS, Azure, and GCP. Make sure to replace placeholders like
1. Set Up AWS SDK (Boto3) for AWS:
First, ensure you have the AWS SDK for Python (Boto3) installed. You can install it using pip:2. Create a Script to Monitor and Deactivate Inactive Users:
Here’s a Python script that checks for inactive IAM users and deactivates their console access if they haven’t logged in for a specified number of days.3. Set Up Azure SDK (Azure Identity and Management) for Azure:
First, ensure you have the Azure SDK for Python installed. You can install it using pip:4. Create a Script to Monitor and Deactivate Inactive Users:
Here’s a Python script that checks for inactive Azure AD users and deactivates their console access if they haven’t logged in for a specified number of days.5. Set Up Google Cloud SDK (Google API Client) for GCP:
First, ensure you have the Google Cloud SDK for Python installed. You can install it using pip:6. Create a Script to Monitor and Deactivate Inactive Users:
Here’s a Python script that checks for inactive GCP IAM users and deactivates their console access if they haven’t logged in for a specified number of days.<subscription_id>
and 'path/to/your/service-account-file.json'
with your actual values.