🇰🇷 한글 설명
Diffusers 라이브러리 0.37.0에서 custom_pipeline 파라미터가 None일 때 'None.py' 파일명으로 자동 변환되어 실행되는 취약점입니다. 공격자는 악성 None.py가 포함된 Hub 저장소를 게시하여 trust_remote_code 검증을 우회하고 사용자의 from_pretrained() 호출 시 임의 코드를 실행할 수 있습니다.
💡 쉬운 설명
라이브러리가 의도하지 않은 파일을 자동으로 실행하는 버그가 있습니다. 공격자가 이를 악용하여 몰래 악성 코드를 실행할 수 있습니다.
🇺🇸 원문 (English)
Diffusers is the a library for pretrained diffusion models. Prior to 0.38.0, diffusers 0.37.0 allows remote code execution without the trust_remote_code=True safeguard when loading pipelines from Hugging Face Hub repositories. The _resolve_custom_pipeline_and_cls function in pipeline_loading_utils.py performs string interpolation on the custom_pipeline parameter using f"{custom_pipeline}.py". When custom_pipeline is not supplied by the user, it defaults to None, which Python interpolates as the literal string "None.py". If an attacker publishes a Hub repository containing a file named None.py with a class that subclasses DiffusionPipeline, the file is automatically downloaded and executed during a standard DiffusionPipeline.from_pretrained() call with no additional keyword arguments. The trust_remote_code check in DiffusionPipeline.download() is bypassed because it evaluates custom_pipeline is not None as False (since the kwarg was never supplied), while the downstream code path that actually loads the module resolves the None value into a valid filename. An attacker can achieve silent arbitrary code execution by publishing a malicious model repository with a None.py file and a standard-looking model_index.json that references a legitimate pipeline class name, requiring only that a victim calls from_pretrained on the repository. This vulnerability is fixed in 0.38.0.
📍 영향받는 시스템
Diffusers 0.37.0 (0.38.0에서 수정)
⚔️ 공격 벡터
악성 None.py 파일이 포함된 Hub 저장소 → 피해자의 from_pretrained() 호출 → 자동 실행
🛡️ 대응 방법
Diffusers 0.38.0 이상으로 업그레이드 또는 명시적으로 trust_remote_code 파라미터 설정
🔧 검증 코드
명령어 실행 후 'Patched'이면 안전, 'Vulnerable'이면 취약 상태입니다.
pip show diffusers 2>/dev/null | grep -qE 'Version: (0\.(3[8-9]|[4-9])|[1-9])' && echo 'Patched' || echo 'Vulnerable'