Skip to content

sapi/cli: guard Content-Length overflow and enforce post_max_size#58

Closed
iliaal wants to merge 1 commit into
masterfrom
fix/gh-22003-cli-server-content-length
Closed

sapi/cli: guard Content-Length overflow and enforce post_max_size#58
iliaal wants to merge 1 commit into
masterfrom
fix/gh-22003-cli-server-content-length

Conversation

@iliaal
Copy link
Copy Markdown
Owner

@iliaal iliaal commented May 11, 2026

The dev server crashes when Content-Length wraps ssize_t (30+ digit value), or when a legitimately large Content-Length passes pemalloc and aborts the process.

Guard the parser's Content-Length and chunked-size accumulators against SSIZE_MAX, then reject oversize Content-Length in on_headers_complete and reply 413 with the configured post_max_size in the body.

Fixes php#22003

The dev server's HTTP parser accumulates Content-Length digits into an
ssize_t without an overflow check; a 30-digit value wraps and the
consumer aborts on pemalloc. Guard the decimal and chunked-size
accumulators against SSIZE_MAX, then reject in on_headers_complete when
the parsed length exceeds post_max_size and reply 413 with the
configured limit in the body.

Fixes phpGH-22003
@iliaal iliaal force-pushed the fix/gh-22003-cli-server-content-length branch from 21036f4 to 612aa33 Compare May 11, 2026 23:35
@iliaal
Copy link
Copy Markdown
Owner Author

iliaal commented May 12, 2026

Submitted upstream as php#22017

@iliaal iliaal closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote DoS via overflowed Content-Length

1 participant