A value taken from an HTTP request is written to a text log as it is
What it finds
log.Printf("login failed for %s", r.FormValue("user")): a value with a line break writes lines of its own into the log, which can forge entries or hide an attack from whoever reads the log. Structured logging with log/slog quotes values; text logs quote them with %q.
A request value of the handler, as described for the request values of the pack, must be an argument of Print, Printf, Println, Fatal, Fatalf, Panicf of log. Many logs are read only by programs that split on records rather than lines, so the rule is strict.
From the rule's source, request_value_logged.rs.
package p import ( "log" "net/http") func handle(w http.ResponseWriter, r *http.Request) { user := r.FormValue("user") log.Printf("login failed for %s", user)tx0 reports: log.Printf writes a value taken from the request as it is log.Printf("login failed for %d", len(user))} 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:request-value-logged" = "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:request-value-logged] reason="..."tx0 explain tx0/go:request-value-logged shows the same in the terminal. Found a false positive? Report it.