A file mode lets any user of the machine modify the file

tx0/ts:world-writable-moderecommendedwarningsecurity, cwe-732

What it finds

A file or directory that every user of the machine may write can be replaced or changed by any of them, which turns a local account into control over what the program reads or runs.

Reported are the modes given to Node's chmod, fchmod, lchmod, mkdir, open, writeFile and appendFile, and their synchronous and promise forms, when the mode is a literal number or octal string that grants write access to others, as 0o777 or "666"; and process.umask(0), which lets every file created afterwards be written by everyone.

From the rule's source, world_writable_mode.rs.

Example from the rule's tests
import fs from "fs";export function prepare(dir: string, file: string) {  fs.chmodSync(file, 0o777);tx0 reports: lets every user write the file  fs.mkdirSync(dir, { mode: 0o766, recursive: true });tx0 reports: lets every user write the file  fs.writeFileSync(file, "x", { mode: "666" });tx0 reports: lets every user write the file  fs.chmodSync(file, 0o755);  fs.mkdirSync(dir, { recursive: true });  process.umask(0);tx0 reports: umask(0) lets everyone 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:world-writable-mode" = "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:world-writable-mode] reason="..."

tx0 explain tx0/ts:world-writable-mode shows the same in the terminal. Found a false positive? Report it.