Am I affected?

type your req version to check

Description

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.

Weaknesses & attack patterns

Weakness

CWE-409 · Improper Handling of Highly Compressed Data (Data Amplification) in catalog → MITRE ↗

Attack patterns

CAPEC-197 · Exponential Data Expansion MITRE ↗

Affected — Hex / req Hex.pm ↗ Repository ↗

≥ 0.1.0 < 0.6.1 affected
every other version: unaffected
cpe cpe:2.3:a:wojtekmach:req:*:*:*:*:*:*:*:*
version type semver
modules · source files · routines
modules 'Elixir.Req.Steps' · 'Elixir.Req'
source files lib/req/steps.ex · lib/req.ex
routines 'Elixir.Req.Steps':decode_body/1 · 'Elixir.Req.Steps':decompress_body/1 · 'Elixir.Req':decode_body/1 · 'Elixir.Req':decompress/1 · 'Elixir.Req':decode/2 · 'Elixir.Req':decompress/2

Affected — GitHub / wojtekmach/req Repository ↗

≥ e377537 and up affected
→ 84977e5 not affected
→ ea5506f not affected
every other version: unaffected
cpe cpe:2.3:a:wojtekmach:req:*:*:*:*:*:*:*:*
version type git
modules · source files · routines
modules 'Elixir.Req.Steps' · 'Elixir.Req'
source files lib/req/steps.ex · lib/req.ex
routines 'Elixir.Req.Steps':decode_body/1 · 'Elixir.Req.Steps':decompress_body/1 · 'Elixir.Req':decode_body/1 · 'Elixir.Req':decompress/1 · 'Elixir.Req':decode/2 · 'Elixir.Req':decompress/2

Workarounds

Disable Req's automatic body decoding on requests that fetch attacker-influenced URLs by passing decode_body: false to Req.new/1 / Req.get!/1. To also skip the content-encoding decompression pipeline, pass raw: true. Both options leave the response body as the raw on-the-wire bytes, so the caller can size-check before any decompression.

References

Credits

Peter Ullrich Finder
Jonatan Männchen / EEF Analyst
Wojtek Mach Remediation developer

CVSS breakdown

CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Exploitability

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None

Vulnerable System

Confidentiality
None
Integrity
None
Availability
High

Subsequent Systems

Confidentiality
None
Integrity
None
Availability
None
« All CVEs