Skip to content
Misconfiguration Disclosed report Intermediate

Persistent SMTP header injection via identity `organization` / `name`

The identity save handler stored the organization and name fields without validation or CRLF stripping, and the mailer later wrote the organization value into an unstructured header without folding or encoding. An attacker could inject extra SMTP headers such as Bcc and From into every message sent from that identity.

dogeshark Follow

Originally disclosed on HackerOne

Informational View original
  • Triaged in 21 hours
  • Fixed in 46 days
  • Disclosed after 46 days

Vulnerability Summary

program/actions/settings/identity_save.php:49-52 copies every identity column straight from the POST body. The handler validates only email, reply-to and bcc (via rcube_utils::check_email() at program/actions/settings/identity_save.php:82-97); name and organization are never validated and never CRLF-stripped. rcube_charset::clean() — the only transformation get_input_string() applies — preserves CR and LF verbatim.

The stored value is read back on every send and assigned unconditionally at program/include/rcmail_sendmail.php:216-218 ($headers['Organization'] = $identity_arr['organization'];). Organization is an unstructured header, and Mail_mimePart::encodeHeader() short-circuits that case: when the value is pure ASCII — its non-ASCII probe preg_match('#([^\s\x21-\x7E]){1}#') treats CR and LF as \s — and strlen($name.': '.$value) <= 78, it returns the value with no folding and no RFC2047 encoding at all. The raw CRLF reaches the wire as a header separator without Net_SMTP::quotedata() even needing to normalise anything.

Steps to Reproduce

  1. Log in to Roundcube as any user.

  2. Save an identity — POST /?_task=settings&_action=save-identity with a valid _token and:

    _organization=Acme%0D%0ABcc:%[email protected]%0D%0AFrom:%[email protected]
    

    PHP percent-decodes this into real CR/LF bytes.

  3. program/actions/settings/identity_save.php:49-52 copies _organization into $save_data['organization'] with no filtering; the email validation loop at program/actions/settings/identity_save.php:82-97 never inspects it.

  4. rcube_user::update_identity() persists the value byte-for-byte through a parameterised UPDATE.

  5. Compose and send any message using that identity — POST /?_task=mail&_action=send.

  6. program/include/rcmail_sendmail.php:148 → :652-664 reads the identity row back; program/include/rcmail_sendmail.php:216-218 assigns it to $headers['Organization'].

  7. program/lib/Roundcube/rcube.php:1802 serialises the headers through Mail_mimePart::encodeHeader(), whose unstructured short-ASCII branch applies no transformation; program/lib/Roundcube/rcube_smtp.php:321 writes them to the wire.

  8. Run the executable proof against the real repository and vendor code:

    php roundcubemail-master_VULNHUNT_RESULTS_2026-08-03-095945/exploit_tests/test_vuln_002_smtp_header_injection_identity.php
    

    Result: PASS. On-the-wire output:

    Organization: Acme\r\n
    Bcc: [email protected]\r\n
    From: [email protected]\r\n
    

Impact

Every message the account sends silently carries attacker-authored headers until the identity is edited — covert Bcc recipients, forged From:/Sender:, and forged trust signals consumed by downstream MTAs and spam filters, all emitted with the server's SMTP submission credentials.

The most damaging case is a deployment that sets identities_level to 1 or 3 specifically to stop users changing their sender address. That control unsets only email (program/actions/settings/identity_save.php:69-71), leaving organization writable — so the user injects their own From: header and defeats the pinning outright.

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

Likely the identity save handler copied the organization and name fields from the request without validation or CRLF stripping, and the header encoder skipped folding and encoding for short pure-ASCII unstructured values, so embedded line breaks passed through unchanged.

Impact

Every message the account sends could silently carry attacker-authored headers such as covert Bcc recipients and forged From or Sender values, and on deployments that pin the sender address the writable organization field could be used to defeat that pinning.

What the attacker needed

A free account; ability to save an identity; victim sends mail from that identity

How it was found

  1. Log in to Roundcube as any user.
  2. Submit the save-identity request with a valid token and a crafted organization value containing encoded line breaks.
  3. The handler copies the organization value into the save data without filtering, and the email validation loop never inspects it.
  4. The identity is persisted byte-for-byte through a parameterised update.
  5. Compose and send any message using that identity.
  6. The send path reads the identity back, assigns it to the Organization header, and the encoder passes it through unchanged to the SMTP connection.

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 section and a body, separated by a blank line, and each header sits on its own line. If a user-supplied value can contain line breaks, an attacker can end the current header early and add new ones of their own, such as a hidden copy recipient. Here the application saved such a value and later pasted it into outgoing mail without cleaning it.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

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.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.