SMTP header injection via C-escape `\r` in the recipient display name
Roundcube strips CR/LF from recipient input before calling stripcslashes() on the display name, so a literal backslash-r sequence survives sanitisation and becomes a real carriage return afterwards. An authenticated user could then inject extra mail headers such as Bcc, Sender or Received into messages sent with the server's own SMTP credentials.
- Triaged in 21 hours
- Fixed in 46 days
- Disclosed after 2 months
Vulnerability Summary
Roundcube strips CR/LF from address input in rcmail_sendmail::email_input_format()
(program/include/rcmail_sendmail.php:760) and then, twenty-five lines later,
calls stripcslashes() on the recipient's display name at
program/include/rcmail_sendmail.php:790. An authenticated user who submits the
two-character sequence \r inside a quoted display name passes the strip
regexp untouched — there is no control character in the input yet — and
stripcslashes() converts it into a real 0x0D after the sanitizer has run.
Nothing downstream removes it. format_email_recipient()
(program/lib/Roundcube/bootstrap.php:329-333) escapes only ".
Mail_mimePart::encodeHeader() folds only /\r?\n[\s\t]*/, so a lone CR is
never matched, and its non-ASCII test preg_match('#([^\s\x21-\x7E]){1}#')
classifies CR as whitespace, so no RFC2047 encoding is applied either. Finally
Net_SMTP::quotedata() (vendor/pear/net_smtp/Net/SMTP.php:1489) normalises
every lone CR into a full CRLF, turning the injected text into real header
lines on the wire.
Steps to Reproduce
-
Log in to Roundcube as any user.
-
Send
POST /?_task=mail&_action=sendwith a valid_tokenand the body parameter — note\ris backslash followed by the letterr, not a control character:_to="x\rBcc: [email protected]\rSender: [email protected]\rX-Pad: p" <[email protected]> -
program/include/rcmail_sendmail.php:112reads the raw value; the CRLF strip atprogram/include/rcmail_sendmail.php:760matches nothing. -
program/include/rcmail_sendmail.php:790—$name = stripcslashes($name);materialises three real 0x0D bytes inside the display name. -
program/include/rcmail_sendmail.php:202assigns the result to$headers['To'];:384hands it toMail_mime;program/lib/Roundcube/rcube.php:1802serialises the headers, which leaves the lone CR intact. -
program/lib/Roundcube/rcube_smtp.php:321callsNet_SMTP::data(), whosequotedata()promotes each CR to CRLF. -
Run the executable proof, which exercises the real repository and vendor code end to end:
php roundcubemail-master_VULNHUNT_RESULTS_2026-08-03-095945/exploit_tests/test_vuln_001_smtp_header_injection_recipient.phpResult: PASS. On-the-wire output:
To: "x\r\n Bcc: [email protected]\r\n Sender: [email protected]\r\n X-Pad: p"\r\n <[email protected]>\r\nBcc: [email protected]andSender: [email protected]are asserted to be standalone CRLF-delimited header lines.
Impact
Any authenticated user gains arbitrary RFC-822 header emission on messages
relayed with the server's own SMTP submission credentials — a capability the
compose form deliberately does not expose (rcmail_sendmail.php:198-269 builds
the header array from a fixed key set). Concretely they can:
- forge
From:/Sender:/Reply-To:, bypassing the server-side identity lookup atrcmail_sendmail.php:147-175and theidentities_levelpinning enforced atprogram/actions/settings/identity_save.php:64-79— sender spoofing from a domain whose SPF/DKIM the mail server legitimately satisfies; - add covert
Bcc:recipients; - forge trust-signal headers (
Received:,Authentication-Results:,X-Spam-Status:) that downstream MTAs and spam filters consume; - inject an empty line to terminate the header block early and control the raw message body the MTA parses.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The input was sanitised before a later stripcslashes() call turned an escaped backslash-r sequence into a real carriage return, and no downstream component removed the lone CR.
Impact
An authenticated user could forge sender and reply headers, add hidden Bcc recipients, inject trust-signal headers consumed by downstream filters, and terminate the header block early to control the message body.
What the attacker needed
A Roundcube account; a valid request token
How it was found
- Log in to Roundcube as any user.
- Submit the mail send request with a valid token and a recipient display name containing the two-character backslash-r sequence.
- The CRLF strip runs on the raw value and matches nothing.
- stripcslashes() turns the sequence into real carriage return bytes inside the display name.
- The headers are serialised and passed to the SMTP library, which promotes each lone CR to CRLF.
- The proof script confirms the injected Bcc and Sender lines appear as standalone header lines on the wire.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Email messages are made of a header block (To, From, Subject and so on) followed by a blank line and the body. If a program lets a user's text contain a line break inside a header value, the user can start a new header line of their own. Here the program tried to remove line breaks first, but a two-character text sequence was turned into a real line break only after that check, so the injected headers slipped through.
What is Smuggling / CRLF?
A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.