{"id":"CVE-2021-41084","aliases":["GHSA-5vcm-3xc3-w7x3"],"url":"https://o3.security/vulnerability/CVE-2021-41084","summary":"Response Splitting from unsanitized headers","details":"### Impact\n\nhttp4s is vulnerable to response-splitting or request-splitting attacks when untrusted user input is used to create any of the following fields:\n\n* Header names (`Header.name`å\n* Header values (`Header.value`)\n* Status reason phrases (`Status.reason`)\n* URI paths (`Uri.Path`)\n* URI authority registered names (`URI.RegName`) (through 0.21)\n\nThe following backends render invalid carriage return, newline, or null characters in an unsafe fashion.\n\n|                | blaze-server | ember-server | blaze-client | ember-client | jetty-client |\n|:---------------|:-------------|:-------------|:-------------|--------------|--------------|\n| header names   | ⚠            | ⚠            | ⚠            | ⚠            |   ⚠            | \n| header values  | ⚠            | ⚠            | ⚠            | ⚠            |              |\n| status reasons | ⚠            | ⚠            |              |              |              |\n| URI paths      |              |              |  ⚠             |  ⚠             |              |\n| URI regnames   |              |              |  ⚠ < 0.22           |  ⚠ < 0.22            |              |\n\nFor example, given the following service:\n\n```scala\nimport cats.effect._\nimport org.http4s._\nimport org.http4s.dsl.io._\nimport org.http4s.server.blaze.BlazeServerBuilder\nimport scala.concurrent.ExecutionContext.global\n\nobject ResponseSplit extends IOApp {\n  override def run(args: List[String]): IO[ExitCode] =\n    BlazeServerBuilder[IO](global)\n      .bindHttp(8080)\n      .withHttpApp(httpApp)\n      .resource\n      .use(_ => IO.never)\n\n  val httpApp: HttpApp[IO] =\n    HttpApp[IO] { req =>\n      req.params.get(\"author\") match {\n        case Some(author) =>\n          Ok(\"The real content\")\n            .map(_.putHeaders(Header(\"Set-Cookie\", s\"author=${author}\")))\n        case None =>\n          BadRequest(\"No author parameter\")\n      }\n    }\n}\n```\n\nA clean `author` parameter returns a clean response:\n\n```sh\ncurl -i 'http://localhost:8080/?author=Ross'\n```\n\n```http\nHTTP/1.1 200 OK\nContent-Type: text/plain; charset=UTF-8\nSet-Cookie: author=Ross\nDate: Mon, 20 Sep 2021 04:12:10 GMT\nContent-Length: 16\n\nThe real content\n```\n\nA malicious `author` parameter allows a user-agent to hijack the response from our server and return different content:\n\n```sh\ncurl -i 'http://localhost:8080/?author=hax0r%0d%0aContent-Length:+13%0d%0a%0aI+hacked+you'\n```\n\n```http\nHTTP/1.1 200 OK\nContent-Type: text/plain; charset=UTF-8\nSet-Cookie: author=hax0r\nContent-Length: 13\n\nI hacked you\n```\n\n### Patches\n\nVersions 0.21.29, 0.22.5, 0.23.4, and 1.0.0-M27 perform the following:\n\n* If a status reasoon phrase is invalid, it is dropped. Rendering is optional per spec.\n* If a header name is invalid in a request or response, the header is dropped.  There is no way to generically sanitize a header without potentially shadowing a correct one.\n* If a header value is invalid in a request or response, it is sanitized by replacing null (`\\u0000`), carriage return (`\\r`), and newline (`\\n`) with space (` `) characters per spec.\n* If a URI path or registered name is invalid in a request line, the client raises an `IllegalArgumentException`.\n* If a URI registered name is invalid in a host header, the client raises an `IllegalArgumentException`. \n\n### Workarounds\n\nhttp4s services and client applications should sanitize any user input in the aforementioned fields before returning a request or response to the backend.  The carriage return, newline, and null characters are the most threatening.\n\nNot all backends were affected: jetty-server, tomcat-server, armeria, and netty on the server; async-http-client, okhttp-client, armeria, and netty as clients.\n\n### References\n* https://owasp.org/www-community/attacks/HTTP_Response_Splitting\n* https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#fields.values\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [GitHub](http://github.com/http4s/http4s)\n* Contact us via the [http4s security policy](https://github.com/http4s/http4s/security/policy)","published":"2021-09-21T18:15:07.427Z","modified":"2026-07-09T12:20:26.529295Z","cvss":{"score":4.7,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N"},"epss":{"score":0.01235,"percentile":0.67582,"asOf":"2026-09-17"},"cisaKev":null,"exploitsKnown":1,"affectedPackages":[{"ecosystem":"Maven","name":"org.http4s:http4s-client_2.12","fixedVersion":"0.21.29"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_2.12","fixedVersion":"0.22.5"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_2.12","fixedVersion":"0.23.4"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_2.13","fixedVersion":"0.21.29"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_2.13","fixedVersion":"0.22.5"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_2.13","fixedVersion":"0.23.4"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_3","fixedVersion":"0.21.29"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_3","fixedVersion":"0.22.5"},{"ecosystem":"Maven","name":"org.http4s:http4s-client_3","fixedVersion":"0.23.4"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.10","fixedVersion":null},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.11","fixedVersion":null},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.12","fixedVersion":"0.21.29"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.12","fixedVersion":"0.22.5"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.12","fixedVersion":"0.23.4"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.13","fixedVersion":"0.21.29"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.13","fixedVersion":"0.22.5"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.13","fixedVersion":"0.23.4"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_2.13.0-M5","fixedVersion":null},{"ecosystem":"Maven","name":"org.http4s:http4s-server_3","fixedVersion":"0.22.5"},{"ecosystem":"Maven","name":"org.http4s:http4s-server_3","fixedVersion":"0.23.4"}],"fix":{"url":"https://github.com/http4s/http4s/commit/d02007db1da4f8f3df2dbf11f1db9ac7afc3f9d8","label":"http4s/http4s@d02007d"},"references":[{"type":"ADVISORY","url":"https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#fields.values"},{"type":"ADVISORY","url":"https://owasp.org/www-community/attacks/HTTP_Response_Splitting"},{"type":"FIX","url":"https://github.com/http4s/http4s/commit/d02007db1da4f8f3df2dbf11f1db9ac7afc3f9d8"},{"type":"EVIDENCE","url":"https://github.com/http4s/http4s/security/advisories/GHSA-5vcm-3xc3-w7x3"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41084"},{"type":"PACKAGE","url":"https://github.com/http4s/http4s"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-07-09T12:20:26.529295Z"}}