A program is run with a name or argument taken from an HTTP request without a check
What it finds
exec.Command("convert", r.FormValue("file"), "out.png"): without a shell there is no injection of whole commands, but a value from the request still chooses the program, or passes options: --output=/etc/... or -exec change what a tool does. Values are checked, and separated from options with -- where the tool supports it.
The program or an argument of exec.Command or exec.CommandContext must be a request value of the handler, as described for the request values of the pack, that the function does not check in a condition.
From the rule's source, request_value_in_command.rs.
package p import ( "net/http" "os/exec") func convert(w http.ResponseWriter, r *http.Request) { file := r.FormValue("file") exec.Command("convert", file, "out.png").Run()tx0 reports: exec.Command is given a value taken from the request exec.Command("convert", "in.png", "out.png").Run()} 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:request-value-in-command" = "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-in-command] reason="..."tx0 explain tx0/go:request-value-in-command shows the same in the terminal. Found a false positive? Report it.