{"id":"CVE-2026-39971","aliases":["CVE-2026-39971","GHSA-458g-q4fh-mj6r"],"related":[],"kind":"vulnerability","state":"published","title":"Serendipity: Host Header Injection leads to SMTP header injection via unvalidated HTTP_HOST","summary":"Serendipity is a PHP-powered weblog engine. In versions 2.6-beta2 and below, the email sending functionality in include/functions.inc.php inserts $_SERVER['HTTP_HOST'] directly into the Message-ID SMTP header without validation, and the existing sanitization function serendipity_isResponseClean() is not called on HTTP_HOST before embedding it. An attacker who can control the Host header during an email-triggering action such as comment notifications or subscription emails can inject arbitrary SMTP headers into outgoing emails. This enables identity spoofing, reply hijacking via manipulated Message-ID threading, and email reputation abuse through the attacker's domain being embedded in legitimate mail headers. 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 email sending functionality in include/functions.inc.php inserts $_SERVER['HTTP_HOST'] directly into the Message-ID SMTP header without validation, and the existing sanitization function serendipity_isResponseClean() is not called on HTTP_HOST before embedding it. An attacker who can control the Host header during an email-triggering action such as comment notifications or subscription emails can inject arbitrary SMTP headers into outgoing emails. This enables identity spoofing, reply hijacking via manipulated Message-ID threading, and email reputation abuse through the attacker's domain being embedded in legitimate mail headers. This issue has been fixed in version 2.6.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nSerendipity inserts `$_SERVER['HTTP_HOST']` directly into the `Message-ID` SMTP header without any validation beyond CRLF stripping. An attacker who can control the `Host` header during an email-triggering action can inject arbitrary SMTP headers into outgoing emails, enabling spam relay, BCC injection, and email spoofing.\n\n### Details\nIn `include/functions.inc.php:548`:\n```php\n$maildata['headers'][] = 'Message-ID: <' \n    . bin2hex(random_bytes(16)) \n    . '@' . $_SERVER['HTTP_HOST']  // ← unsanitized, attacker-controlled\n    . '>';\n```\n\nThe existing sanitization function only blocks `\\r\\n` and URL-encoded variants:\n```php\nfunction serendipity_isResponseClean($d) {\n    return (strpos($d, \"\\r\") === false && strpos($d, \"\\n\") === false \n        && stripos($d, \"%0A\") === false && stripos($d, \"%0D\") === false);\n}\n```\n\nCritically, `serendipity_isResponseClean()` is **not even called** on `HTTP_HOST` before embedding it into the mail headers — making this exploitable with any character that SMTP interprets as a header delimiter.\n\nEmail is triggered by actions such as:\n- New comment notifications to blog owner\n- Comment subscription notifications to subscribers\n- Password reset emails (if configured)\n\n### PoC\n```bash\n# Trigger comment notification email with injected header\ncurl -s -X POST \\\n  -H \"Host: attacker.com>\\r\\nBcc: victim@evil.com\\r\\nX-Injected:\" \\\n  -d \"serendipity[comment]=test&serendipity[name]=hacker&serendipity[email]=a@b.com&serendipity[entry_id]=1\" \\\n  http://[TARGET]/comment.php\n```\nResulting malicious `Message-ID` header in outgoing email:\n```\nMessage-ID: <deadbeef@attacker.com>\nBcc: victim@evil.com\nX-Injected: >\n```\n\n### Impact\nAn attacker can control the domain portion of the `Message-ID` header in all outgoing emails sent by Serendipity (comment notifications, subscriptions). \nThis enables:\n- **Identity spoofing** — emails appear to originate from attacker-controlled domain\n- **Reply hijacking** — some mail clients use Message-ID for threading, pointing replies toward attacker infrastructure\n- **Email reputation abuse** — attacker's domain embedded in legitimate mail headers\n### Suggested Fix\nSanitize `HTTP_HOST` before embedding in mail headers, and restrict to valid hostname characters only:\n```php\n$safe_host = preg_replace('/[^a-zA-Z0-9.\\-]/', '', \n    parse_url('http://' . $_SERVER['HTTP_HOST'], PHP_URL_HOST)\n);\n$maildata['headers'][] = 'Message-ID: ';\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"Serendipity es un motor de weblog impulsado por PHP. En las versiones 2.6-beta2 e inferiores, la funcionalidad de envío de correo electrónico en include/functions.inc.php inserta $_SERVER[’HTTP_HOST’] directamente en el encabezado SMTP Message-ID sin validación, y la función de saneamiento existente serendipity_isResponseClean() no se llama en HTTP_HOST antes de incrustarlo. Un atacante que puede controlar el encabezado Host durante una acción que desencadena un correo electrónico, como notificaciones de comentarios o correos electrónicos de suscripción, puede inyectar encabezados SMTP arbitrarios en los correos electrónicos salientes. Esto permite la suplantación de identidad, el secuestro de respuestas a través de la manipulación del encadenamiento de Message-ID, y el abuso de la reputación del correo electrónico a través del dominio del atacante incrustado en los encabezados de correo legítimos. Este problema ha sido solucionado en la versión 2.6.0.","source":"nvd"}],"published":"2026-04-14T22:32:38.000Z","modified":"2026-10-26T22:10:00.163Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N","score":7.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N","score":7.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N","score":7.2,"rating":"HIGH"}],"cwes":["CWE-113"],"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-458g-q4fh-mj6r","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":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-39971","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":"yes","technicalImpact":"partial","date":"2026-04-15T16:20:55.327Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-39971","url":"https://www.cve.org/CVERecord?id=CVE-2026-39971","licence":"CVE Terms of Use","modified":"2026-04-15T16:22:04.004Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-458g-q4fh-mj6r","url":"https://github.com/advisories/GHSA-458g-q4fh-mj6r","licence":"CC-BY-4.0","modified":"2026-05-05T16:00:57.024Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-39971","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-39971","licence":"Public domain","modified":"2026-10-26T22:10:00.163Z"}],"updatedAt":"2026-11-25T22:59:18.813Z","epss":{"score":0.00265,"percentile":0.19701,"date":"2026-12-01T12:00:22.000Z"}}