Skip to content

h3: fully fix dirty-list use-after-free (unlink conn on free) (#62) - #63

Merged
EdmondDantes merged 1 commit into
mainfrom
62-fully-fix-dirty-list-uaf
May 31, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
62-fully-fix-dirty-list-uaf

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

Follow-up to the arm_timer NULL-guard from #61 — turns the mitigation into a complete fix.

Problem

http3_connection_free did not unlink the connection from the listener's dirty list (dirty_head / conn->dirty_next / conn->in_dirty) before efree. A conn freed while still marked dirty dangles on the list; the next http3_listener_flush_dirty walks into freed memory. The arm_timer guard only catches the post-OPENSSL_cleanse case (ngtcp2_conn == NULL) — not a reallocation of the slot to a live conn.

Fix

  • New http3_listener_unmark_flush(l, conn) — singly-linked unlink from dirty_head, clears in_dirty / dirty_next.
  • Called in http3_connection_free before teardown.
  • arm_timer NULL guard kept as defense-in-depth.

Verification

  • phpt 25/25 (tests/phpt/server/h3/).
  • 8× sustained c=64 crash-stress (the regime that surfaced the original crash): no crash, server alive, 0 errored.

Closes #62

http3_connection_free did not remove the connection from the listener's
dirty list before efree, so a conn freed while still marked dirty dangled
there and the next flush_dirty walked into freed memory. The arm_timer
NULL guard (#61) only catches the post-OPENSSL_cleanse manifestation
(ngtcp2_conn == NULL); it does not help if the freed slot is reallocated
to a live conn first.

Add http3_listener_unmark_flush() (singly-linked unlink from dirty_head)
and call it in http3_connection_free before teardown. The arm_timer guard
stays as defense-in-depth.

phpt 25/25; 8x sustained c=64 crash-stress clean (0 errored, no crash).
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Total lines: 80.86% → 80.58% (-0.28 pp)

File Baseline Current Δ Touched
src/http3/http3_callbacks.c 76.63% 78.61% +1.98 pp
src/http3/http3_connection.c 81.74% 81.79% +0.05 pp ●
src/http3/http3_listener.c 74.80% 64.82% -9.98 pp ●

❌ Regression in touched files (> 1.0 pp drop)

  • src/http3/http3_listener.c dropped -9.98 pp

Add [coverage-drop-ok] to a commit message in this PR to override.

@EdmondDantes
EdmondDantes merged commit d222183 into main May 31, 2026
8 checks passed
@EdmondDantes
EdmondDantes deleted the 62-fully-fix-dirty-list-uaf branch June 27, 2026 03:42
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.

HTTP/3: fully fix dirty-list use-after-free (unlink conn on free)

1 participant