chroot is called without a chdir after it, so the working directory stays outside the jail

tx0/cpp:chroot-without-chdirrecommendedwarningsecurity/authn-authzdepth fastsecurity, cwe-243

What it finds

chroot(dir); changes the root directory but not the working directory, which may still be outside the new root and gives access to everything beneath it. chdir("/") right after closes that.

From the rule's source, chroot_without_chdir.rs.

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:

tx0.toml
[rules]
"tx0/cpp:chroot-without-chdir" = "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/cpp:chroot-without-chdir] reason="..."

tx0 explain tx0/cpp:chroot-without-chdir shows the same in the terminal. Found a false positive? Report it.