Skip to content

urldata: move cookiehost to struct SingleRequest#21312

Closed
bagder wants to merge 4 commits into
masterfrom
bagder/cookiehost
Closed

urldata: move cookiehost to struct SingleRequest#21312
bagder wants to merge 4 commits into
masterfrom
bagder/cookiehost

Conversation

@bagder

@bagder bagder commented Apr 14, 2026

Copy link
Copy Markdown
Member

To make it scoped for the single request appropriately.

Reported-by: Muhamad Arga Reksapati

Verify with libtest 2504: a custom Host disabled on reused handle

@bagder bagder marked this pull request as ready for review April 14, 2026 09:18
@bagder bagder requested a review from Copilot April 14, 2026 14:19
To make it scoped for the single request appropriately.

Reported-by: Muhamad Arga Reksapati

Verify with libtest 2504: a custom Host *disabled* on reused handle

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a cookie/Host header scoping issue by moving cookiehost from UrlState to SingleRequest, and adds a regression test to ensure a custom Host: value does not persist across reused easy handles.

Changes:

  • Move cookiehost storage to struct SingleRequest and update HTTP cookie/Set-Cookie logic to use it.
  • Update cleanup/reset paths to free request-scoped cookiehost.
  • Add libtest + test case 2504 to validate behavior when reusing a handle after removing a custom Host: header.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/urldata.h Removes cookiehost from UrlState allocated pointer set.
lib/request.h Adds cookiehost to struct SingleRequest.
lib/request.c Frees req->cookiehost during hard reset.
lib/http.c Stores/uses data->req.cookiehost for cookie host decisions.
lib/url.c Updates easy-handle close cleanup to free data->req.cookiehost.
tests/libtest/lib2504.c New libtest exercising handle reuse with/without custom Host:.
tests/libtest/Makefile.inc Registers lib2504.c in the libtest build.
tests/data/test2504 New test definition verifying request headers across two performs.
tests/data/Makefile.am Registers test2504 in the test suite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/url.c
Comment thread tests/libtest/lib2504.c Outdated
Comment thread lib/http.c
@bagder bagder force-pushed the bagder/cookiehost branch from cb5b2b8 to 04bffc4 Compare April 14, 2026 14:39
@bagder bagder closed this in 3a19987 Apr 14, 2026
@bagder bagder deleted the bagder/cookiehost branch April 14, 2026 14:59
icanhasmath pushed a commit to ActiveState/curl that referenced this pull request May 29, 2026
To make it scoped for the single request appropriately.

Reported-by: Muhamad Arga Reksapati

Closes curl#21312

(cherry picked from commit 3a19987)

Backport to 8.17.0 to address CVE-2026-6276 (a custom Host: header set on
a first request was stored in the persistent state.aptr.cookiehost; a
second request on the same easy handle without the custom Host: header
would then reuse that stale value and send cookies meant for the first
host). The fix moves cookiehost from the persistent struct UrlState aptr
to the per-request struct SingleRequest (data->req), which is reset for
each request, and clears it at the top of http_set_aptr_host() before it
may be set again.

Adapted to 8.17.0: curlx_safefree()/curlx_free() replaced with
Curl_safefree()/free(); the cookiehost free was added to
Curl_req_hard_reset() (8.17.0 has no req->proxyuserpwd anchor). Test 2504
omitted (newer libtest infrastructure).
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
To make it scoped for the single request appropriately.

Reported-by: Muhamad Arga Reksapati

Verify with libtest 2504: a custom Host *disabled* on reused handle

Closes curl#21312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants