🇰🇷 한글 설명
Rembg 2.0.82 이전 버전에서 공개 API /api/remove의 extras.sam_model 파라미터가 검증 없이 SAM 파일명과 GitHub 다운로드 URL에 삽입됩니다. 이를 통해 경로 순회와 URL 프래그먼트를 조합한 공격으로 임의 ONNX 모델을 설치하고 서버에서 읽을 수 있는 파일의 내용을 결과 마스크로 유출할 수 있습니다.
💡 쉬운 설명
이미지 배경 제거 도구 Rembg의 공개 API에 입력값 검사가 부족해, 인증 없이도 서버 내부 파일을 훔쳐보거나 악성 모델을 실행할 수 있습니다. 2.0.82 이상 버전으로 업데이트하면 해결됩니다.
🇺🇸 원문 (English)
Rembg is a tool to remove images background. Prior to 2.0.82, the public /api/remove endpoint passes attacker-controlled extras.sam_model through rembg/commands/s_command.py to rembg/sessions/sam.py, where it is interpolated into SAM filenames and GitHub download URLs passed to pooch.retrieve() without a pinned hash. An unauthenticated attacker can supply a sam_model value combining path traversal with URL fragment syntax to exploit the HTTP request discarding the fragment while the local POSIX path retains it. The first request primes the attacker-selected path tree, and an identical repeated request downloads malicious ONNX encoder and decoder files beside a readable target file. The graphs can load the target through ONNX external data and encode its bytes into the returned PNG mask, disclosing complete files accessible to the rembg process and allowing arbitrary ONNX computation. This issue is fixed in version 2.0.82.
📍 영향받는 시스템
Rembg 2.0.82 미만 버전 (공개 /api/remove 엔드포인트를 노출한 서버)
⚔️ 공격 벡터
인증 없이 sam_model 값에 경로 순회와 URL 프래그먼트를 넣어 두 번 요청해 악성 ONNX 파일을 설치한 뒤, 대상 파일 내용을 PNG 마스크로 추출
🛡️ 대응 방법
rembg를 2.0.82 이상으로 업그레이드하고, 공개 API 노출을 제한하거나 인증을 적용
🔧 검증 코드
출력된 Version 값이 2.0.82 미만이면 취약하므로 업그레이드가 필요하고, 2.0.82 이상이면 수정된 버전입니다.
pip show rembg 2>/dev/null | grep -i version