Oct 23, 2026·5 min read·11 visits
Local unprivileged users can manipulate lock directories created by filelock's ReadWriteLock, causing victim processes to recursively delete arbitrary directories using path-based shutil.rmtree calls.
A Time-of-Check Time-of-Use (TOCTOU) race condition in the Python `filelock` library (versions 4.1.0 to 4.2.0) allows local unprivileged attackers to cause arbitrary directory deletion by swapping file system targets during lock cleanup or dead owner sweeps.
The filelock package is a platform-independent Python implementation used to manage inter-process file locks. Starting with version 4.1.0, the package introduced SQLite-backed reader/writer lock primitives, implemented in ReadWriteLock and AsyncReadWriteLock. These classes allow multiple concurrent readers or an exclusive writer to synchronize operations across independent operating system processes.
When operating in fallback environments where direct file descriptor interaction via /proc/self/fd is unavailable or when utilizing shared directories, ReadWriteLock creates temporary private directories formatted as .filelock-* in the database parent directory. These directories hold hard-linked entries (lock.db) corresponding to active process lock instances.
Prior to version 4.2.1, releasing a lock or cleaning up stale lock entries during dead-owner sweeps triggered recursive path-based deletion via shutil.rmtree(). In non-sticky, world-writable directories, a local attacker can exploit this design by swapping the expected directory path with a target victim directory prior to deletion.
The technical root cause of CVE-2026-112937 lies in relying on path string resolution during recursive directory cleanup instead of using file descriptor pinning. In src/filelock/_read_write.py, the lock mechanism invoked shutil.rmtree(directory) with a string path representing .filelock-<pid>-<hash>.
Because string-based path traversal performs resolution dynamically at execution time, a window of exposure exists between when the lock directory is identified and when shutil.rmtree() performs recursive directory unlinking. An attacker with write and rename permissions in the shared parent directory can move the legitimate .filelock-* directory and replace it with a directory owned by the victim process.
When the victim process finishes lock release or executes the _sweep_links_of_the_dead routine, it passes the string path to shutil.rmtree(). Python traverses the substituted directory path using the process's effective permissions, systematically unlinking all child items and removing the directory hierarchy.
In vulnerable versions, link directories were unlinked directly via shutil.rmtree without verifying directory inode stability or permissions:
# Vulnerable implementation in filelock/_read_write.py
def _purge_link_directory(self, directory: str) -> None:
# Vulnerable path string resolution
if os.path.exists(directory):
shutil.rmtree(directory)The fix implemented in commit 5e3f2ec0c5fb17cb2635b60b2b68bc63ab81ca2d replaces path-based deletion with file descriptor-pinned operations through _remove_link_directory(link). The patched implementation opens the target directory directly and verifies its device and inode identifier:
# Patched implementation in filelock/_read_write.py
def _remove_link_directory(link: Link) -> None:
# Open directory file descriptor securely
fd = os.open(link.path, _DIRECTORY_FLAGS)
try:
opened = os.fstat(fd)
# Verify device and inode match expected identity
if (opened.st_dev, opened.st_ino) != link.identity:
raise SecurityError("Directory identity mismatch detected")
# Perform directory-relative unlinks using dir_fd
_unlink_contents_at(fd)
finally:
os.close(fd)Additionally, filelock introduced _names_are_private and _directory_is_private helpers to ensure parent directories restrict write access strictly to the owner before link operations proceed. Sweeping functions now enforce user identity checks via os.fstat(fd).st_uid == owner.
To exploit this vulnerability, an attacker requires local unprivileged shell access and write access to the parent directory where the filelock database resides. Shared temporary locations without sticky bits (such as unprotected custom subdirectories under /tmp) represent primary attack vectors.
The attack flow operates in four distinct stages:
.filelock-* entries created by the victim process.rename) to move .filelock-<pid>-<hash> to a temporary name..filelock-<pid>-<hash> pointing to a victim-owned target directory (e.g., /home/victim/project).shutil.rmtree(), traversing the attacker-placed reference and deleting the target directory tree.The impact of CVE-2026-112937 is restricted to localized integrity loss and application denial of service. The vulnerability does not provide arbitrary code execution or direct read access to confidential file contents.
Because the deletion occurs under the user privileges running the filelock library, an attacker can induce destruction of any file or directory writable by that user account. If the victim process runs as a privileged account (such as root or Administrator), an unprivileged attacker can delete critical system configurations or database directories.
This vulnerability has been assigned a CVSS v3.1 score of 6.1 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L). EPSS scoring is rated at 0.00096, reflecting no observed exploitation in wild ransomware or automated attack frameworks.
Organizations and developers should update the filelock dependency to version 4.2.1 or higher immediately.
For Python environments managed via pip:
pip install --upgrade "filelock>=4.2.1"For projects using pyproject.toml dependencies:
[dependencies]
filelock = ">=4.2.1"If immediate dependency updates cannot be deployed, teams must apply filesystem configuration workarounds. Ensure all lock databases and link directories reside inside restricted directories owned by the process user with strict permissions (0o700). Avoid placing lock instances in shared world-writable paths like /tmp unless sticky bits (S_ISVTX) are strictly enforced.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
filelock tox-dev | >= 4.1.0, < 4.2.1 | 4.2.1 |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-112937 |
| Weakness Class | CWE-367: Time-of-Check Time-of-Use (TOCTOU) Race Condition |
| CVSS v3.1 Score | 6.1 (Medium) |
| CVSS Vector | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L |
| Attack Vector | Local (Unprivileged) |
| Exploit Maturity | None (No public weaponized exploit) |
| CISA KEV Status | Not Listed |
The software checks the state of a resource before acting upon it, but the resource's state changes before the action is executed.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.
CVE-2026-128077 (GHSA-r99w-jh2x-3mg9) is an authorization bypass and interpretation conflict vulnerability affecting Nuxt and its underlying @nuxt/nitro-server package in versions 4.6.0 through 4.6.3. When an incoming HTTP request path begins with a double forward slash (e.g., //x/admin), the WHATWG URL parser within the Nuxt server-side page renderer interprets the initial segment as a network host/authority and resolves the remaining path (/admin) against the application's page router. Because Nitro server middleware, route-scoped serverHandlers, and Nitro routeRules evaluate the unparsed request path (//x/admin), path-based access controls, redirects, and security header policies configured for /admin fail to match and are bypassed.