/

CVE-2026-39971

Severity:

HIGH RISK

(7.2)

HTTP Response / Header Injection in Serendipity Email

CVE-2026-39971

Analyzed

Vulnerability type

Category:

HTTP Response / Header Injection

CWE:

CWE-113

Impact:

SMTP Header Injection and Email Identity Spoofing

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Serendipity's email sending logic inserts the raw HTTP Host header into the Message-ID SMTP header without proper validation or sanitization.

If an attacker can control the Host header during an email-triggering action, they can inject arbitrary SMTP headers into outgoing emails, enabling identity spoofing and manipulation of email threading and reputation.

Affected context

The vulnerability arises in Serendipity installations (versions 2.6-beta2 and below) when the application sends emails, such as comment notifications or subscription messages.

During email generation, the value of $_SERVER['HTTP_HOST'] is embedded directly into the Message-ID SMTP header without invoking the existing serendipity_isResponseClean() sanitization routine.

Deployments where upstream components, proxies, or clients can influence the Host header are particularly exposed.

Exploit preconditions

  • Attack surface: HTTP interface of the Serendipity blog where email-triggering actions occur (e.g., comment posting, subscription workflows).
  • Required access: Ability to send HTTP requests to the blog and control or override the Host header (often achievable by a remote unauthenticated attacker unless constrained by infrastructure).
  • Trigger point: Any code path that sends an email and constructs a Message-ID header using $_SERVER['HTTP_HOST'] in include/functions.inc.php.
  • Why exploitation is possible: The Host header is treated as trusted input and inserted into the Message-ID SMTP header without validation or cleansing, allowing newline or crafted content to break out of the intended header value and introduce additional SMTP headers.

Why this happens

The root cause is improper neutralization of user-controllable input when constructing SMTP headers, aligning with CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting'), generalized here as header injection.

The application directly uses $_SERVER['HTTP_HOST'] in the Message-ID header, assuming it to be trustworthy, and fails to apply the existing serendipity_isResponseClean() sanitization routine.

Because SMTP and HTTP headers share similar line-based semantics, unvalidated inclusion of header content enables attackers to inject additional headers or manipulate existing ones.

Conceptually, this is an input validation and output encoding failure: untrusted request metadata is embedded into protocol-level headers without filtering control characters or enforcing a strict, safe format.

Potential impact

  • Email identity spoofing by manipulating header fields associated with the blog or sender domain.
  • Reply or conversation hijacking via crafted Message-ID values that influence threading in email clients.
  • Abuse of the blog's email reputation by embedding attacker-controlled domains or headers into legitimate emails.
  • Facilitation of phishing or social engineering by making malicious emails appear associated with a trusted blog.
  • Potential interference with downstream mail handling, logging, or filtering due to malformed or injected headers.

General mitigation guidance

Effective mitigation focuses on treating all request-derived metadata, including Host, as untrusted and constraining its use in protocol headers.

Recommended defensive patterns include:

  • Validating the Host value against a strict whitelist or configuration-derived canonical domain before using it in any header.
  • Applying a central sanitization function to all header-bound values that strips or rejects control characters, CR/LF sequences, and other unsafe characters.
  • Constructing Message-ID and similar headers from server-side constants or configuration (e.g., application domain) rather than from client-controlled request data.
  • Encapsulating email header assembly behind a dedicated utility that enforces safe formatting and refuses untrusted input that does not match an expected pattern (such as a simple hostname).
  • Deploying the application with web server and reverse proxy configurations that normalize or restrict the Host header to known values wherever feasible, reducing the attack surface if application-level checks fail.

How teams detect issues like this

Detection typically involves a combination of code-level inspection and runtime monitoring:

  • Static analysis: Create rules to flag any direct use of $_SERVER['HTTP_HOST'], other $_SERVER entries, or user input when concatenated into mail headers, HTTP headers, or other protocol metadata without sanitization.
  • Code review signals: During review, treat all header construction code as security-sensitive and verify that a single, well-tested sanitization function is applied consistently. Watch for string concatenation into headers and for bypasses of existing validation utilities.
  • Policy enforcement: Introduce coding guidelines that prohibit direct embedding of request data in headers and require using safe wrappers for email and HTTP response construction.
  • Automated tooling: Configure linters or security scanners to detect potential header injection patterns, such as unescaped \r / \n or uncontrolled domain values in header fields, and integrate these checks into CI pipelines.

Sources

SourceLink
github.comgithub.com/s9y/Serendipity/releases/tag/2.6.0
github.comgithub.com/s9y/Serendipity/security/advisories/GHSA-458g-q4fh-mj6r

Frequently asked

questions

In many deployments, a remote attacker who can send HTTP requests to the blog can exploit this issue, as the Host header is often client-controlled unless constrained by upstream infrastructure.

Not necessarily. Any unauthenticated user who can trigger an email-sending action (such as posting a comment or subscribing) and control the Host header can potentially exploit the vulnerability, subject to web server and proxy behavior.

The safest pattern is to stop using request-derived headers such as HTTP_HOST when constructing SMTP headers and instead rely on a configured, constant application domain. Apply a shared sanitization routine to any value that must enter a header and reject or normalize anything that does not match a strict allowed pattern.

Establish clear rules that all protocol headers (HTTP, SMTP, etc.) are constructed from trusted, validated sources only; centralize header creation in well-reviewed helpers; enforce sanitization of any user-controlled data used in headers; and back these practices with static analysis, code review checklists, and CI-based security checks.

Find out what's already
exploitable in your codebase.