Description
Allow TCP 3389 only on hosts that need RDP, and only from approved management ranges or source security groups. Establish the management path, such as a VPN, first.
Potential impact
External clients can attempt to sign in when public addressing, routing and the RDP listener permit it. Compromised accounts or weak host controls can expose the server and its data.
Remediation
Check IPv4 and IPv6 rules across attached groups, the host firewall and authentication. Test the approved path, remove the public grant, then verify a new management connection and rejection from an unapproved source. Review authentication logs for unusual attempts.
Examples
Configure AWS credentials in the execution environment and supply vpc_id and management_cidr. Both tasks manage the same group. With the default purge_rules: true, include every existing ingress rule that should remain.
Before
- name: Configure the RDP security group
amazon.aws.ec2_security_group:
name: example2
description: an example EC2 group
vpc_id: "{{ vpc_id }}"
region: eu-west-1
rules:
- proto: tcp
ports: 3389
cidr_ip: 0.0.0.0/0
The first rule allows TCP 3389 from all IPv4 sources.
After
- name: Configure the RDP security group
amazon.aws.ec2_security_group:
name: example2
description: an example EC2 group
vpc_id: "{{ vpc_id }}"
region: eu-west-1
rules:
- proto: tcp
ports: 3389
cidr_ip: "{{ management_cidr }}"
The second uses management_cidr. Set it to the actual source addresses on the management path. Configure the resource attachment and routes separately.