Triage and Remediation
How to Prevent
Using Console
Using Console
To prevent the misconfiguration of not having Multi-Factor Authentication (MFA) enabled for the root account in AWS IAM using the AWS Management Console, follow these steps:
-
Sign in to the AWS Management Console:
- Log in to the AWS Management Console using your root account credentials.
-
Navigate to the IAM Dashboard:
- In the AWS Management Console, go to the Services menu and select IAM (Identity and Access Management).
-
Enable MFA for the Root Account:
- In the IAM Dashboard, you will see a section labeled Security Status. Look for the item that says MFA on your root account.
- Click on the Manage MFA button next to this item.
-
Follow the MFA Setup Wizard:
- Follow the on-screen instructions to set up MFA. You will need to choose the type of MFA device (e.g., virtual MFA device, U2F security key, or hardware MFA device) and complete the setup process by scanning a QR code or entering a code provided by your MFA device.
Using CLI
Using CLI
To prevent the misconfiguration where the root account does not have Multi-Factor Authentication (MFA) enabled in AWS IAM using the AWS CLI, follow these steps:
-
Create a Virtual MFA Device:
First, create a virtual MFA device for the root account. This will generate a QR code that you can scan with an MFA application (like Google Authenticator).
-
Enable MFA for the Root Account:
After scanning the QR code with your MFA application, you will receive two consecutive MFA codes. Use these codes to enable MFA for the root account.
-
Verify MFA Device:
To ensure that the MFA device is correctly associated with the root account, you can list the MFA devices for the root account.
-
Enforce MFA Usage:
Optionally, you can create an IAM policy that enforces the use of MFA for sensitive operations. Attach this policy to the root account or other IAM users as needed.
Using Python
Using Python
To prevent the misconfiguration of not having Multi-Factor Authentication (MFA) enabled for the root account in AWS IAM using Python scripts, you can follow these steps:
-
Install AWS SDK for Python (Boto3):
Ensure you have Boto3 installed in your Python environment. You can install it using pip if you haven’t already.
-
Create a Python Script to Check MFA Status:
Write a Python script that uses Boto3 to check if MFA is enabled for the root account. This script will help you identify if the root account does not have MFA enabled.
-
Automate the Script Execution:
Schedule the script to run at regular intervals using a task scheduler like cron (Linux) or Task Scheduler (Windows) to ensure continuous monitoring.
For example, to run the script every day at midnight using cron, you can add the following line to your crontab:
-
Notify Administrators:
Enhance the script to send notifications (e.g., via email or Slack) if MFA is not enabled. This ensures that administrators are alerted immediately and can take action.