A stack trace is written into an HTTP response
What it finds
w.Write(debug.Stack()) in an HTTP handler: a stack trace tells a client the names of functions and files, the versions of libraries and sometimes values from memory, which helps whoever looks for a way in. It belongs in the server's log; the client gets a short message.
Reported are calls of debug.Stack of runtime/debug, at any depth, in the arguments of a call that writes to a parameter declared as http.ResponseWriter: a method Write or WriteString on it, http.Error, or fmt.Fprint, Fprintf, Fprintln and io.WriteString with it as the first argument.
From the rule's source, goroutine_dump_in_response.rs.
package p import ( "log" "net/http" "runtime/debug") func handle(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { log.Printf("panic: %v\n%s", err, debug.Stack()) http.Error(w, string(debug.Stack()), http.StatusInternalServerError)tx0 reports: a stack trace is sent to the client } }() w.Write(debug.Stack())tx0 reports: a stack trace is sent to the client} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:goroutine-dump-in-response" = "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:goroutine-dump-in-response] reason="..."tx0 explain tx0/go:goroutine-dump-in-response shows the same in the terminal. Found a false positive? Report it.