Skip to content

Binding to an unrestricted IP address

Description

Binding to all network interfaces can potentially open up a service to traffic on unintended interfaces, that may not be properly documented or secured. By passing "0.0.0.0" as the address to the `Listen` family of functions, the application will bind to all interfaces.

Examples

Insecure Code

go
net.Listen("tcp", "0.0.0.0:8080")

Secure Code

go
addr := os.Getenv("IP_ADDRESS"); listener, err := net.Listen("tcp", addr)

Remediation

Pass the interface IP address through an environment variable, configuration file, or determine the primary interface(s) IP address.

Rule Details

FieldValue
IDCODE-0794
CategoryInsecureConfig
SeverityLOW
CWECWE-1327
ConfidenceHIGH
ImpactLOW
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsnetwork interface, IP address
OWASPA6:2017-Security Misconfiguration, A05:2021-Security Misconfiguration