Sep 16, 2026·6 min read·39 visits
An unanchored substring matching flaw in http4s's CookieJar client middleware allows session cookies to be leaked to attacker-controlled origins during outbound HTTP requests.
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.
The vulnerability lies within the client-side CookieJar middleware of the http4s library. http4s is a functional, streaming HTTP interface for Scala applications. When the CookieJar middleware is enabled, it acts as an automated repository for maintaining HTTP cookies across sequential requests.
The vulnerability is categorized as a failure to validate authority boundaries during cookie retrieval and propagation. In standard HTTP client implementations, cookie scoping must strictly adhere to the domain-matching and path-matching criteria defined in RFC 6265. This boundary ensures that sensitive authorization cookies are never transmitted to unauthorized origins.
Instead of implementing RFC 6265 compliant matching logic, the client middleware historically relied on unanchored substring comparisons. This mechanism causes the client to send sensitive cookies to unauthorized third-party domains or incorrect sub-paths under specific conditions. As a result, any application performing outbound requests to external, user-supplied, or redirected destinations is vulnerable to credential exposure.
The root cause of the cookie leakage is located in the cookieAppliesToRequest method inside the companion object of the CookieJar class. This method validates whether a stored ResponseCookie should be appended to a new outbound Request based on three main properties: the host domain, the path, and the connection security.
To determine domain eligibility, the vulnerable code evaluates if the requested URI host authority contains the cookie's domain attribute as a substring. It performs this evaluation using the Scala .contains method. Because the check is completely unanchored, a cookie intended for example.com is deemed applicable to any destination host that has example.com as a substring, such as evilexample.com or example.com.attacker.net.
Similarly, the path validation logic compares the target path against the cookie's path attribute using another unanchored .contains check. If a cookie is restricted to /admin, the middleware will attach it to requests heading to /administrator or /public/admin-docs. This violates path boundary rules and permits cross-path session exposure.
The following diagram illustrates how the vulnerable validation logic permits unauthorized cross-origin transmission of cookies.
The code-level flaw is visible when comparing the vulnerable and patched implementations within CookieJar.scala. The vulnerable version evaluates both domain and path matching purely as raw string containment checks. This logic ignores structural boundaries such as dot delimiters in domains or slashes in paths.
// Vulnerable Implementation
private[middleware] def cookieAppliesToRequest[N[_]](
r: Request[N],
c: ResponseCookie,
): Boolean = {
val domainApplies = c.domain.exists(s =>
r.uri.host.forall { authority =>
authority.renderString.contains(s) // Fails on evilexample.com
}
)
val pathApplies = c.path.forall(s => r.uri.path.renderString.contains(s)) // Fails on /administrator
// ...
}To correct this vulnerability, the maintainers implemented helper methods called domainMatches and pathMatches which closely align with the rules of RFC 6265. These functions enforce exact matches, proper subdomain delegation, and path-segment boundaries.
// Patched Implementation
private def domainMatches(host: Uri.Host, cookieDomain: String): Boolean = {
val requestHost = host.value.toLowerCase(Locale.ROOT)
val domain = cookieDomain.toLowerCase(Locale.ROOT).stripPrefix(".")
domain.nonEmpty && {
host match {
case _: Uri.Ipv4Address | _: Uri.Ipv6Address =>
requestHost == domain
case _: Uri.RegName =>
requestHost == domain || requestHost.endsWith("." + domain)
}
}
}In the patched domain-matching logic, case folding is explicitly performed using Locale.ROOT to prevent internationalization bypasses. Additionally, IP addresses are restricted to exact equality checks, while standard hostnames are validated to ensure they are either an exact match or a valid subdomain ending with a dot delimiter. This eliminates substring matching on sibling domains.
An attacker can exploit this vulnerability if they can coerce the vulnerable Scala application into dispatching an outbound request to an attacker-controlled destination. Common vectors to achieve this include Server-Side Request Forgery (SSRF) vulnerabilities, user-defined webhooks, or open redirects. The attacker does not need prior authorization to exploit this flaw.
Consider an application that allows users to provide an external image URL for profile customization. If the application first communicates with https://example.com and obtains a session cookie, that cookie is stored in the CookieJar middleware. Subsequent requests initiated by the same client wrapper will reuse this state.
When the application attempts to fetch the attacker's image hosted at http://evilexample.com, the CookieJar matches "evilexample.com" with the stored "example.com" domain. The client then includes the Cookie header in the outbound HTTP request. The attacker's server captures the request headers, thereby compromising the session credentials of the application.
The impact of this vulnerability is the compromise of confidential credentials and session tokens managed by the http4s client. Depending on the architecture, this can lead to privilege escalation or unauthorized system access on behalf of the vulnerable application. If the cookie contains administrative session keys, the entire upstream platform may be compromised.
The Common Vulnerability Scoring System (CVSS) v3.1 base score of 6.8 reflects a Network attack vector with High confidentiality impact and High complexity. The complexity is high because the attacker must find a way to receive outbound traffic from the application and register domain names containing the victim's domain name as a substring. No user interaction is required for the leak to happen.
This vulnerability has not been observed in active exploitation in the wild, and it is not listed in CISA's Known Exploited Vulnerabilities catalog. However, the ease of exploitation once an outbound request trigger exists makes prompt remediation highly recommended. Security teams must treat any client-side cookie leakage as a high-priority exposure.
The primary recommendation is to update the http4s library to a version that implements proper RFC 6265 cookie matching. For the 0.23.x stable branch, update to version 0.23.35 or higher. For the 1.0.x milestone branch, upgrade to 1.0.0-M47 or higher.
If an immediate library upgrade is not possible, you can disable the CookieJar middleware on the client if cookie state management is not required. Avoiding the inclusion of this middleware entirely eliminates the vulnerable code path. Developers should review whether cookie tracking is strictly necessary for client-side API integrations.
Alternatively, you can implement strict outbound request filtering. Enforcing a strict domain allowlist for outbound HTTP connections prevents the client from transmitting requests to arbitrary attacker-controlled hostnames, reducing the risk of cookie exfiltration. This provides defense-in-depth against credential theft.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/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-565, CWE-1275 |
| Attack Vector | Network (AV:N) |
| CVSS v3.1 Score | 6.8 (Medium) |
| EPSS Score | Negligible |
| Impact | High Confidentiality Loss (Cookie Exfiltration) |
| Exploit Status | PoC available in test suite, no weaponized exploits in wild |
| KEV Status | Not listed in CISA KEV |
The system uses information from a cookie to make security-critical decisions without validating the authority boundary of the receiver relative to the cookie's target domain.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.
CVE-2026-128077 (GHSA-r99w-jh2x-3mg9) is an authorization bypass and interpretation conflict vulnerability affecting Nuxt and its underlying @nuxt/nitro-server package in versions 4.6.0 through 4.6.3. When an incoming HTTP request path begins with a double forward slash (e.g., //x/admin), the WHATWG URL parser within the Nuxt server-side page renderer interprets the initial segment as a network host/authority and resolves the remaining path (/admin) against the application's page router. Because Nitro server middleware, route-scoped serverHandlers, and Nitro routeRules evaluate the unparsed request path (//x/admin), path-based access controls, redirects, and security header policies configured for /admin fail to match and are bypassed.