Sep 16, 2026·5 min read·4 visits
The http4s CookieJar client middleware accepted arbitrary cookie Domain attributes verbatim without verifying if they matched the issuing server's origin. This enables rogue servers to inject cookies for unrelated target domains in applications utilizing shared CookieJar instances.
A validation flaw exists in the CookieJar client middleware of the http4s library. Prior to versions 0.23.35 and 1.0.0-M47, the middleware trusts server-supplied Domain attributes in HTTP Set-Cookie response headers without confirming that the domain matches the origin host. A malicious server can leverage this to register unauthorized cookies targeting different domains, creating potential session fixation or cookie poisoning vectors.
The http4s library provides minimal, idiomatic Scala interfaces for HTTP services, including client-side middleware utilities. One such utility is the CookieJar client middleware, which allows applications to programmatically maintain and manage HTTP cookies across sequential HTTP requests.
Prior to the security fixes implemented in versions 0.23.35 and 1.0.0-M47, the CookieJar middleware failed to perform proper domain matching checks when processing the Set-Cookie header in HTTP responses. According to security specifications, client agents must prevent servers from setting cookies for domains outside of their immediate authority (e.g., attacker.com setting a cookie for targetbank.com).
Because the middleware unconditionally accepted the server-provided Domain attribute, any system using a shared CookieJar instance to access multi-tenant environments, web scraping endpoints, or proxy destinations was vulnerable to cookie injection. Attackers could plant custom session states or bypass integrity protection on critical target domains.
The vulnerability stems from a violation of RFC 6265 Section 5.3 Step 6. Under this specification, a client user-agent must reject cookie Domain attributes that do not domain-match the origin host that supplied the cookie. The purpose of this check is to prevent hostile servers from registering cookies targeting arbitrary scopes.
In the vulnerable http4s implementation, the extractFromResponseCookie function parsed incoming response cookies and registered them using the following logic:
c.domain.orElse(uri.host.map(_.value)) match {
case Some(domainS) =>
val key = CookieKey(c.name, domainS, c.path)
val newCookie = c.copy(domain = domainS.some)
m + (key -> CookieValue(newCookie, httpDate))
}If the cookie parsed from the response (c.domain) contained a custom Domain attribute, the code assigned it directly as the storage key's domain (domainS), skipping any validation against the actual origin host (uri.host). Consequently, an HTTP client querying multiple destinations could have its state polluted by a single compromised or malicious server.
The vulnerability was mitigated in commit 87535f7288f3baaf6736e2735087e473762b5b2f by validating the parsed cookie domain against the origin host prior to storage.
// Patched logic in CookieJar.scala
private[middleware] def extractFromResponseCookie(
m: Map[CookieKey, CookieValue]
)(c: ResponseCookie, httpDate: HttpDate, uri: Uri): Map[CookieKey, CookieValue] = {
val storedDomain = c.domain match {
case Some(d) =>
// Confirm that the response host exists and domain-matches the attribute
if (uri.host.exists(domainMatches(_, d))) Some(d) else None
case None =>
uri.host.map(_.value)
}
storedDomain match {
case Some(domainS) =>
val key = CookieKey(c.name, domainS, c.path)
val newCookie = c.copy(domain = domainS.some)
m + (key -> CookieValue(newCookie, httpDate))
case None => // Ignore Cookies We Can't get a domain for
m
}
}The patched version checks if the target domain (d) matches the host using domainMatches. If the domain is not authoritative for the current origin host, it is set to None, which safely discards the unauthorized cookie registration.
Despite this fix, a key security limitation remains. The library does not implement Public Suffix List (PSL) validation. Therefore, a server hosted on a shared public suffix (such as victim.github.io) is still technically capable of planting a cookie for the entire public suffix wildcard (github.io). Multi-tenant application designs must remain cautious when sharing a single CookieJar context across tenant boundaries.
To execute this attack, the client must use a single CookieJar instance to send requests to both the attacker-controlled server and the victim domain. This is common in automation platforms, crawlers, or services routing traffic for multiple users.
First, the attacker provisions a session identifier (attacker_id) on the target web application (target.com). Next, when the victim's client makes an outbound connection to attacker.com, the attacker's server responds with an unauthorized cookie instruction specifying the target domain:
HTTP/1.1 200 OK
Set-Cookie: session=attacker_id; Domain=target.com; Path=/; Secure; HttpOnlyBecause the vulnerable client registers this cookie without validating the origin, the local cookie jar maps session=attacker_id under target.com. When the client subsequently requests resource paths on target.com, the client transmits the injected cookie, completing the session fixation vector.
To resolve this security issue, software developers must update their project dependencies to the appropriate patched releases. The official fixes have been backported to standard release lines.
For systems utilizing the 0.23.x release series, update the dependency to 0.23.35:
libraryDependencies += "org.http4s" %% "http4s-client" % "0.23.35"For systems utilizing the 1.0.x pre-release series, update the dependency to 1.0.0-M47:
libraryDependencies += "org.http4s" %% "http4s-client" % "1.0.0-M47"If upgrading dependencies is not immediately feasible, developers must isolate CookieJar instances. Avoid sharing a single client context across requests to different administrative domains. Instantiating distinct client instances or unique cookie jars per remote target host isolates states and prevents cross-origin data pollution.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
http4s-client http4s | < 0.23.35 | 0.23.35 |
http4s-client http4s | >= 1.0.0-M1, < 1.0.0-M47 | 1.0.0-M47 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-384 / CWE-565 |
| Attack Vector | Network |
| CVSS v3.1 Score | 6.8 (Medium) |
| Exploit Maturity | None (No public exploit modules) |
| CISA KEV Status | Not Listed |
| Impact | Session Fixation / Cookie Tampering |
Session Fixation occurs when an attacker establishes a known session identifier on a victim's system, and then tricks the victim's browser into using that identifier when authenticating to a target application.
CVE-2026-61598 is a high-severity mass-assignment vulnerability (CWE-915) affecting the Python package djust prior to version 1.0.7. An authenticated client can supply arbitrary parameter names to modify public view attributes on the server via WebSocket events, leading to unauthorized state manipulation, authorization bypass, or price tampering.
An uncontrolled resource consumption vulnerability (CVE-2026-69213) in the http4s Ember HTTP/2 server and client implementations allows unauthenticated remote attackers to trigger an OutOfMemoryError (OOM) and cause a Denial of Service (DoS) by exploiting unbounded outbound queues.
CVE-2026-60137 is a critical SQL injection vulnerability in the Core component of WordPress. The flaw occurs within the WP_Query class during the processing of the author__not_in parameter, where user-supplied array inputs are constructed into a SQL string without strict integer type-casting. When chained with CVE-2026-63030, an unauthenticated remote attacker can exploit this SQL injection to read database values, extract administrator credential hashes, or modify administrative options to execute arbitrary PHP code on the server.
A medium-severity cross-origin cookie leakage vulnerability exists in the CookieJar client middleware of the http4s library. Due to unanchored substring searches used to determine whether a cookie applies to an outbound request, sensitive cookies (such as session IDs and credentials) can be inadvertently sent to unauthorized domains or paths.
An HTTP Request/Response Smuggling vulnerability (CVE-2026-69216) was identified in the Ember chunked transfer encoding decoder of the http4s Scala library. Due to parser leniency accepting sign prefixes, surrounding whitespace, and missing trailing CRLFs, attackers can bypass proxy security boundaries, poison shared caches, or hijack request queues.
A critical resource exhaustion vulnerability exists in the http4s Ember HTTP/2 server and client implementations. By failing to limit the size or quantity of incoming HTTP/2 CONTINUATION frames, the engine allows unauthenticated remote attackers to exhaust JVM heap memory, causing a complete Denial of Service.