CVE-2026-82416: FrankenPHP Cross-request PHP Session ID Leak Vulnerability

HIGH
Advisory Identifier: GHSA-v3ph-cgqh-r8p5
CVSS 7.7
CWE-362 CWE-488
Published
Advisory Summary

CVE-2026-82416 is a HIGH (CVSS 7.7) cross-request php session id leak vulnerability (CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')) affecting FrankenPHP libraries in the Go ecosystem. The issue involves cross-request php session id leak in worker mode when the session extension is a shared module. Remediation is available by upgrading affected packages to version 1.12.5.

CVE-2026-82416 at a Glance

CVE Identifier CVE-2026-82416
GHSA Identifier GHSA-v3ph-cgqh-r8p5
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Affected Product FrankenPHP
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2026-82416

To remediate this vulnerability, upgrade all affected FrankenPHP dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/dunglas/frankenphp fixed: 1.12.5
Upgrade github.com/dunglas/frankenphp to 1.12.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/dunglas/frankenphp

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-82416, inspect your project dependencies for FrankenPHP:

inspect dependencies for github.com/dunglas/frankenphp

Analyze the terminal output to locate any version of FrankenPHP in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.12.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition'), where the product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently. In FrankenPHP, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary In worker mode under concurrency, FrankenPHP can hand a PHP session id from one request to another when PHP's `session` extension is loaded as a shared module instead of being statically linked into the FrankenPHP binary. A request presenting `Cookie: session=A` can have `session_id()` resolve to `B` (a different concurrent client's id) or to a stale id from a previous request served by the same worker thread. ## Impact - **Security:** cross-user session exposure / session hijacking in worker mode. Same impact class as CVE-2026-24894. - **Functional:** users are intermittently logged out; their cookie's session is ignored and they receive a foreign or empty session. ## Affected / not affected Exposure is determined by how the `session` extension is linked in the PHP build FrankenPHP is compiled against, **not** by the FrankenPHP release: - **Affected:** any build where the `session` extension is not visible to FrankenPHP at compile time, i.e. loaded as a shared / out-of-tree module (`extension=session` in an ini). This includes the RPM and Debian packages and other packaged `php-zts` distributions that ship `session` as a shared extension under `conf.d`. - **Not affected:** builds where `session` is statically compiled into the PHP that FrankenPHP links against, such as the official static binaries and Docker images. There, the reset code below is compiled in and clears the id every request. The C session-reset code is unchanged across 1.11.x-1.12.x, so this is not a code regression between releases. A "1.12.2 works / 1.12.3 leaks" observation on the same host reflects two differently-built packages, not a source change. The persistent-zval helpers (#2366) are compiled only under `FRANKENPHP_TEST` and are unrelated. ## Root cause FrankenPHP resets per-request session state in `frankenphp_reset_session_state()`, which releases `PS(id)` so the next `session_start()` re-reads the request cookie. That whole function is guarded by `#ifdef HAVE_PHP_SESSION`, a macro defined only when the session extension headers are present at FrankenPHP compile time (session statically enabled in the PHP build). When `session` is a shared module, `HAVE_PHP_SESSION` is undefined, the reset is compiled out, and `PS(id)` survives the request boundary. PHP's `session_start()` reads the request cookie only when `PS(id)` is `NULL` (`ext/session/session.c`, `try_find_session_id_in_cookies()`: `if (!PS(use_cookies) || PS(id)) return;`). With a stale `PS(id)`, the cookie is ignored and the worker reuses the previous request's id, exposing it to whichever client is served next. ## Reproduction Minimal worker script (`index.php`): ```php <?php $handler = static function () { session_start(); $sent = $_COOKIE['session'] ?? '(none)'; $id = session_id(); header('Content-Type: text/plain'); echo ($sent === '(none)' || $sent === $id) ? "OK sent=$sent id=$id\n" : "LEAK sent=$sent id=$id\n"; session_write_close(); }; while (\frankenphp_handle_request($handler)) {} ``` Run under worker mode with `num 2` (≥2 workers), `session.use_strict_mode=1`, on a PHP build where `session` is a shared module. Pre-create two valid sessions `A` and `B`, then fire concurrent requests alternating the two cookies: ```sh seq 600 | xargs -P32 -I{} sh -c ' c=$([ $(( {} % 2 )) -eq 0 ] && echo A || echo B); curl -s -H "Cookie: session=$c" http://127.0.0.1:8080/' | grep -c LEAK ``` On an affected build a large fraction of responses are `LEAK` (`session_id()` differs from the cookie sent, and `A` and `B` sometimes resolve to the same id). On a statically-linked build the count is always `0`. ## Fix When `HAVE_PHP_SESSION` is undefined, FrankenPHP now resets the `session` module through the module registry on every worker request (its `RSHUTDOWN` releases `PS(id)`, `RINIT` re-initialises the globals), so the per-request cleanup always runs regardless of how the extension is linked. Statically-linked builds are unchanged and keep using `frankenphp_reset_session_state()`. Verified on PHP 8.6-dev ZTS, 2 workers, `session.use_strict_mode=1`, 600 alternating-cookie concurrent requests: before the fix 519/600 leaked; after the fix 0/600. Statically-linked builds stayed at 0/600. ## Workarounds - Use a FrankenPHP build with `session` statically compiled (official static binaries or Docker images). - Or, in the worker loop, after `session_write_close()` call `session_id('')` so the next `session_start()` re-reads the request cookie (with `session.use_strict_mode=1`).

CVE-2026-82416 Affected FrankenPHP Versions

1 component(s)
Fixed Versions:
1.12.5
Product / Package Ecosystem Affected Versions Fixed Version
github.com/dunglas/frankenphp
Go
< 1.12.5
1.12.5

References

Frequently Asked Questions

What is CVE-2026-82416?
CVE-2026-82416 is a security vulnerability in FrankenPHP involving Cross-request PHP session ID leak in worker mode when the session extension is a shared module under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition').
Which FrankenPHP versions are affected?
Affected versions include releases prior to 1.12.5 across affected packages: github.com/dunglas/frankenphp.
What version fixes CVE-2026-82416?
Upgrading to 1.12.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/dunglas/frankenphp affected?
Yes, github.com/dunglas/frankenphp is affected in releases prior to 1.12.5. Upgrade your dependency to 1.12.5 or later.
What is the CVSS score of CVE-2026-82416?
CVE-2026-82416 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2026-82416?
CVE-2026-82416 is classified under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') (The product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently.).
How can I check Go dependencies for CVE-2026-82416?
Run the dependency tree command: 'inspect dependencies for github.com/dunglas/frankenphp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v3ph-cgqh-r8p5",
  "modified" : "2026-10-15T20:14:29Z",
  "published" : "2026-10-15T20:14:29Z",
  "aliases" : [ "CVE-2026-82416" ],
  "summary" : "FrankenPHP: Cross-request PHP session ID leak in worker mode when the session extension is a shared module",
  "details" : "## Summary\nIn worker mode under concurrency, FrankenPHP can hand a PHP session id from one request to another when PHP's `session` extension is loaded as a shared module instead of being statically linked into the FrankenPHP binary. A request presenting `Cookie: session=A` can have `session_id()` resolve to `B` (a different concurrent client's id) or to a stale id from a previous request served by the same worker thread.\n\n## Impact\n- **Security:** cross-user session exposure / session hijacking in worker mode. Same impact class as CVE-2026-24894.\n- **Functional:** users are intermittently logged out; their cookie's session is ignored and they receive a foreign or empty session.\n\n## Affected / not affected\nExposure is determined by how the `session` extension is linked in the PHP build FrankenPHP is compiled against, **not** by the FrankenPHP release:\n\n- **Affected:** any build where the `session` extension is not visible to FrankenPHP at compile time, i.e. loaded as a shared / out-of-tree module (`extension=session` in an ini). This includes the RPM and Debian packages and other packaged `php-zts` distributions that ship `session` as a shared extension under `conf.d`.\n- **Not affected:** builds where `session` is statically compiled into the PHP that FrankenPHP links against, such as the official static binaries and Docker images. There, the reset code below is compiled in and clears the id every request.\n\nThe C session-reset code is unchanged across 1.11.x-1.12.x, so this is not a code regression between releases. A \"1.12.2 works / 1.12.3 leaks\" observation on the same host reflects two differently-built packages, not a source change. The persistent-zval helpers (#2366) are compiled only under `FRANKENPHP_TEST` and are unrelated.\n\n## Root cause\nFrankenPHP resets per-request session state in `frankenphp_reset_session_state()`, which releases `PS(id)` so the next `session_start()` re-reads the request cookie. That whole function is guarded by `#ifdef HAVE_PHP_SESSION`, a macro defined only when the session extension headers are present at FrankenPHP compile time (session statically enabled in the PHP build). When `session` is a shared module, `HAVE_PHP_SESSION` is undefined, the reset is compiled out, and `PS(id)` survives the request boundary.\n\nPHP's `session_start()` reads the request cookie only when `PS(id)` is `NULL` (`ext/session/session.c`, `try_find_session_id_in_cookies()`: `if (!PS(use_cookies) || PS(id)) return;`). With a stale `PS(id)`, the cookie is ignored and the worker reuses the previous request's id, exposing it to whichever client is served next.\n\n## Reproduction\nMinimal worker script (`index.php`):\n```php\n<?php\n$handler = static function () {\n    session_start();\n    $sent = $_COOKIE['session'] ?? '(none)';\n    $id   = session_id();\n    header('Content-Type: text/plain');\n    echo ($sent === '(none)' || $sent === $id) ? \"OK   sent=$sent id=$id\\n\"\n                                               : \"LEAK sent=$sent id=$id\\n\";\n    session_write_close();\n};\nwhile (\\frankenphp_handle_request($handler)) {}\n```\nRun under worker mode with `num 2` (≥2 workers), `session.use_strict_mode=1`, on a PHP build where `session` is a shared module. Pre-create two valid sessions `A` and `B`, then fire concurrent requests alternating the two cookies:\n```sh\nseq 600 | xargs -P32 -I{} sh -c '\n  c=$([ $(( {} % 2 )) -eq 0 ] && echo A || echo B);\n  curl -s -H \"Cookie: session=$c\" http://127.0.0.1:8080/' | grep -c LEAK\n```\nOn an affected build a large fraction of responses are `LEAK` (`session_id()` differs from the cookie sent, and `A` and `B` sometimes resolve to the same id). On a statically-linked build the count is always `0`.\n\n## Fix\nWhen `HAVE_PHP_SESSION` is undefined, FrankenPHP now resets the `session` module through the module registry on every worker request (its `RSHUTDOWN` releases `PS(id)`, `RINIT` re-initialises the globals), so the per-request cleanup always runs regardless of how the extension is linked. Statically-linked builds are unchanged and keep using `frankenphp_reset_session_state()`.\n\nVerified on PHP 8.6-dev ZTS, 2 workers, `session.use_strict_mode=1`, 600 alternating-cookie concurrent requests: before the fix 519/600 leaked; after the fix 0/600. Statically-linked builds stayed at 0/600.\n\n## Workarounds\n- Use a FrankenPHP build with `session` statically compiled (official static binaries or Docker images).\n- Or, in the worker loop, after `session_write_close()` call `session_id('')` so the next `session_start()` re-reads the request cookie (with `session.use_strict_mode=1`).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/dunglas/frankenphp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.12.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.12.4"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/php/frankenphp/security/advisories/GHSA-v3ph-cgqh-r8p5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-82416"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/php/frankenphp/pull/2523"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/php/frankenphp/commit/be24d82531675f90862b8cde1e9fc7e9ee855aa5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/php/frankenphp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/php/frankenphp/releases/tag/caddy/v1.12.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-362", "CWE-488" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-15T20:14:29Z",
    "nvd_published_at" : "2026-10-13T17:17:47Z"
  }
}