🇰🇷 한글 설명
SGLang의 get_tokenizer 함수에서 caller가 trust_remote_code=False로 명시적으로 지정해도 HuggingFace transformers v5가 TokenizersBackend를 반환할 때 내부에서 trust_remote_code=True로 자동 재호출하여 코드 인젝션이 발생합니다. tokenizer_config.json의 auto_map을 통해 참조된 악의적인 tokenizer.py가 SGLang 프로세스에서 임의 코드를 실행할 수 있으며, 로그나 경고 없이 진행됩니다.
💡 쉬운 설명
SGLang에서 '안전하게 로드해' 라고 설정해도 내부적으로 몰래 '위험하게 로드'로 바꾸어 악의적인 코드를 실행하게 만드는 보안 결함입니다. 공격자는 HuggingFace 모델 저장소에 악의적인 파이썬 코드를 숨겨놓고 실행하도록 유도할 수 있습니다.
🇺🇸 원문 (English)
A vulnerability was detected in sgl-project SGLang up to 0.5.9. Impacted is the function get_tokenizer of the file python/sglang/srt/utils/hf_transformers_utils.py of the component HuggingFace Transformer Handler. The manipulation of the argument trust_remote_code with the input False as part of Boolean results in code injection. The attack can be executed remotely. A high complexity level is associated with this attack. The exploitability is considered difficult. In get_tokenizer(), when the caller passes trust_remote_code=False and HuggingFace transformers v5 returns a TokenizersBackend instance (the generic fallback for tokenizer classes not in the registry), SGLang silently re-invokes AutoTokenizer.from_pretrained with trust_remote_code=True, overriding the caller's explicit security setting. A model repository containing a malicious tokenizer.py referenced via auto_map in tokenizer_config.json will execute arbitrary Python in the SGLang process during this second call. No log line or warning is emitted. The override affects all current SGLang versions because transformers==5.3.0 is pinned in pyproject.toml. Both tokenizer_mode="auto" and tokenizer_mode="slow" are affected. The exploit is now public and may be used. The vendor was contacted early about this disclosure but did not respond in any way.
📍 영향받는 시스템
SGLang 0.5.9 이하 (transformers==5.3.0 고정으로 모든 현재 버전 영향)
⚔️ 공격 벡터
원격 공격 가능, tokenizer_mode="auto" 또는 "slow" 사용 시 악의적인 HuggingFace 모델 저장소 활용
🛡️ 대응 방법
SGLang을 0.6.0 이상으로 업그레이드하거나 untrusted 모델 저장소 사용 금지
🔧 검증 코드
VULNERABLE이 출력되면 영향받는 버전(0.5.9 이하), PATCHED가 출력되면 안전한 버전입니다.
pip show sglang | grep Version | awk '{print $2}' | grep -E '^0\.[0-5]\.[0-9]' && echo 'VULNERABLE' || echo 'PATCHED'