Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration of “Telnet Port Should Not Be Open” for GCP using GCP console, please follow the below steps:
  1. Login to your GCP console.
  2. Navigate to the GCP project which has the instance with the open Telnet port.
  3. Click on the hamburger menu on the top left corner of the console and select “Compute Engine” under the “Compute” section.
  4. From the list of instances, select the instance with the open Telnet port.
  5. Click on the “Edit” button at the top of the page.
  6. Scroll down to the “Firewall” section and click on “Management, disks, networking, SSH keys”.
  7. Under the “Firewall” section, click on “default-allow-internal”.
  8. Scroll down to the “Protocols and ports” section and uncheck the “tcp:23” option.
  9. Click on the “Save” button at the bottom of the page.
By following the above steps, you have successfully remediated the misconfiguration of “Telnet Port Should Not Be Open” for GCP using GCP console.

To remediate the “Telnet Port Should Not Be Open” misconfiguration on GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP Console.
  2. Run the following command to list all the instances in the project:
  1. Identify the instance that has the telnet port open.
  2. Connect to the instance using SSH:
  1. Once connected to the instance, run the following command to check if telnet is installed:
  1. If telnet is installed, run the following command to uninstall it:
  1. If telnet is not installed, run the following command to check if the telnet port is open:
  1. If the telnet port is open, edit the firewall rules for the instance to close the telnet port:
  1. Verify that the telnet port is closed by running the following command:
  1. Exit the SSH session by typing exit.
  2. Repeat steps 4-10 for any other instances that have the telnet port open.
By following the above steps, you can remediate the “Telnet Port Should Not Be Open” misconfiguration on GCP using GCP CLI.
To remediate the Telnet Port Should Not Be Open misconfiguration in GCP using Python, you can follow these steps:
  1. Connect to the GCP project using the Python client library.
  1. Check if the Telnet port is open by looking at the instance’s firewall rules.
  1. If there is a firewall rule that allows Telnet traffic, delete it.
  1. Confirm that the Telnet port is no longer open by checking the instance’s firewall rules again.
By following these steps, you can remediate the Telnet Port Should Not Be Open misconfiguration for a GCP instance using Python.
Substitute:
  • VPC_NETWORK_RESOURCE_NAME with your google_compute_network resource name.
  • GCP_PROJECT_ID with your project ID.
  • KNOWN_TRUSTED_CIDR_1 / KNOWN_TRUSTED_CIDR_2 with your allowed IP ranges.
  • TELNET_TARGET_TAG with the network tag used by instances that must receive Telnet (or remove target_tags if you intentionally apply to all instances on the network).
This change is in-place; it should not force replacement of the firewall rule, only an update to source_ranges.Verification: terraform plan should show the existing google_compute_firewall rule’s source_ranges changing from ["0.0.0.0/0"] (or similarly broad ranges) to the specified KNOWN_TRUSTED_CIDR_* values, with no -/+ replacement indicator for the resource.