A file's permissions let every user write it
What it finds
os.chmod(path, 0o777): a file or directory that every user may write can be changed or replaced by any other account on the machine (CWE-732).
The mode must be an integer literal, or stat constants joined with |, whose bits let others write: 0o002, S_IWOTH or S_IRWXO.
From the rule's source, world_writable_mode.rs.
import osimport stat def share(path): os.chmod(path, 0o777)tx0 reports: os.chmod lets every user write the file os.chmod(path, stat.S_IRWXU | stat.S_IWOTH)tx0 reports: os.chmod lets every user write os.chmod(path, 0o755) os.chmod(path, stat.S_IRUSR | stat.S_IWUSR) 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:
[rules]
"tx0/python: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/python:world-writable-mode] reason="..."tx0 explain tx0/python:world-writable-mode shows the same in the terminal. Found a false positive? Report it.