🇰🇷 한글 설명
optimate 프로젝트의 neural_magic_training.py에서 torch.load()가 weights_only=True 파라미터 없이 모델 파일을 역직렬화하는 취약점(CWE-502)이 존재합니다. 공격자는 --model 인자로 지정된 디렉토리에 악의적으로 조작된 state_dict.pt 파일을 배치하여 Pickle 모듈을 통해 임의의 Python 객체를 역직렬화하고 피해자 시스템에서 임의 코드를 실행할 수 있습니다.
💡 쉬운 설명
PyTorch 모델 파일을 로드할 때 보안 검증이 없어서, 해커가 만든 악의적인 모델 파일을 통해 컴퓨터를 제어할 수 있습니다. 신뢰할 수 없는 출처의 모델 파일을 실행하면 위험합니다.
🇺🇸 원문 (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 loading a model state dictionary from a state_dict.pt file via torch.load(), the function does not enable 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 state_dict.pt file within a directory specified via the --model argument, leading to arbitrary code execution during the deserialization process on the victim's system.
📍 영향받는 시스템
optimate 프로젝트 (commit a6d302f 이전, 2024-07-21 포함)
⚔️ 공격 벡터
--model 인자로 악의적인 state_dict.pt 파일을 전달하여 역직렬화 중 임의 코드 실행 유도
🛡️ 대응 방법
torch.load() 호출을 torch.load(file, weights_only=True)로 변경하여 안전한 역직렬화 활성화
🔧 검증 코드
명령어 결과가 없으면 모두 수정됨, 결과가 있으면 weights_only=True가 적용되지 않은 부분의 라인 번호 확인
grep -n "torch.load" neural_magic_training.py | grep -v "weights_only=True"