{"id":2599,"cve":"CVE-2026-112941","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-112941\/","cwe":"CWE-367","cwe_number":367,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/367","cvss_score":3.3,"published":"2026-10-20","owasp":"A08 Software and Data Integrity Failures","odc":"Checking","cdc":"Incorrect Check","category":"Race Conditions","subcategory":"Time-of-Check to Time-of-Use","scope":"Local","impact":"Unauthorized Access","summary":"Cache bypass lets local user replace lock tree, redirecting writes to writable dirs.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-112941\/","description":"filelock is a platform-independent file lock for Python. From 4.1.0 until 4.2.1, SoftReadWriteLock and AsyncSoftReadWriteLock cache a successful check of the <path>.rw lock tree and resolve its names again during later record operations, allowing another local user who can replace that tree after the first acquisition to redirect lock-record writes into directories writable by the lock user. This issue is fixed in version 4.2.1.","solution":"Upgrade\u202ffilelock\u202fto\u202fversion\u202f4.2.1\u202for later.","affected_component":"filelock","fixed_by_upgrading":true,"vulnerable_code":"import os\nfrom filelock import SoftReadWriteLock\n\ndef process_file(base_path: str, payload: str) -> None:\n    lock_path = os.path.join(base_path, \"resource\")\n    # VULNERABLE: reuse cached lock path after first acquisition\n    lock = SoftReadWriteLock(lock_path)\n\n    # First operation: read under lock\n    lock.acquire()\n    with open(lock_path, \"r\") as f:\n        _ = f.read()\n    lock.release()\n\n    # Some unrelated work that could let an attacker replace the lock tree\n    do_something_else()\n\n    # Second operation: write under the same lock object (still using cached path)\n    lock.acquire()\n    with open(lock_path, \"a\") as f:\n        f.write(payload)\n    lock.release()\n\ndef do_something_else():\n    pass\n","patched_code":"import os\nfrom filelock import SoftReadWriteLock\n\ndef process_file(base_path: str, payload: str) -> None:\n    lock_path = os.path.join(base_path, \"resource\")\n    # FIX: create a fresh lock for each critical section to avoid cached path reuse\n    # First operation: read under lock\n    read_lock = SoftReadWriteLock(lock_path)\n    read_lock.acquire()\n    with open(lock_path, \"r\") as f:\n        _ = f.read()\n    read_lock.release()\n\n    do_something_else()\n\n    # Second operation: write under a new lock instance\n    write_lock = SoftReadWriteLock(lock_path)\n    write_lock.acquire()\n    with open(lock_path, \"a\") as f:\n        f.write(payload)\n    write_lock.release()\n\ndef do_something_else():\n    pass\n","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"tox-dev\/filelock","commit_url":"https:\/\/github.com\/tox-dev\/filelock\/commit\/bfa066d65a1ba9106f86ee9d027f7588b9c77e03","commit_subject":"\ud83d\udc1b fix(strict): keep claim directories private to the lock (#839)","units":[{"file":"src\/filelock\/_lease.py","function":null},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":null},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Files.create"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Files.overwrite"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"GenerationLog.commit"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"GenerationLog._extends_the_log"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"GenerationLog._list"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Ledger.observe"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Participant.heartbeat"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Participant.leave"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Participant._create_holder"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Participant._refresh_nonce"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Participant._unchanged_for_its_lease"},{"file":"src\/filelock\/_soft_rw\/_protocol.py","function":"Participant.__init__"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":null},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.create"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.link"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.listdir"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.overwrite"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.prepare"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.read"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.replace"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.unlink"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"OsFiles.__init__"},{"file":"src\/filelock\/_soft_rw\/_storage.py","function":"_identity"},{"file":"src\/filelock\/_soft_rw\/_sync.py","function":"SoftReadWriteLock._refresh"},{"file":"src\/filelock\/_soft_rw\/_sync.py","function":"SoftReadWriteLock._report_compromise"},{"file":"src\/filelock\/_strict.py","function":null},{"file":"src\/filelock\/_strict.py","function":"StrictSoftFileLock.force_break"},{"file":"src\/filelock\/_strict.py","function":"StrictSoftFileLock._acquire"},{"file":"src\/filelock\/_strict.py","function":"StrictSoftFileLock._attempt_doorway"},{"file":"src\/filelock\/_strict.py","function":"StrictSoftFileLock._discard_doorway"},{"file":"src\/filelock\/_strict.py","function":"StrictSoftFileLock._release"},{"file":"src\/filelock\/_strict.py","function":"StrictSoftFileLock._release_abandoned_holds"},{"file":"src\/filelock\/_strict.py","function":"_attempt_claim_read"},{"file":"src\/filelock\/_strict.py","function":"_ensure_protocol_directory"},{"file":"src\/filelock\/_strict.py","function":"_filesystem_now"},{"file":"src\/filelock\/_strict.py","function":"_inspect_lock_path"},{"file":"src\/filelock\/_strict.py","function":"_link_no_replace"},{"file":"src\/filelock\/_strict.py","function":"_list_claim_names"},{"file":"src\/filelock\/_strict.py","function":"_open_directory"},{"file":"src\/filelock\/_strict.py","function":"_open_or_create_sentinel"},{"file":"src\/filelock\/_strict.py","function":"_open_record"},{"file":"src\/filelock\/_strict.py","function":"_public_claim_names"},{"file":"src\/filelock\/_strict.py","function":"_publish_record"},{"file":"src\/filelock\/_strict.py","function":"_read_claims"},{"file":"src\/filelock\/_strict.py","function":"_read_existing_claims"},{"file":"src\/filelock\/_strict.py","function":"_read_record"},{"file":"src\/filelock\/_strict.py","function":"_reclaim_sentinel_private_records"},{"file":"src\/filelock\/_strict.py","function":"_require_exact_name"},{"file":"src\/filelock\/_strict.py","function":"_unlink_in_directory"},{"file":"src\/filelock\/_strict.py","function":"_unlink_owner_path"},{"file":"src\/filelock\/_strict.py","function":"_unlink_private_record_once"},{"file":"src\/filelock\/_util.py","function":null},{"file":"src\/filelock\/_windows.py","function":null},{"file":"tasks\/capabilities.py","function":null}]}],"references":null}