Skip to content

capsule: reject a capsule that can never be buffered - #22998

Closed
MegaManSec wants to merge 1 commit into
curl:masterfrom
MegaManSec:capsule-reject-oversized
Closed

MegaManSec wants to merge 1 commit into
curl:masterfrom
MegaManSec:capsule-reject-oversized

Conversation

@MegaManSec

Copy link
Copy Markdown
Contributor

Curl_capsule_process_udp_raw() checked whether the full advertised payload
was buffered before checking whether it fits anywhere. cf_capsule_recv()
stops filling at Curl_bufq_is_full() (4 x 16 KiB), so a peer advertising a
length the queue can never hold leaves the decoder returning CURLE_AGAIN
indefinitely while consuming nothing. cf_capsule_data_pending() keeps
reporting data, since the queue is non-empty.

Reordering alone is not enough: QUIC_TUNNEL_INBUF_SIZE is also 64 KiB, so a
length just under it passes the destination-buffer check and still cannot be
buffered. Fail when the queue is full and still short of the capsule.

Also bound the length against SIZE_MAX - offset so offset + payload_len
cannot wrap on 32-bit.

HTTP/3 proxy support is experimental and off by default, so this is a plain
bug, not a security issue.

@github-actions github-actions Bot added the HTTP/3 h3 or quic related label Sep 18, 2026
@bagder
bagder requested a balanced review from Copilot September 18, 2026 20:55

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.

🟡 Changes recommended

The new full-queue rejection path needs regression coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Prevents capsule decoding from retrying indefinitely when an advertised payload cannot fit the receive queue.

Changes:

  • Rejects incomplete capsules once the receive queue is full.
  • Prevents offset + payload_len overflow.
File summaries
File Description
lib/vquic/capsule.c Adds size and full-buffer validation for capsule payloads.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

Comment thread lib/vquic/capsule.c
The decoder waited for the full advertised payload before checking that
it fits anywhere, so a peer advertising a length the receive queue can
never hold made cf_capsule_recv() return CURLE_AGAIN forever.

Check the destination buffer first and fail when the receive queue is
full and still short of the capsule. Also bound the length so that
offset + payload_len cannot wrap.

Add a unit3400 case for the full-queue rejection.
@MegaManSec
MegaManSec force-pushed the capsule-reject-oversized branch from 9358638 to 4bc4748 Compare September 18, 2026 21:39
@github-actions github-actions Bot added the tests label Sep 18, 2026
@bagder bagder closed this in 7934b54 Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HTTP/3 h3 or quic related tests

Development

Successfully merging this pull request may close these issues.

3 participants