A temporary file name is made with a function that leaves time for another process to take the name
What it finds
tmpnam, tempnam and mktemp return a name that does not exist yet, and the file is created in a second step; in between another process can create the file or a link of that name and have the program write where it chooses. mkstemp and tmpfile create the file in one step.
From the rule's source, insecure_temporary_file.rs.
#include <stdio.h>#include <stdlib.h> void temp(char *name){ char *a = tmpnam(NULL);tx0 reports: tmpnam makes a name that another process can take mktemp(name);tx0 reports: mktemp makes a name that another process can take (void)a; mkstemp(name);} 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:
[rules]
"tx0/c:insecure-temporary-file" = "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/c:insecure-temporary-file] reason="..."tx0 explain tx0/c:insecure-temporary-file shows the same in the terminal. Found a false positive? Report it.