Repository navigation
Conversation
Code running between two worker requests, in the worker loop or in a destructor, can set request state after the previous request reset it. sapi_activate() then drops the header callback, headers, status line, mimetype and php://input body without releasing them, and the next client inherits the URL rewriter state and the session. Release this state before waiting for the next request.
dunglas
force-pushed
the
fix/worker-header-callback-leak
branch
from
November 10, 2026 16:10
a47cecd to
8f14144
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code running between two worker requests, in the worker loop or in a destructor, can set request state after the previous request reset it. Calling request functions there isn't supported, but nothing stopped it:
header_register_callback()sapi_activate()drops the callback without releasing it: it leaks with everything it captures until the worker stopsheader(),setcookie(), a session cookieheader('HTTP/1.1 ...')header('Content-Type: ...')fopen('php://input')output_add_rewrite_var()session_id(),session_start()The session case is the one that matters: a destructor that touches the session between two requests hands it to the next client.
frankenphp_handle_request()now releases this state with the superglobals, before waiting for the next request. It skips the first call, where the worker script's boot request is still active.The header callback leak was found while reading Rapira, which works around it.