Skip to main content

More Info:

Determines if UDP port 137 or 138 for NetBIOS is open to the public

Risk Level

Medium

Address

Security

Compliance Standards

SOC2, GDPR, ISO27001, HIPAA, HITRUST, NISTCSF, PCIDSS, FedRAMP

Triage and Remediation

Remediation

Using Console

To remediate the NetBIOS port being open misconfiguration in GCP using GCP console, follow these steps:
  1. Login to your GCP console.
  2. Select the project where the misconfiguration exists.
  3. Navigate to the Compute Engine section.
  4. Select the VM instance where the misconfiguration exists.
  5. Click on the “Edit” button at the top of the VM instance details page.
  6. Scroll down to the “Firewall” section.
  7. Click on “Add firewall rule”.
  8. Enter a name for the firewall rule.
  9. Set the “Action on match” to “Deny”.
  10. Set the “Targets” to “All instances in the network”.
  11. In the “Source filter” section, select “IP ranges”.
  12. Enter the IP range that you want to block.
  13. In the “Protocols and ports” section, select “Specified protocols and ports”.
  14. In the “Protocols and ports” field, enter “udp:137; udp:138; tcp:139; tcp:445” to block NetBIOS traffic.
  15. Click on the “Create” button to save the firewall rule.
After completing these steps, the NetBIOS port will be blocked for the specified IP range on the selected VM instance.

To remediate the NetBIOS Port Should Not Be Open misconfiguration in 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 firewall rules in your project:
  3. Look for the firewall rule that allows traffic on port 139 or 445, which are the ports used by NetBIOS. Note the name of the firewall rule.
  4. Run the following command to delete the firewall rule:
    Replace [FIREWALL_RULE_NAME] with the name of the firewall rule that you noted in step 3.
  5. Confirm that the firewall rule has been deleted by running the command in step 2 again.
  6. Verify that the NetBIOS port is no longer open by running a port scan on your GCP instance from an external network.
By following these steps, you have successfully remediated the NetBIOS Port Should Not Be Open misconfiguration in GCP using GCP CLI.
To remediate the NetBIOS Port Should Not Be Open misconfiguration in GCP using Python, you can follow these steps:
  1. Use the google-cloud-securitycenter library to retrieve the list of assets that have open NetBIOS ports. You can use the following code snippet to achieve this:
  1. For each asset with an open NetBIOS port, use the google-cloud-compute library to update the firewall rule and close the port. You can use the following code snippet to achieve this:
Note that you may need to adjust the code snippets to fit your specific use case, such as changing the filter expression or updating the firewall rule with different parameters.

Additional Reading: