An operating system command is started by a bare name, found through the PATH

tx0/java:command-path-lookupstrictwarningsecurity, cwe-426

What it finds

Runtime.getRuntime().exec("convert ...") and new ProcessBuilder("git", ...) start whatever program of that name comes first in the directories of PATH. Whoever can change PATH, or write to one of its directories, decides what runs (CWE-426). An absolute path names the program meant.

Reported is a string literal given as the command to exec or as the first argument of new ProcessBuilder, when its program has no directory.

From the rule's source, command_path_lookup.rs.

Example from the rule's tests
class Tools {  void run() throws Exception {    Runtime.getRuntime().exec("convert in.png out.jpg");tx0 reports: found through PATH    new ProcessBuilder("git", "status").start();tx0 reports: found through PATH    Runtime.getRuntime().exec("/usr/bin/convert in.png out.jpg");  }}
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/java:command-path-lookup" = "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/java:command-path-lookup] reason="..."

tx0 explain tx0/java:command-path-lookup shows the same in the terminal. Found a false positive? Report it.