When standard temporary directory validations fail, this code falls back to an alternative temporary directory without checking execution privileges. This may lead to local privilege escalation if the directory is accessible to lower privileged users and the application is running as SYSTEM.
Rule Explorer
Search the public rule index by CVE, GHSA, CWE, language, framework, author, or rule slug. Filter by language, framework, severity, confidence, license, and validation status.
- Public rules
- 2917
- Downloads
- 3.3M
- Verified
- 2917
- Authors
- 2
Creating a file in a shared temporary directory with a predictable name and without `os.O_EXCL` allows local attackers to mount a symlink attack. If an attacker pre-creates a symlink at the predictable path, opening or creating the file will follow the symlink and overwrite the target file. Use `os.CreateTemp` to safely create temporary files, or provide `os
Creating a temporary file without specifying a `dir` and then moving it with `shutil.move` can lead to an arbitrary file overwrite. If the temporary directory is on a different filesystem than the destination, `shutil.move` falls back to a copy operation, which insecurely follows symbolic links at the destination path. Provide the `dir` argument so the tempo
Call to mktemp(3) creates a predictable temporary filename without atomically creating or locking the file. Any subsequent open()/fopen()/ creat() on that name is subject to a TOCTOU race (CWE-377): a local attacker who can write to the target directory can pre-create the predicted path as a symlink (causing arbitrary file write) or as a file whose name cont
Use of `tempfile.mktemp()` followed by `open()` on the returned path is insecure (CWE-377 / CVE-2023-2800). `mktemp()` only predicts a filename without atomically creating the file, opening a TOCTOU race in which a local attacker can place a symlink at the predicted path before it is opened, leading to arbitrary file overwrite. Replace this pattern with `tem
The application was found creating temporary files with the insecure `mktemp` method. Depending on how the application uses this temporary file, an attacker may be able to create symlinks that point to other files prior to the application creating or writing to the target file, leading to unintended files being created or overwritten. To remediate this issue
The `mktemp` function should no longer be used due to multiple flaws. Some implementations created random files by using known information like the process ID and a single letter. This allows for possible race conditions where an attacker could guess or manipulate these files prior to them being used. Consider using the `mkstemp` function instead, but be awa
The application was found creating files in shared system temporary directories (`/tmp` or `/var/tmp`) without using the `tempfile.TemporaryFile` function. Depending on how the application uses this temporary file, an attacker may be able to create symlinks that point to other files prior to the application creating or writing to the target file, leading to
There exists a possible race condition in between the time that `tempnam` or `tmpnam` returns a pathname, and the time that the program opens it, another program might create that pathname using `open`, or create it as a symbolic link. Consider using the `mkstemp` function instead, but be aware it also contains possible risks. Ensure the process has called t
The `GetTempFileName` function works by generating a randomly named file, creating the file (if it does not exist) and then closing it. An application wishing to use this temporary file will need to reopen this file to begin working with it. This leads to a potential Time Of Check Time Of Use (TOCTOU) vulnerability, as an attacker could replace or modify the
There exists a possible race condition in between the time that `tmpfile` returns a pathname, and the time that the program opens it, another program might create that pathname using `open`, or create it as a symbolic link. Consider using the `mkstemp` function instead, but be aware it also contains possible risks. Ensure the process has called the `umask` f
Some older Unix-like systems, `mkstemp` would create temp files with 0666 permissions, meaning the file created would be read/write access for all users. Ensure the process has called the `umask` function with restricted permissions prior to calling `mkstemp` and validate the permissions prior to using the file descriptor. For more information on temporary f