cookie: reject control octets in cookies loaded from a file#22070
Closed
alhudz wants to merge 1 commit into
Closed
cookie: reject control octets in cookies loaded from a file#22070alhudz wants to merge 1 commit into
alhudz wants to merge 1 commit into
Conversation
bagder
approved these changes
Jun 17, 2026
There was a problem hiding this comment.
Pull request overview
This PR hardens curl’s cookie-jar file loader so it rejects cookies containing control octets in the cookie name or value, aligning file-loaded cookies with the existing filtering applied to cookies received via Set-Cookie headers. It also adds a regression test ensuring such cookies are not emitted in outgoing Cookie: request headers.
Changes:
- Add
invalid_octets()filtering for cookie name/value inparse_netscape()(cookie file ingestion path). - Add new test
test2311that loads a cookie jar containing a value with a control byte and verifies only the clean cookie is sent. - Register
test2311in the testcases list.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/cookie.c |
Drops file-loaded cookies whose name/value contain control octets, matching HTTP cookie parsing rules. |
tests/data/test2311 |
New regression test covering cookie-jar ingestion of a control-octet cookie value. |
tests/data/Makefile.am |
Adds test2311 to the test suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parse_netscape()inlib/cookie.ccopies the cookie name and value straight out of the file without theinvalid_octets()filtering that aSet-Cookieheader goes through. A cookie file whose value holds a control byte (anything0x01-0x1for0x7f) is loaded and then written verbatim into the outgoingCookierequest header, the very bytes that make some servers reject the request and that the HTTP path already drops.Apply the same
invalid_octets()check on the file path, dropping the cookie when its name or value carries a control octet. Putting it in the loader keeps both ingestion paths agreeing on what a valid cookie looks like instead of leaning on the send path to cope.test2311loads a jar with a0x07byte in one value and verifies only the clean cookie reaches the wire.