A socket or server is given the address 0.0.0.0 or ::

tx0/python:listen-on-any-addressstrictwarningsecurity, cwe-200

What it finds

sock.bind(("0.0.0.0", 8080)), app.run(host="0.0.0.0"): listening on every interface makes a service reachable from every network the machine is on, not only from the one it is meant for (CWE-200). Listening on 127.0.0.1, or on the address of one interface, limits who can connect.

Reported are the addresses 0.0.0.0 and :: as the first element of the tuple given to a bind method, and as a host keyword argument.

From the rule's source, listen_on_any_address.rs.

Example from the rule's tests
import socket  def serve(app):    sock = socket.socket()    sock.bind(("0.0.0.0", 8080))tx0 reports: this listens on every network interface of the machine    sock.bind(("127.0.0.1", 8080))    app.run(host="0.0.0.0")tx0 reports: this listens on every network interface    app.run(host="localhost")
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/python:listen-on-any-address" = "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/python:listen-on-any-address] reason="..."

tx0 explain tx0/python:listen-on-any-address shows the same in the terminal. Found a false positive? Report it.