Skip to content

Avoid stale H2 writes after 100 Continue - #13504

Merged
cmcfarlen merged 1 commit into
apache:masterfrom
bneradt:fix-h2-expect-continue-uaf
Aug 7, 2026
Merged

Avoid stale H2 writes after 100 Continue#13504
cmcfarlen merged 1 commit into
apache:masterfrom
bneradt:fix-h2-expect-continue-uaf

Conversation

@bneradt

@bneradt bneradt commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

HttpSM owns the write buffer attached to an HTTP/2 stream. After WRITE_COMPLETE it may release the buffer while a connection-level write-ready event can restart the stream through the non-owning _send_reader alias. This leaves restart_sending vulnerable to a use-after-free.

Clear _send_reader before delivering WRITE_COMPLETE to HttpSM, and check completed write VIOs before inspecting the reader during connection restarts. This preserves zero-byte completion processing, including END_STREAM.

Testing:

  • Fedora debug build and format checks
  • Full Apache AuTest matrix: 540 passed, 0 failed, 20 skipped
  • Focused H2, HTTP/2, and 100 Continue coverage on the 10.0.x mirror: 29 passed, 0 failed

Copilot AI lite review requested due to automatic review settings August 5, 2026 22:31
@bneradt bneradt added this to the 11.0.0 milestone Aug 5, 2026
@bneradt bneradt self-assigned this Aug 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the HTTP/2 stream write path against a use-after-free that can occur after an informational (e.g., 100 Continue) response completes and releases its write buffer, but the connection later delivers a write-ready event that re-enters stream write processing.

Changes:

  • Add an early exit in Http2Stream::update_write_request() when the write VIO is already complete (ntodo() <= 0), preventing examination of a potentially stale reader.
  • Simplify the reader-availability guard by relying on the early ntodo() check and then checking availability unconditionally for pending writes.

@bneradt
bneradt marked this pull request as draft August 5, 2026 23:40
HttpSM owns the write buffer attached to an HTTP/2 stream. After
WRITE_COMPLETE it may release the buffer while a connection-level
write-ready event can restart the stream through the non-owning
_send_reader alias. This leaves restart_sending vulnerable to a
use-after-free.

Clear _send_reader before delivering WRITE_COMPLETE to HttpSM, and
check completed write VIOs before inspecting the reader during
connection restarts. This preserves zero-byte completion processing,
including END_STREAM.
@bneradt
bneradt force-pushed the fix-h2-expect-continue-uaf branch from 66a68dc to 6ff78d3 Compare August 6, 2026 00:33
@bneradt
bneradt marked this pull request as ready for review August 6, 2026 16:15
Copilot AI review requested due to automatic review settings August 6, 2026 16:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@cmcfarlen
cmcfarlen merged commit c0351de into apache:master Aug 7, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.0 in ATS v10.2.x Aug 7, 2026
cmcfarlen pushed a commit that referenced this pull request Aug 9, 2026
HttpSM owns the write buffer attached to an HTTP/2 stream. After
WRITE_COMPLETE it may release the buffer while a connection-level
write-ready event can restart the stream through the non-owning
_send_reader alias. This leaves restart_sending vulnerable to a
use-after-free.

Clear _send_reader before delivering WRITE_COMPLETE to HttpSM, and
check completed write VIOs before inspecting the reader during
connection restarts. This preserves zero-byte completion processing,
including END_STREAM.

Co-authored-by: bneradt <bneradt@yahooinc.com>
(cherry picked from commit c0351de)
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Aug 9, 2026
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.0 Aug 9, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to the 10.2.x branch as 7bf5d4b for the 10.2.0 release.

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

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

3 participants