Summary
FrankenPHP, when running in worker mode prior to version 1.11.2, fails to correctly reset the PHP $_SESSION superglobal between requests handled by the same worker process.
As a result, a subsequent request can read residual session data from a previous request—potentially belonging to a different user—even before session_start() is called, creating a risk of unauthorized access to another user's session information.
Affected context
The vulnerability occurs in FrankenPHP deployments configured to run in worker mode, where a single long-lived worker process serves multiple HTTP requests sequentially.
In affected versions, the $_SESSION superglobal is not reliably cleared or reinitialized between requests, so data from one request can persist in memory and become visible to a subsequent, unrelated request handled by the same worker.
This typically impacts applications that rely on PHP sessions for user state, authentication, or sensitive data storage.
Exploit preconditions
- Attack surface: Web applications served by FrankenPHP in worker mode.
- Required access: Ability to send HTTP requests to the affected application (standard web client access).
- Trigger point: Any new request processed by a worker that previously handled a different user's request, before
session_start()has been invoked. - Why exploitation is possible:
- The worker process reuses the same PHP runtime between requests.
$_SESSIONis not cleared or reinitialized per request, leaving residual state.- Application code may read from
$_SESSION(directly or indirectly) before session initialization logic is applied, exposing data from the prior request.
Why this happens
This issue stems from improper session lifecycle management in a long-running worker model.
Instead of treating each HTTP request as an isolated execution context, the runtime allows the $_SESSION superglobal to persist across requests without guaranteed reset.
This maps to CWE-384: Session Fixation / Session Management Vulnerability and is closely related to CWE-269: Improper Privilege Management and CWE-613: Insufficient Session Expiration, because session-bound privileges and data are improperly scoped and isolated.
Conceptually, the bug is an insecure reuse of in-memory session state: request-specific data is stored in a process-global variable that is not reinitialized between uses, breaking the expectation that each user's session is private and tied only to their own authenticated context.
Potential impact
- A request may read sensitive
$_SESSIONdata belonging to a previous user, including identifiers, CSRF tokens, or application-specific secrets. - User-specific configuration or personalization data may be exposed to other users.
- Application logic that trusts existing
$_SESSIONcontent could perform actions based on another user's state, leading to privilege confusion. - Leakage of partial authentication or authorization context, which may assist in further attacks such as account takeover or privilege escalation.
General mitigation guidance
Mitigation centers on enforcing strict per-request isolation of session state and avoiding reliance on stale global variables in long-lived workers.
General defensive patterns include:
- Ensuring that all per-request global state (including
$_SESSION) is deterministically reinitialized at the beginning of each request in worker-based servers. - Designing frameworks and middleware so that session handling logic runs early in the request pipeline and does not depend on previously set global state.
- Avoiding storage of security-sensitive material in long-lived global structures unless they are explicitly scoped and cleared per request.
- Employing defense-in-depth by limiting the amount and sensitivity of data stored in sessions and avoiding overloading session state with excessive authorization or secret data.
- Applying strict least-privilege principles in application logic so that even if residual session data is visible, it cannot by itself authorize critical operations without fresh, request-bound checks.
How teams detect issues like this
Detection focuses on identifying leaked or reused session state across requests in long-running workers:
- Static analysis and code review:
- Look for application or framework code that reads from
$_SESSIONbefore explicit session initialization, especially in worker or SAPI implementations. - Flag patterns where request-specific state is stored in persistent globals that survive between requests.
- Review server/runtime integration code that should be responsible for clearing superglobals and other per-request containers.
- Dynamic and behavioral testing:
- Create automated tests that send sequential requests through the same worker environment and verify that
$_SESSIONand other request-specific variables start empty or in a known baseline state. - Use fuzzing or integration tests that simulate concurrent or repeated requests under load to observe any cross-request data leakage.
- Operational monitoring:
- Instrument applications to log unexpected
$_SESSIONcontent or mismatches between session identifiers and authenticated principals. - Use runtime security tools or application firewalls that can detect anomalies in session behavior, such as conflicting user identities sharing session-like data.
Automated security scanning tools and CI/CD checks can be configured to inspect framework and server integration code for improper clearing of superglobals and other request globals.

