Triage and Remediation
Remediation
Using Console
Using Console
To remediate the issue of SSM document being public in AWS EC2 using the AWS console, follow these steps:
- Login to AWS Console: Go to the AWS Management Console and login with your credentials.
- Navigate to Systems Manager (SSM): Go to the AWS Systems Manager service by typing “Systems Manager” in the search bar and selecting it from the dropdown.
- Access SSM Documents: In the Systems Manager console, navigate to the left-hand menu and click on “Documents” under the “Shared Resources” section.
- Identify Public SSM Documents: Look through the list of SSM documents to identify the ones that are marked as public. These will have a permission setting indicating that they are public.
-
Change Document Permissions:
- Select the public SSM document by clicking on it.
- Click on the “Edit” button to modify the document permissions.
- In the document permissions settings, change the visibility from public to private.
- Save the changes.
- Verify Changes: After changing the permissions, verify that the SSM document is no longer public by checking the permissions settings.
- Monitor for Compliance: Regularly monitor the SSM documents to ensure that they are not set to public in the future.
Using CLI
Using CLI
To remediate the issue of an SSM Document being public in AWS EC2 using AWS CLI, follow these steps:
-
Identify the public SSM Documents: Run the following AWS CLI command to list all public SSM Documents:
-
Update the SSM Document to be private: You will need to update the SSM Document to be private. You can do this by running the following AWS CLI command:
Replace
DOCUMENT_NAME
with the name of the public SSM Document that you want to make private. -
Verify the SSM Document is now private: To confirm that the SSM Document is now private, you can run the following AWS CLI command:
Replace
DOCUMENT_NAME
with the name of the SSM Document you updated.
Using Python
Using Python
To remediate the misconfiguration of having an SSM Document public for AWS EC2 instances using Python, you can follow these steps:aws fsx update-file-system —file-system-id fs-1234567890abcdef0 —backup-id backup-0abcdef1234567890 —windows-configuration AutomaticBackupRetentionDays=30,ThroughputCapacity=8aws fsx describe-file-systems —file-system-ids fs-1234567890abcdef0aws fsx create-backup-policy —file-system-id fs-1234567890abcdef0 —daily-backup-start-time 01:00:00 —automatic-backup-retention-days 30Replace
Remove the “All” option from the document permissions
response = ssm_client.modify_document_permission( Name=document_name, PermissionType=‘Share’, AccountIds=[], SharedDocumentVersion=None ) print(f”Permissions updated for SSM document ''.”)def main():Specify the name of the SSM document to remediate
document_name = ‘your-ssm-document-name’Remediate SSM document permissions
remediate_ssm_document_permission(document_name)if name == “main”: main()-
Configure AWS credentials:
Ensure that you have configured your AWS credentials either by setting environment variables or using AWS CLI
aws configure
command. - Use the following Python script to create a backup plan for FSx in AWS EC2:
'your-file-system-arn1', 'your-file-system-arn2'
with the ARNs of the EFS file systems you want to protect, and 'your-backup-vault-name'
with the name of the backup vault where backups will be stored. This script creates a backup plan for the specified EFS file systems, ensuring they are protected by backups according to the specified schedule and retention policy. Adjust the backup plan settings as needed.