Description
Restrict Windows Remote Desktop (TCP 3389) to the approved management path. A rule allowing 0.0.0.0/0 or ::/0 lets other clients with a route to the service attempt to sign in.
Potential impact
A reachable RDP service can receive password guesses and sign-in attempts using stolen credentials. A compromised account can expose the resources it can access.
Remediation
Set up IAP TCP forwarding or a VPN for the VMs that need RDP, including the required permissions and firewall rules. Check other allowed port ranges for 3389. Keep OS authentication in place and test that only the approved path works.
Examples
The first excerpt is a historical configuration that cannot be deployed. google.cloud 1.14.0 rejects its combination of source and target options, and test_object and test_project are invalid names. For the second excerpt, supply the project ID and a service account JSON file and confirm the intended VPC. Omitting the network selects the default VPC.
First configuration
- name: rdp_in_port
google.cloud.gcp_compute_firewall:
name: test_object
source_ranges:
- "0.0.0.0/0"
allowed:
- ip_protocol: tcp
ports:
- "22"
- "80"
- "3389"
target_tags:
- test-ssh-server
- staging-ssh-server
source_tags:
- test-ssh-clients
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
The Compute Engine API allows a source matching either source_ranges or source_tags. The tag cannot narrow 0.0.0.0/0.
Comparison configuration
- name: create a firewall
google.cloud.gcp_compute_firewall:
name: test-object
allowed:
- ip_protocol: tcp
ports:
- '80'
target_tags:
- test-ssh-server
- staging-ssh-server
source_ranges:
- "192.0.2.10/32"
project: "{{ project_id }}"
auth_kind: serviceaccount
service_account_file: /tmp/auth.pem
state: present
The second rule permits only TCP 80 to VMs with either target tag. Replace the documentation address 192.0.2.10/32 with the individual internal /32 addresses of the approved client VMs. RDP uses a separate management path.