Skip to content

http: reject empty header names - #23292

Closed
cmeister2 wants to merge 1 commit into
masterfrom
fix/dynhds-empty-header-name
Closed

cmeister2 wants to merge 1 commit into
masterfrom
fix/dynhds-empty-header-name

Conversation

@cmeister2

@cmeister2 cmeister2 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Curl_dynhds_add() requires a non-empty header name, but two HTTP paths could pass an empty one. A custom proxy header such as --proxy-header " : ignored" becomes empty after trimming, while an HTTP/1 header line beginning with : has a zero-length name from the outset. In debug builds, either path can reach the assertion in Curl_dynhds_add().

Reject the invalid HTTP/1 line and ignore the malformed custom proxy header, consistent with the existing handling of unusable custom-header entries. The low-level assertion remains in place.

The abort was exposed by 1c9f1f4c3f88 (dynhds: check size overflows, #23210), which added the non-empty-name assertion. Both malformed caller paths predate that check. curl-fuzzer CI found the regression.

Add regression coverage for the parser and proxy CONNECT paths.

Tested with a debug CMake build:

  • tests/runtests.pl 2602 1428
  • scripts/checksrc-all.pl
  • scripts/spacecheck.pl
  • scripts/badwords-all

A custom proxy header can have a non-empty name that becomes empty after
trimming. An HTTP/1 header line can also start with a colon. Reject these
inputs before they reach Curl_dynhds_add(), which requires a non-empty
name.

Keep custom proxy headers consistent with existing behavior by ignoring
the malformed entry. Return CURLE_BAD_FUNCTION_ARGUMENT from the HTTP/1
parser.

Add unit and proxy CONNECT regression coverage.

Follow-up to 1c9f1f4
Ref: curl/curl-fuzzer#409

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.

Copilot review overview

🟢 Approval recommended

The validation changes are correctly placed and covered by focused regression tests.

Review effort: Balanced
Findings: None

What changed in this PR

Rejects empty HTTP header names before they reach Curl_dynhds_add() assertions.

Changes:

  • Rejects colon-leading HTTP/1 headers.
  • Ignores proxy headers whose names become empty after trimming.
  • Adds regression coverage for both paths.
File Description
lib/​dynhds.c Rejects zero-length HTTP/1 header names.
lib/​http_proxy.c Skips empty trimmed proxy-header names.
tests/​unit/​unit2602.c Tests rejection without header insertion.
tests/​data/​test1428 Tests malformed proxy-header omission.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cmeister2
cmeister2 requested a review from icing October 6, 2026 21:39
@jay jay closed this in 36a582d Oct 7, 2026
@jay

jay commented Oct 7, 2026

Copy link
Copy Markdown
Member

Thanks

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

Labels

Development

Successfully merging this pull request may close these issues.

4 participants