🇰🇷 한글 설명
tarfile 또는 zipfile의 명령줄 인터페이스(CLI)로 아카이브를 압축 해제할 때, 표준 라이브러리 모듈과 같은 이름의 악성 Python 스크립트가 생성될 수 있습니다. 이후 다음 파일 압축 해제 중 오류가 발생하면 해당 스크립트가 실행되며, 특히 traceback.py로 만들어진 경우 위험합니다. Python은 python -m MODULE 실행 시 현재 디렉터리를 sys.path에 추가하고 아카이브도 현재 디렉터리에 풀리기 때문에 이 문제가 발생합니다. 수정 사항은 gzip, tarfile, zipfile CLI에서 sys.path[0]을 제거하여 추출된 파일이 표준 라이브러리 모듈을 가리는 것을 방지합니다.
💡 쉬운 설명
압축 파일을 풀다가 오류가 나면, 압축 파일 안에 숨겨진 가짜 프로그램이 자동으로 실행될 수 있습니다. 이 문제는 Python 명령줄 도구에서 발생하며, 수정 버전으로 업데이트하면 해결됩니다.
🇺🇸 원문 (English)
When tarfile or zipfile command line interface (CLI) is used to
decompress an archive, a Python script shadowing the stdlib can be
created. Then if an error occurs during decompressing the next file,
the newly created Python script is executed. This is especially true
if the created Python is called traceback.py. The problem is that
Python adds the current directory to sys.path when python -m MODULE is
run, and the archive is also decompressed in the current directory.
The fix removes sys.path[0] in gzip, tarfile and zipfile command line
interface to prevent shadowing standard library modules from extracted
files.
📍 영향받는 시스템
Python 3.x의 tarfile·zipfile·gzip 명령줄 인터페이스를 사용하는 시스템 (정확한 취약 버전은 제조사 공지 확인 필요)
⚔️ 공격 벡터
악성 아카이브를 사용자가 현재 디렉터리에서 CLI로 압축 해제할 때, 표준 모듈 이름(traceback.py 등)의 악성 스크립트가 생성되어 이후 오류 발생 시 실행됨
🛡️ 대응 방법
Python을 sys.path[0] 제거 패치가 포함된 최신 보안 업데이트 버전으로 업그레이드
🔧 검증 코드
출력된 Python 버전을 배포판/공식 보안 공지에서 확인된 패치 버전과 비교하여, 같거나 높으면 수정이 적용된 것이고 낮으면 업데이트가 필요합니다.
python3 -c "import sys, platform; print(platform.python_version())"