🔍 CVE-2025-68146

6.3
CVSS Score
MEDIUM
2025-12-16
2025-12-16 19:15
✅ 완료

🇰🇷 한글 설명

filelock 라이브러리에서 발생하는 Time-of-Check-Time-of-Use (TOCTOU) 경쟁 조건 취약점으로, 공격자가 임의의 사용자 파일을 손상시키거나 잘라낼 수 있다. 이 취약점은 Unix와 Windows의 파일 잠금 생성에서 발생하며, filelock 3.20.1 버전 이전에서 영향을 받는다.

💡 쉬운 설명

filelock 라이브러리가 파일 잠금을 생성할 때 발생하는 취약점으로, 공격자가 임의의 파일을 손상시킬 수 있다. 이 취약점은 로컬 파일 시스템 접근과 심볼릭 링크 생성이 가능한 사용자에게 영향을 미친다. 업그레이드나 작업-around을 통해 취약점을 완화할 수 있다.

🇺🇸 원문 (English)

filelock is a platform-independent file lock for Python. In versions prior to 3.20.1, a Time-of-Check-Time-of-Use (TOCTOU) race condition allows local attackers to corrupt or truncate arbitrary user files through symlink attacks. The vulnerability exists in both Unix and Windows lock file creation where filelock checks if a file exists before opening it with O_TRUNC. An attacker can create a symlink pointing to a victim file in the time gap between the check and open, causing os.open() to follow the symlink and truncate the target file. All users of filelock on Unix, Linux, macOS, and Windows systems are impacted. The vulnerability cascades to dependent libraries. The attack requires local filesystem access and ability to create symlinks (standard user permissions on Unix; Developer Mode on Windows 10+). Exploitation succeeds within 1-3 attempts when lock file paths are predictable. The issue is fixed in version 3.20.1. If immediate upgrade is not possible, use SoftFileLock instead of UnixFileLock/WindowsFileLock (note: different locking semantics, may not be suitable for all use cases); ensure lock file directories have restrictive permissions (chmod 0700) to prevent untrusted users from creating symlinks; and/or monitor lock file directories for suspicious symlinks before running trusted applications. These workarounds provide only partial mitigation. The race condition remains exploitable. Upgrading to version 3.20.1 is strongly recommended.

📍 영향받는 시스템

Unix, Linux, macOS, Windows 시스템에서 filelock 라이브러리 3.20.1 버전 이전

⚔️ 공격 벡터

로컬 파일 시스템 접근과 심볼릭 링크 생성이 가능한 사용자

🛡️ 대응 방법

filelock 라이브러리를 3.20.1 버전으로 업그레이드하거나, SoftFileLock을 사용하거나, 잠금 파일 디렉토리에 대한 권한을 제한한다.

🔧 검증 코드

로컬 시스템에서 Python을 실행하고, filelock 라이브러리가 설치되어 있는지 확인한다. filelock 버전을 확인하고, 3.20.1 버전 미만인 경우 취약한 것으로 판단한다. filelock 라이브러리가 설치되어 있지 않은 경우 미설치로 판단한다.

Shell / Script
import pkg_resources
try:
    filelock_version = pkg_resources.get_distribution('filelock').version
    if filelock_version < '3.20.1':
        print({"result": "취약", "reason": "filelock 버전이 3.20.1 미만"})
    else:
        print({"result": "양호", "reason": "filelock 버전이 3.20.1 이상"})
except pkg_resources.DistributionNotFound:
    print({"result": "미설치", "reason": "filelock 라이브러리가 설치되어 있지 않음"})

📊 CVSS Vector String

CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H

💻 영향받는 소프트웨어

Python