CVE-2026-47072: Hackney has CRLF / header injection in WebSocket upgrade request
Summary CRLF injection in hackney's WebSocket upgrade request builder (src/hackneyws.erl). init/1 copies the host, path, headers, and protocols options from the caller-supplied opts map verbatim into #wsdata{}, and dohandshake/1 splices them directly into the raw HTTP/1.1 upgrade request by binary concatenation with no \r\n or \0 stripping.
Published Jun 26, 2026
Affected packages
hackney
- Ecosystem
- Erlang (Hex)
- Affected
- >= 2.0.0, < 4.0.1
- Fixed in
- 4.0.1
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
CRLF injection in hackney's WebSocket upgrade request builder (src/hackney_ws.erl). init/1 copies the host, path, headers, and protocols options from the caller-supplied opts map verbatim into #ws_data{}, and do_handshake/1 splices them directly into the raw HTTP/1.1 upgrade request by binary concatenation with no \r\n or \0 stripping. A caller that passes any of these fields from untrusted input can inject arbitrary header lines into the outbound upgrade request.
Details
do_handshake/1 builds the upgrade request at several concatenation sites:
- Host header (lines 583–590): the host binary is written straight into
Host: <host>:<port>\r\n. - Sec-WebSocket-Protocol (lines 601–602): protocol tokens are joined with
,and appended as a header line. - Extra headers (line 606): caller-supplied
{Name, Value}tuples are concatenated asName: Value\r\nwith no sanitization of either component. - Request path (line 611): the path is interpolated into the
GET <path> HTTP/1.1\r\nrequest line.
None of these sites reject \r, \n, or \0. A header value like <<"benign\r\nAuthorization: Bearer token">> produces two distinct header lines on the wire. A path with an embedded \r\n rewrites the request line itself.
PoC
- Call
:hackney_ws.start_link/1withheaders: [{"X-User", "v\r\nAuthorization: Bearer attacker"}]. - Connect to a raw TCP listener and capture the bytes hackney writes.
- The request contains a standalone
Authorization: Bearer attackerline that the upstream WebSocket server parses as a legitimate header.
Impact
Header injection / request smuggling in outbound WebSocket upgrades. Affects hackney 2.0.0 through 4.0.0 wherever host, path, headers, or protocols options are populated from network or user input. Consequences include forging authentication headers toward the upstream server, log and cache poisoning, and request smuggling through intermediary proxies. CVSS v4.0: 6.9 (MEDIUM).
Resources
- Introduction commit: https://github.com/benoitc/hackney/commit/690cecaf236fba49526da404a5bc889a24367a3e
- Patch commit: https://github.com/benoitc/hackney/commit/52310ca807e7b48441ba0e9129171f535313fdd1
Credited to PJUllrich, maennchen.
References
- https://github.com/benoitc/hackney/security/advisories/GHSA-f9vr-g2g2-x9fg
- https://nvd.nist.gov/vuln/detail/CVE-2026-47072
- https://github.com/benoitc/hackney/commit/52310ca807e7b48441ba0e9129171f535313fdd1
- https://cna.erlef.org/cves/CVE-2026-47072.html
- https://osv.dev/vulnerability/EEF-CVE-2026-47072
- https://github.com/advisories/GHSA-f9vr-g2g2-x9fg
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Erlang (Hex) vulnerabilities
All Erlang (Hex) entriesCVE-2026-47066
Hackney has an infinite loop on non-token byte at start of an Alt-Svc entry
high8.7Jun 26, 2026CVE-2026-47067
Hackney vulnerable to atom-table exhaustion via unrecognized URL schemes
high8.7Jun 26, 2026CVE-2026-47069
Hackney has CRLF / header injection via unvalidated `domain` and `path` options
low2.1Jun 26, 2026CVE-2026-47070
Hackney: Cross-origin Redirect Leaks Authorization, Cookie, and Request Body
medium6.0Jun 26, 2026CVE-2026-47071
Hackney: `ssl:connect/2` post-handshake upgrade has no timeout
high8.2Jun 26, 2026CVE-2026-47073
Hackney has unbounded buffer accumulation in WebSocket
high8.7Jun 26, 2026
