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", "::" or an empty string as the address to the `socket.bind` function, the application will bind to all interfaces.

Examples

Insecure Code

python
sock.bind(("0.0.0.0", 9777))

Secure Code

python
address = os.getenv("IP_ADDRESS", "127.0.0.1")
sock.bind((address, 9777))

Remediation

Pass the interface IP address through an environment variable, configuration file, or determine the primary interface(s) IP address. For example, get the IP address from an environment variable `IP_ADDRESS`.

Rule Details

FieldValue
IDCODE-0113
CategoryInsecureConfig
SeverityLOW
CWECWE-1327
ConfidenceHIGH
ImpactLOW
LikelihoodMEDIUM
ExploitabilityEASY
Tagsnetwork, interface
OWASPA6:2017-Security Misconfiguration, A05:2021-Security Misconfiguration