A file is created at a fixed path in a shared temporary directory such as /tmp

tx0/ts:public-temp-pathrecommendedwarningsecurity/filesdepth fastsecurity

What it finds

Every user of the machine can create files in /tmp. A program that writes to a fixed name there can be tricked by another user who created the file or a link of that name first, into overwriting other files or reading planted data. fs.mkdtemp creates a private directory with an unpredictable name.

Reported are string literals that start with /tmp/, /var/tmp/ or /dev/shm/ given as the first argument of fs functions that create, open or write files.

From the rule's source, public_temp_path.rs.

Example from the rule's tests
import * as fs from "node:fs";export function save(data: string) {  fs.writeFileSync("/tmp/report.txt", data);tx0 reports: is a fixed name in a directory that every user can write}
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 recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:public-temp-path" = "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/ts:public-temp-path] reason="..."

tx0 explain tx0/ts:public-temp-path shows the same in the terminal. Found a false positive? Report it.