GHSA-F283-GHQC-FG79: Partial fix review for Guzzle cookie jar DoS
Summary
The supplied patch material does not address the stated denial-of-service issue involving unbounded cookie jar growth and oversized Cookie headers. Instead, the diffs primarily fix redirect Referer fragment stripping and cookie host-only/domain identity handling plus persistence format hardening. Those are valid security and correctness improvements, but they do not introduce resource bounds, eviction, per-domain limits, or header-size controls needed to mitigate the advisory’s described DoS condition.
Analysis
Vulnerability
GHSA-F283-GHQC-FG79 describes a denial-of-service condition where a malicious server can cause a client-side cookie jar to accumulate excessive cookie state, eventually producing oversized Cookie request headers that downstream servers reject with HTTP 431/400. The core security property required by the fix is bounded resource consumption: limits on cookie count, size, scope, persistence, or outbound header construction.
The provided patch set from PR #3901 does not show such controls. The visible changes fall into two different areas: redirect Referer sanitization and cookie host-only semantics/persistence correctness. Neither area introduces explicit caps on cookie jar growth or outbound cookie header size.
// Redirect change shown in the patch set
$uri = $request->getUri()->withUserInfo('')->withFragment('');
// Cookie identity change shown in the patch set
private function removeCookie(SetCookie $cookie): void
{
$this->cookies = \array_filter(
$this->cookies,
static function (SetCookie $stored) use ($cookie): bool {
return !($stored->getName() === $cookie->getName()
&& $stored->getPath() === $cookie->getPath()
&& $stored->getDomain() === $cookie->getDomain()
&& $stored->getHostOnly() === $cookie->getHostOnly());
}
);
}Based on the supplied sources, the patch does not demonstrate mitigation of the advisory’s stated root cause: unbounded cookie storage and header emission.
Patch
The patch content in the referenced pull request contains three substantive themes:
- Redirect Referer hardening:
RedirectMiddlewarenow strips URI fragments in addition to user info before generating aRefererheader, and documentation/tests were updated accordingly. - Cookie host-only identity preservation:
SetCookiegains aHostOnlyboolean, cookie matching logic distinguishes host-only cookies from domain cookies, andCookieJarremoval logic now keys onname + path + domain + hostOnlyinstead of collapsing those identities. - Persistent jar format validation:
FileCookieJarandSessionCookieJarnow persist an explicitHostOnlymarker and reject legacy/nonconforming records lacking that boolean.
These changes are technically coherent for cookie correctness and persistence safety. The new tests verify coexistence of host-only and domain cookies with the same name, exact deletion behavior, and persistence/load validation. However, the patch excerpts do not show any of the controls expected for a resource-exhaustion fix, such as:
- maximum cookies per jar or per domain,
- maximum individual cookie size,
- maximum aggregate outbound
Cookieheader size, - eviction policy for excess cookies,
- refusal to store attacker-supplied cookies beyond configured thresholds.
Review
Pros
- The cookie model is more RFC-aligned: host-only cookies are now represented explicitly and no longer conflated with domain cookies.
- Deletion semantics are more precise because
removeCookie()includesHostOnlyin the identity comparison. - Persistence is safer and less ambiguous:
FileCookieJarandSessionCookieJarreject records missing the explicitHostOnlymarker, preventing silent reinterpretation of stored cookie scope. - Tests are strong for the behavior actually changed, especially coexistence and exact deletion of host-only versus domain cookies.
- The redirect fragment stripping change is a legitimate security improvement, as reflected in the updated docs and tests in PR #3901.
Cons
- The patch does not appear to implement any resource bounds relevant to the advisory summary in the GHSA.
- No visible logic limits cookie accumulation in memory, on disk, or in session persistence.
- No visible logic constrains the size of the generated
Cookierequest header before sending requests. - The changelog snippets shown are partly unrelated to the stated DoS issue, which makes traceability from advisory to fix weak.
- Rejecting older persisted cookie data without migration may be operationally disruptive, while still not addressing the described denial-of-service vector.
Verdict
Partial fix.
The supplied patch improves cookie correctness and persistence integrity, but it does not, from the provided diffs, remediate the stated denial-of-service mechanism of unbounded cookie jar resource exhaustion. If the vulnerability is accurately summarized by the report and the advisory, then the root cause remains unaddressed unless additional unshown commits add hard limits or eviction behavior.
For a complete fix, engineers should expect explicit enforcement points in cookie ingestion and request emission paths: cap cookie count per origin and globally, cap aggregate header size, reject or evict excess cookies deterministically, and add regression tests that simulate attacker-controlled Set-Cookie floods leading to oversized outbound headers.
Recommended Labs
Try this vulnerability pattern yourself with hands-on labs.
- Energy.php
Closest hands-on defensive match for this Guzzle advisory because it maps to CWE-770/CWE-400 style uncontrolled resource consumption and denial-of-service conditions. It helps practice adding bounds and defensive controls to prevent request-processing exhaustion, which is directly relevant to unbounded cookie jar growth and oversized outbound headers.
- No Sutpo.php
Another PHP-focused lab aligned to CWE-770/CWE-400 themes. Recommended because the Guzzle issue is fundamentally about missing limits and defensive validation around attacker-influenced state. This lab reinforces secure coding patterns such as enforcing quotas, rejecting abusive inputs, and hardening request handling paths against exhaustion.
- OWASP Top 10
As an easier PHP defensive lab, this is a good warm-up if you want to build secure coding habits before the medium resource-exhaustion labs. While not cookie-jar-specific, it still supports the same learning goal: recognizing parser and input-handling weaknesses early and applying bounded, defensive fixes. For broader learning, pair these labs with SecDim Learn's OWASP Top 10 course at https://learn.secdim.com/course/owasp-top-10.