🇰🇷 한글 설명
wojtekmach Req 라이브러리에서 고압축 데이터 처리 미흡으로 인해 발생하는 데이터 증폭 취약점입니다. 공격자가 제어하는 HTTP 서버가 압축 폭탄(Decompression Bomb) 형태의 응답을 보낼 경우, 클라이언트의 메모리가 고갈되어 프로세스가 충돌할 수 있습니다.
💡 쉬운 설명
작은 크기의 압축 파일을 풀었을 때 엄청나게 큰 용량으로 늘어나게 만들어 컴퓨터의 메모리를 가득 채우는 공격입니다. 이로 인해 프로그램이 갑자기 멈추거나 꺼질 수 있습니다.
🇺🇸 원문 (English)
Improper Handling of Highly Compressed Data (Data Amplification) vulnerability in wojtekmach Req allows attacker-controlled HTTP servers to exhaust memory in a Req client via decompression-bomb response bodies.
Req's default response pipeline includes Req.Steps.decode_body/1 and Req.Steps.decompress_body/1 in lib/req/steps.ex. decode_body/1 dispatches on the server-supplied content-type (or URL extension) and calls :zip.extract(body, [:memory]) for application/zip, :erl_tar.extract({:binary, body}, [:memory]) for application/x-tar, and :erl_tar.extract({:binary, body}, [:memory, :compressed]) for application/gzip / .tgz. Each returns the full decompressed archive contents as a [{name, bytes}] list in memory, with no per-entry or total size cap. decompress_body/1 walks the content-encoding header and chains :zlib/:brotli/:ezstd decoders, so a response advertising content-encoding: gzip, gzip, gzip inflates through multiple layers without bound.
Both steps are enabled by default, no caller opt-in is required, and the attacker controls the content-type and content-encoding headers on their own server (or on any host reached via Req's automatic redirect following). A sub-megabyte response can expand to multiple gigabytes on the victim, crashing the BEAM process.
This issue affects req: from 0.1.0 before 0.6.1.
📍 영향받는 시스템
wojtekmach Req: 0.1.0 버전부터 0.6.1 미만 버전
⚔️ 공격 벡터
공격자가 조작된 Content-Type 및 Content-Encoding 헤더를 포함한 압축 폭탄 응답을 전송하여 클라이언트의 메모리 고갈 유도
🛡️ 대응 방법
Req 라이브러리를 0.6.1 이상의 최신 버전으로 업데이트하십시오.
🔧 검증 코드
출력된 버전이 0.6.1 미만(예: 0.5.0)이면 취약한 상태이며, 0.6.1 이상이면 안전합니다.
mix deps info req | grep -E 'req \([0-9]+\.[0-9]+\.[0-9]+\)'