net/http/pprof is imported for its side effect, which adds profiling endpoints to the default server

tx0/go:profiling-endpoint-importstrictwarningsecurity, cwe-489

What it finds

import _ "net/http/pprof" registers handlers under /debug/pprof/ on http.DefaultServeMux, so every server that uses the default mux exposes stack traces, command lines and heap profiles, and lets callers start costly profiles. Registering the handlers on a separate mux that listens only locally, or behind authentication, keeps them away from users.

Imports of net/http/pprof with the blank name are reported. A program that serves the default mux only on a local address is a deliberate use, so the rule is strict.

From the rule's source, profiling_endpoint_import.rs.

Example from the rule's tests
package p import (	"net/http"	_ "net/http/pprof"tx0 reports: this import adds profiling endpoints to the default HTTP server) var _ = http.DefaultServeMux
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/go:profiling-endpoint-import" = "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:profiling-endpoint-import] reason="..."

tx0 explain tx0/go:profiling-endpoint-import shows the same in the terminal. Found a false positive? Report it.