🇰🇷 한글 설명
scripts/iib/tool.py의 to_abs_path 함수가 os.path.normpath를 사용하여 경로를 정규화할 때 심볼릭 링크를 해결하지 못하는 취약점이 있습니다. 이로 인해 스캔된 디렉토리 내부에 생성된 심볼릭 링크가 보안 검사를 우회하여 /etc/passwd와 같은 외부 파일을 노출시킬 수 있습니다. 네트워크에 노출된 Stable Diffusion WebUI 환경에서 특히 위험하며, os.path.realpath를 사용하여 경로를 해결하도록 수정되었습니다.
💡 쉬운 설명
파일 경로를 확인하는 과정에서 '가짜 연결 통로(심볼릭 링크)'를 제대로 검사하지 못하는 문제입니다. 공격자가 이 통로를 이용해 원래 접근해서는 안 되는 시스템의 중요한 파일들을 몰래 훔쳐볼 수 있습니다.
🇺🇸 원문 (English)
to_abs_path in scripts/iib/tool.py normalised the requested path with os.path.normpath, which collapses dot segments but does not resolve symbolic links. A symlink placed inside a scanned directory therefore satisfies the containment comparison performed by is_path_trusted in scripts/iib/api.py while pointing outside that directory, and FileResponse follows the link when serving the response, so a link created in an image directory and targeting a file such as /etc/passwd discloses that file. Whether the check applies depends on get_enable_access_control in scripts/iib/tool.py: it returns true when IIB_ACCESS_CONTROL is set to enable, false when set to disable, and otherwise true when the host Stable Diffusion WebUI was started with share, ngrok, listen or server_name, falling back to false. Confinement is therefore active in the network-exposed WebUI deployments that rely on it, while a standalone run with no such option serves every readable file regardless of this flaw. The fix resolves the path with os.path.realpath.
📍 영향받는 시스템
Stable Diffusion WebUI (IIB 관련 스크립트 사용 환경)
⚔️ 공격 벡터
스캔 가능한 디렉토리 내부에 외부 파일을 가리키는 심볼릭 링크를 생성하여 파일 응답 요청
🛡️ 대응 방법
scripts/iib/tool.py의 경로 정규화 방식을 os.path.normpath에서 os.path.realpath로 업데이트
🔧 검증 코드
명령어 결과에 os.path.normpath가 포함되어 있다면 취약한 버전이며, os.path.realpath로 수정되어 있어야 안전합니다.
grep -r 'os.path.normpath' scripts/iib/tool.py