Skip to content
Smuggling / CRLF Disclosed report Advanced

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.

dogeshark Follow

Originally disclosed on HackerOne

Informational View original
  • 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

  1. Log in to Roundcube as any user.

  2. Send POST /?_task=mail&_action=send with a valid _token and the body parameter — note \r is backslash followed by the letter r, not a control character:

    _to="x\rBcc: [email protected]\rSender: [email protected]\rX-Pad: p" <[email protected]>
    
  3. program/include/rcmail_sendmail.php:112 reads the raw value; the CRLF strip at program/include/rcmail_sendmail.php:760 matches nothing.

  4. program/include/rcmail_sendmail.php:790 — $name = stripcslashes($name); materialises three real 0x0D bytes inside the display name.

  5. program/include/rcmail_sendmail.php:202 assigns the result to $headers['To']; :384 hands it to Mail_mime; program/lib/Roundcube/rcube.php:1802 serialises the headers, which leaves the lone CR intact.

  6. program/lib/Roundcube/rcube_smtp.php:321 calls Net_SMTP::data(), whose quotedata() promotes each CR to CRLF.

  7. 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.php
    

    Result: 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\n
    

    Bcc: [email protected] and Sender: [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 at rcmail_sendmail.php:147-175 and the identities_level pinning enforced at program/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.

The original report as published on HackerOne, by dogeshark. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Log in to Roundcube as any user.
  2. Submit the mail send request with a valid token and a recipient display name containing the two-character backslash-r sequence.
  3. The CRLF strip runs on the raw value and matches nothing.
  4. stripcslashes() turns the sequence into real carriage return bytes inside the display name.
  5. The headers are serialised and passed to the SMTP library, which promotes each lone CR to CRLF.
  6. 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.

More by dogeshark

View all

4 more disclosed reports, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

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.