{"id":"CVE-2026-39963","aliases":["CVE-2026-39963","GHSA-4m6c-649p-f6gf"],"related":[],"kind":"vulnerability","state":"published","title":"Serendipity: Host Header Injection enables authentication cookie scoping to an attacker-controlled domain","summary":"Serendipity is a PHP-powered weblog engine. In versions 2.6-beta2  and below, the serendipity_setCookie() function in include/functions_config.inc.php uses $_SERVER['HTTP_HOST'] without validation as the domain parameter of setcookie(). An attacker who can influence the Host header at login time, such as via MITM, reverse proxy misconfiguration, or load balancer manipulation, can force authentication cookies including session tokens and auto-login tokens to be scoped to an attacker-controlled domain. This enables session fixation, token leakage to attacker-controlled infrastructure, and privilege escalation if an admin logs in under a poisoned Host header. This issue has been fixed in version 2.6.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Serendipity is a PHP-powered weblog engine. In versions 2.6-beta2  and below, the serendipity_setCookie() function in include/functions_config.inc.php uses $_SERVER['HTTP_HOST'] without validation as the domain parameter of setcookie(). An attacker who can influence the Host header at login time, such as via MITM, reverse proxy misconfiguration, or load balancer manipulation, can force authentication cookies including session tokens and auto-login tokens to be scoped to an attacker-controlled domain. This enables session fixation, token leakage to attacker-controlled infrastructure, and privilege escalation if an admin logs in under a poisoned Host header. This issue has been fixed in version 2.6.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nThe `serendipity_setCookie()` function uses `$_SERVER['HTTP_HOST']` without validation as the `domain` parameter of `setcookie()`. An attacker can force authentication cookies — including session tokens and auto-login tokens — to be scoped to an attacker-controlled domain, facilitating session hijacking.\n\n### Details\nIn `include/functions_config.inc.php:726`:\n```php\nfunction serendipity_setCookie($name, $value, $securebyprot = true, ...) {\n    $host = $_SERVER['HTTP_HOST']; // ← attacker-controlled, no validation\n\n    if ($securebyprot) {\n        if ($pos = strpos($host, \":\")) {\n            $host = substr($host, 0, $pos); // strips port only\n        }\n    }\n\n    setcookie(\"serendipity[$name]\", $value, [\n        'domain'   => $host,   // ← poisoned domain\n        'httponly' => $httpOnly,\n        'samesite' => 'Strict'\n    ]);\n}\n```\n\nThis function is called during login with sensitive cookies:\n```php\n// functions_config.inc.php:455-498\nserendipity_setCookie('author_autologintoken', $rnd, true, false, true);\nserendipity_setCookie('author_username', $user);\nserendipity_setCookie('author_token', $hash);\n```\n\nIf an attacker can influence the `Host` header at login time (e.g. via MITM, reverse proxy misconfiguration, or load balancer), authentication cookies are issued scoped to the attacker's domain instead of the legitimate one.\n\n### PoC\n```bash\ncurl -v -X POST \\\n  -H \"Host: attacker.com\" \\\n  -d \"serendipity[user]=admin&serendipity[pass]=admin\" \\\n  http://[TARGET]/serendipity_admin.php 2>&1 | grep -i \"set-cookie\"\n```\n\nExpected output:\n```http\nSet-Cookie: serendipity[author_token]=; domain=attacker.com; HttpOnly\n```\n\n### Impact\n- **Session fixation** — attacker pre-sets a cookie scoped to their domain, then tricks the victim into authenticating, inheriting the poisoned token\n- **Token leakage** — `author_autologintoken` scoped to wrong domain may be sent to attacker-controlled infrastructure\n- **Privilege escalation** — if admin logs in under a poisoned Host header, their admin token is compromised\n\n### Suggested Fix\nValidate `HTTP_HOST` against the configured `$serendipity['url']` before use:\n```php\nfunction serendipity_setCookie($name, $value, ...) {\n    global $serendipity;\n    $configured = parse_url($serendipity['url'], PHP_URL_HOST);\n    $host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);\n    $host = ($host === $configured) ? $host : $configured;\n\n    setcookie(\"serendipity[$name]\", $value, [\n        'domain' => $host,\n        ...\n    ]);\n}\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"Serendipity es un motor de weblogs impulsado por PHP. En las versiones 2.6-beta2 y anteriores, la función serendipity_setCookie() en include/functions_config.inc.php utiliza $_SERVER[’HTTP_HOST’] sin validación como parámetro de dominio de setcookie(). Un atacante que puede influir en el encabezado Host en el momento del inicio de sesión, como a través de MitM, una mala configuración de proxy inverso o manipulación del balanceador de carga, puede forzar que las cookies de autenticación, incluidos los tokens de sesión y los tokens de inicio de sesión automático, se limiten a un dominio controlado por el atacante. Esto permite la fijación de sesión, la fuga de tokens a infraestructura controlada por el atacante y la escalada de privilegios si un administrador inicia sesión bajo un encabezado Host envenenado. Este problema ha sido solucionado en la versión 2.6.0.","source":"nvd"}],"published":"2026-04-14T22:32:29.000Z","modified":"2026-10-26T22:10:00.163Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:N","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:N","score":6.9,"rating":"MEDIUM"}],"cwes":["CWE-565"],"affected":[{"ranges":[{"version":"< 2.6.0","status":"affected"}],"vendor":"s9y","product":"Serendipity","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.6.0"}],"ecosystem":"Packagist","package":"s9y/serendipity","purl":"pkg:composer/s9y/serendipity","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.6.0"},{"status":"affected","version":"2.6.0"}],"vendor":"s9y","product":"serendipity","cpe":"cpe:2.3:a:s9y:serendipity:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/s9y/Serendipity/security/advisories/GHSA-4m6c-649p-f6gf","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/s9y/Serendipity/releases/tag/2.6.0","tags":["product","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-39963","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/s9y/Serendipity","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-04-15T13:23:44.552Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-39963","url":"https://www.cve.org/CVERecord?id=CVE-2026-39963","licence":"CVE Terms of Use","modified":"2026-04-15T13:23:48.591Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4m6c-649p-f6gf","url":"https://github.com/advisories/GHSA-4m6c-649p-f6gf","licence":"CC-BY-4.0","modified":"2026-04-15T21:35:53.816Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-39963","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-39963","licence":"Public domain","modified":"2026-10-26T22:10:00.163Z"}],"updatedAt":"2026-11-25T22:59:18.813Z","epss":{"score":0.00233,"percentile":0.15216,"date":"2026-12-02T12:00:21.000Z"}}