PHP
CVE-2026-39963
MEDIUM
Severity by source
AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:N
Primary rating from GitHub Advisory · only source for this CVE.
CVSS VectorGitHub Advisory
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:L/A:N
Lifecycle Timeline
4DescriptionGitHub Advisory
Summary
The 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.
Details
In include/functions_config.inc.php:726:
function serendipity_setCookie($name, $value, $securebyprot = true, ...) {
$host = $_SERVER['HTTP_HOST']; // ← attacker-controlled, no validation
if ($securebyprot) {
if ($pos = strpos($host, ":")) {
$host = substr($host, 0, $pos); // strips port only
}
}
setcookie("serendipity[$name]", $value, [
'domain' => $host, // ← poisoned domain
'httponly' => $httpOnly,
'samesite' => 'Strict'
]);
}This function is called during login with sensitive cookies:
// functions_config.inc.php:455-498
serendipity_setCookie('author_autologintoken', $rnd, true, false, true);
serendipity_setCookie('author_username', $user);
serendipity_setCookie('author_token', $hash);If 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.
PoC
curl -v -X POST \
-H "Host: attacker.com" \
-d "serendipity[user]=admin&serendipity[pass]=admin" \
http://[TARGET]/serendipity_admin.php 2>&1 | grep -i "set-cookie"Expected output:
Set-Cookie: serendipity[author_token]=; domain=attacker.com; HttpOnlyImpact
- Session fixation - attacker pre-sets a cookie scoped to their domain, then tricks the victim into authenticating, inheriting the poisoned token
- Token leakage -
author_autologintokenscoped to wrong domain may be sent to attacker-controlled infrastructure - Privilege escalation - if admin logs in under a poisoned Host header, their admin token is compromised
Suggested Fix
Validate HTTP_HOST against the configured $serendipity['url'] before use:
function serendipity_setCookie($name, $value, ...) {
global $serendipity;
$configured = parse_url($serendipity['url'], PHP_URL_HOST);
$host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
$host = ($host === $configured) ? $host : $configured;
setcookie("serendipity[$name]", $value, [
'domain' => $host,
...
]);
}AnalysisAI
Serendipity's serendipity_setCookie() function accepts unsanitized HTTP_HOST header values as the cookie domain parameter, allowing remote attackers to scope authentication cookies (session tokens, auto-login tokens) to attacker-controlled domains and facilitate session hijacking. The vulnerability requires user interaction (victim authentication during poisoned Host header) and man-in-the-middle or reverse proxy misconfiguration to exploit, affecting all versions of Serendipity that use the vulnerable function. A proof-of-concept demonstrating cookie domain poisoning exists; exploitation probability is moderate (EPSS 6.9, CVSS AC:H reflects attack complexity), and no evidence of active exploitation has been identified.
Technical ContextAI
Serendipity is a lightweight PHP blog engine. The vulnerability resides in the serendipity_setCookie() function (include/functions_config.inc.php:726), which directly uses the HTTP_HOST server variable-attacker-controllable in HTTP requests-as the domain parameter to PHP's setcookie() function without validation against the configured server hostname. The root cause (CWE-565: Reliance on Cookies without Validation and Integrity Checking) stems from trusting untrusted input (HTTP_HOST header) for security-critical cookie scope decisions. While the code does strip port numbers when securebyprot=true, this defensive measure is insufficient because the hostname itself remains unvalidated. The function sets cookies with httponly and samesite=Strict flags, which provide some mitigation, but the domain poisoning bypasses the intended audience of the cookie. Affected product: Serendipity (pkg:composer/s9y_serendipity) in versions prior to patching.
RemediationAI
Validate the HTTP_HOST header against the configured serendipity['url'] before using it as a cookie domain. The vendor-suggested fix (referenced in the CVE description) implements hostname parsing and comparison: extract the configured hostname using parse_url($serendipity['url'], PHP_URL_HOST), sanitize the HTTP_HOST header with preg_replace('/:[0-9]+$/', '', ...) to strip port numbers, and use the configured hostname if the request's Host header does not match. Apply the patch provided in the GitHub security advisory (https://github.com/advisories/GHSA-4m6c-649p-f6gf). Alternatively, implement a Content Security Policy and configure reverse proxies to validate and normalize Host headers before forwarding requests to Serendipity. Monitor for signs of session hijacking by reviewing cookie domains in browser developer tools and server logs for mismatched Host headers.
sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not
(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear
ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C
Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au
Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c
Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows
The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1
NetAlertX (formerly PiAlert) versions 23.01.14 through 24.x before 24.10.12 allow unauthenticated command injection thro
The GiveWP - Donation Plugin and Fundraising Platform plugin for WordPress is vulnerable to PHP Object Injection in all
Same technique Privilege Escalation
View allShare
External POC / Exploit Code
Leaving vuln.today
GHSA-4m6c-649p-f6gf