🇰🇷 한글 설명
scripts/iib/api.py의 is_path_trusted 함수가 경로를 검증할 때 경로 구분자를 포함하지 않고 문자열 시작 부분만 비교하여 발생하는 취약점입니다. 이로 인해 허용된 디렉토리 이름과 유사하게 시작하는 다른 디렉토리의 파일에 접근할 수 있는 경로 우회 문제가 발생합니다. 네트워크에 노출된 Stable Diffusion WebUI 환경에서 설정된 접근 제어를 무력화하고 민감한 파일을 노출시킬 수 있습니다.
💡 쉬운 설명
허용된 폴더 이름과 비슷하게 시작하는 다른 폴더가 있다면, 보안 검사를 통과하여 비밀 파일까지 읽을 수 있는 오류입니다. 예를 들어 '이미지' 폴더를 허용했는데 '이미지_비밀' 폴더가 있다면 보안망을 뚫고 접근이 가능해집니다.
🇺🇸 원문 (English)
is_path_trusted in scripts/iib/api.py compares the requested path against each allowed parent directory with path.startswith(parent_path), without appending a path separator. A directory whose name merely begins with an allowed path therefore satisfies the comparison, so where /data/images is allowed a request for /data/images_private/secret.txt is treated as trusted and served by FileResponse, disclosing files the confinement was meant to exclude. 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 compares against parent_path joined with os.sep.
📍 영향받는 시스템
Stable Diffusion WebUI (IIB API 사용 환경)
⚔️ 공격 벡터
허용된 경로의 접두사와 일치하는 이름의 다른 디렉토리 경로를 요청하여 파일 탈취
🛡️ 대응 방법
경로 비교 시 parent_path 뒤에 os.sep(경로 구분자)를 추가하여 정확한 디렉토리 일치 여부를 확인하도록 패치 적용
🔧 검증 코드
명령어 결과에 os.sep를 결합하는 수정 사항이 없다면 취약한 상태입니다.
grep -r "path.startswith(parent_path)" scripts/iib/api.py