open is asked to create a file but is not given the permissions for it

tx0/cpp:open-create-without-modedefaultwarningsecurity/filesdepth fastbug, cwe-732

What it finds

open(path, O_WRONLY | O_CREAT): with O_CREAT or O_TMPFILE, open reads a third argument for the permissions of the new file; without one it takes whatever is on the stack or in a register, and the file gets arbitrary permissions.

From the rule's source, open_create_without_mode.rs.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:open-create-without-mode" = "off"

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:open-create-without-mode] reason="..."

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