A server listens on the unspecified address, which accepts connections on every interface
What it finds
net.Listen("tcp", "0.0.0.0:8080"): the unspecified address accepts connections on every network interface of the machine, including public ones, so a service meant for the local machine or one network is reachable from all of them. Binding to 127.0.0.1 or the address of the intended interface limits that.
Reported are constant addresses whose host is 0.0.0.0 or [::], given to Listen or ListenPacket of net, or to ListenAndServe or ListenAndServeTLS of net/http, resolved through the imports. An address with an empty host, as ":8080", listens on all interfaces too but is the common way to serve everyone on purpose, so it is left alone. Containers and servers bind to all interfaces on purpose, so the rule is strict.
From the rule's source, listen_all_interfaces.rs.
package p import ( "net" "net/http") func serve() { net.Listen("tcp", "0.0.0.0:9000")tx0 reports: 0.0.0.0:9000 accepts connections on every network interface net.Listen("tcp", "127.0.0.1:9000") http.ListenAndServe(":8080", nil)} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:listen-all-interfaces" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:listen-all-interfaces] reason="..."tx0 explain tx0/go:listen-all-interfaces shows the same in the terminal. Found a false positive? Report it.