Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the unrestricted RDP access issue in AWS, you can follow these steps:
  1. Login to the AWS Management Console.
  2. Navigate to the EC2 service.
  3. Select the EC2 instance(s) for which you want to restrict RDP access.
  4. Click on the “Security Groups” tab in the bottom pane.
  5. Select the security group(s) associated with the instance(s).
  6. Click on the “Inbound Rules” tab.
  7. Locate the rule that allows RDP access from any IP address (0.0.0.0/0).
  8. Click on the “Edit” button next to the rule.
  9. Change the source IP address to a specific IP address or range of IP addresses that are allowed to access RDP.
  10. Click on the “Save” button to apply the changes.
  11. Repeat these steps for all instances that have unrestricted RDP access.
By following these steps, you can remediate the unrestricted RDP access issue in AWS and restrict RDP access to specific IP addresses only.

To remediate the unrestricted RDP access in AWS, you can follow the below steps using AWS CLI:
  1. Open the AWS CLI on your local machine.
  2. Run the below command to list all the security groups in your AWS account.
  1. Identify the security group that allows unrestricted RDP access.
  2. Run the below command to revoke the inbound rule that allows unrestricted RDP access.
Note: Replace <security-group-id> with the ID of the security group identified in step 3.
  1. Verify that the inbound rule has been revoked by running the below command.
Note: Replace <security-group-id> with the ID of the security group identified in step 3.
  1. Repeat steps 3 to 5 for all the security groups that allow unrestricted RDP access.
By following the above steps, you can remediate the unrestricted RDP access in AWS.
To remediate unrestricted RDP access in AWS using Python, you can follow these steps:
  1. Import the necessary AWS SDK libraries in your Python script. You can use the Boto3 library to interact with AWS services.
  1. Initialize the EC2 client using the Boto3 library.
  1. Use the describe_security_groups method to get a list of all security groups in your AWS account.
  1. Loop through the security groups and check if any of them have an inbound rule allowing unrestricted RDP access (port 3389).
  1. Save the Python script and run it to remove the rule that allows unrestricted RDP access in all security groups in your AWS account.
Note: Make sure you have the necessary permissions to modify security groups in your AWS account before running the script.
This Terraform configuration removes any ingress rule that allows TCP port 3389 (RDP) from 0.0.0.0/0 or ::/0 and optionally replaces it with a more restrictive rule; ensure you have an alternative secure access method (VPN, bastion, etc.) before applying, as public RDP access will be lost.If your current configuration has a wider port range that includes 3389 (for example from_port = 1024, to_port = 65535 with cidr_blocks = ["0.0.0.0/0"]), you must remove that entire ingress block and, if needed, add back narrower, more specific rules that do not publicly expose 3389.This change updates the security group in place; it does not force resource replacement.To verify, run terraform plan and confirm:
  • Any existing ingress rule with protocol = "tcp", from_port/to_port including 3389 and cidr_blocks = ["0.0.0.0/0"] and/or ipv6_cidr_blocks = ["::/0"] is shown as being removed.
  • (Optionally) a new, more restrictive ingress rule for port 3389 from specific IP ranges is shown as being added.