🇰🇷 한글 설명
optimate 프로젝트의 neural_magic_training.py에서 torch.load() 함수가 weights_only=True 파라미터 없이 사용되어 불안전한 역직렬화 취약점이 발생합니다. 공격자가 악의적인 .pt/.pth 모델 파일을 제공하면 임의의 Python 객체가 역직렬화되어 코드 실행이 가능합니다.
💡 쉬운 설명
모델 파일을 로드할 때 검증 없이 모든 내용을 신뢰하는 문제입니다. 공격자가 해로운 모델 파일을 보내면 당신의 컴퓨터에서 악의적인 코드가 실행될 수 있습니다.
🇺🇸 원문 (English)
The _load_model() function in the neural_magic_training.py script of the optimate project in commit a6d302f912b481c94370811af6b11402f51d377f (2024-07-21) is vulnerable to insecure deserialization (CWE-502). When a user provides a single model file path (e.g., .pt or .pth) via the --model command-line argument, the function loads the file using torch.load() without enabling the weights_only=True security parameter. This allows the deserialization of arbitrary Python objects through the Pickle module. A remote attacker can exploit this by providing a maliciously crafted model file, leading to arbitrary code execution during deserialization on the victim's system.
📍 영향받는 시스템
optimate 프로젝트 commit a6d302f912b481c94370811af6b11402f51d377f (2024-07-21) 및 이전 버전
⚔️ 공격 벡터
--model 인자로 악의적인 .pt/.pth 파일 제공 시 torch.load() 역직렬화 단계에서 임의 코드 실행
🛡️ 대응 방법
torch.load(filepath, weights_only=True) 파라미터를 추가하여 Pickle 역직렬화를 비활성화
🔧 검증 코드
출력이 있으면 취약한 torch.load() 호출이 존재하며, 출력이 없으면 모든 호출이 weights_only=True로 보호됩니다.
grep -n "torch.load" neural_magic_training.py 2>/dev/null | grep -v "weights_only=True"