Skip to content

fix(http): fix server crash on chunked transfer encoding with overflowing chunk size#6802

Merged
bluestreak01 merged 2 commits intomasterfrom
vi_fix_chunked
Feb 23, 2026
Merged

fix(http): fix server crash on chunked transfer encoding with overflowing chunk size#6802
bluestreak01 merged 2 commits intomasterfrom
vi_fix_chunked

Conversation

@bluestreak01
Copy link
Copy Markdown
Member

@bluestreak01 bluestreak01 commented Feb 23, 2026

This issue was discovered by Team Atlanta (@LeeSinLiang) 👍

Summary

ChunkedContentParser.parseChunkLength() had no overflow guard on the hex
chunk-size parsing loop. A crafted HTTP request with 16+ hex digits in the
chunk size overflows the long chunkSize to a negative value, which corrupts
the internal buffer pointer. On the next loop iteration isEol() dereferences
the corrupted pointer and the JVM crashes with SIGSEGV.

This is reachable over the network with an unauthenticated POST request
using Transfer-Encoding: chunked. The HTTP header parser does not validate
chunk sizes — that happens entirely in ChunkedContentParser, which processes
body data after headers pass validation.

The fix adds an overflow guard before each chunkSize * 16 accumulation step:
if chunkSize > Long.MAX_VALUE >>> 4, the next multiply would overflow a
positive long, so the input is rejected as a protocol violation. The server
logs the violation and disconnects the client cleanly.

Test plan

  • Add ChunkedContentParserTest with 9 unit tests covering:
    • Original PoC payload (16 hex d digits)
    • All f digits overflow (0xFFFFFFFFFFFFFFFF = -1)
    • 17 hex digits (always exceeds 64 bits)
    • Exact overflow boundary (MAX_CHUNK_SIZE_BEFORE_SHIFT + 1)
    • Largest accepted value (Long.MAX_VALUE = 16 hex digits 7fffffffffffffff)
    • 15 hex f digits (below boundary, must be accepted)
    • Overflow in a second chunk (exercises skipEol=false path, verifies first chunk data delivered correctly)
    • Normal single-chunk and multi-chunk parsing (sanity checks)
  • Verify with network-level PoC that the patched server rejects the malicious request and stays up

🤖 Generated with Claude Code

@bluestreak01 bluestreak01 added Bug Incorrect or unexpected behavior REST API Issues or changes relating to the HTTP endpoints Security labels Feb 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vi_fix_chunked

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 9 / 9 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/cutlass/http/ChunkedContentParser.java 9 9 100.00%

@bluestreak01 bluestreak01 merged commit f353964 into master Feb 23, 2026
46 checks passed
@bluestreak01 bluestreak01 deleted the vi_fix_chunked branch February 23, 2026 18:42
maciulis pushed a commit to maciulis/questdb that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior REST API Issues or changes relating to the HTTP endpoints Security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants