BudgetScan

Listen does not validate that network is a TCP network

low swesweep-fasthttp · reuseport/reuseport_solaris.go · Listen · run #4

Description

Listen is documented as returning a TCP listener, but it passes the caller-supplied network string directly to net.ListenConfig.Listen. If network is taken from untrusted configuration, values such as 'udp', 'unix', or other supported non-TCP networks can produce a non-TCP listener. Host code that assumes TCP semantics, performs type assertions on Addr/Accept results, or relies on TCP port binding behavior may panic or misbehave, enabling denial of service or protocol confusion. Validate that network is one of the supported TCP networks before creating the listener.

Triage

Not triaged.

Raw scan report for this file

```json
[
  {
    "severity": "low",
    "title": "Setsockopt failures are not propagated from listenConfig.Control",
    "function": "listenConfig.Control",
    "description": "The Control callback assigns errors from unix.SetsockoptInt to the named return err, but syscall.RawConn.Control invokes a func(fd uintptr) with no return value, so c.Control returns nil for those setsockopt failures. Listen can therefore return success even if SO_REUSEADDR or SO_REUSEPORT could not be set. An attacker who can influence network or address, or an environment where the option is unsupported or permission-denied, may cause a listener to be created with different socket-option semantics than the caller expects, potentially leading to misconfigured services, failed failover, or denial of service. Check the captured error after c.Control returns and return it if non-nil."
  },
  {
    "severity": "low",
    "title": "Listen does not validate that network is a TCP network",
    "function": "Listen",
    "description": "Listen is documented as returning a TCP listener, but it passes the caller-supplied network string directly to net.ListenConfig.Listen. If network is taken from untrusted configuration, values such as 'udp', 'unix', or other supported non-TCP networks can produce a non-TCP listener. Host code that assumes TCP semantics, performs type assertions on Addr/Accept results, or relies on TCP port binding behavior may panic or misbehave, enabling denial of service or protocol confusion. Validate that network is one of the supported TCP networks before creating the listener."
  }
]
```