Skip to content

fix(security): escape link URLs in activity email templates#2551

Open
karlitschek wants to merge 1 commit intomasterfrom
fix/digest-email-xss
Open

fix(security): escape link URLs in activity email templates#2551
karlitschek wants to merge 1 commit intomasterfrom
fix/digest-email-xss

Conversation

@karlitschek
Copy link
Copy Markdown
Member

The activity-digest and queued-mail templates interpolate the link attribute of rich-subject parameters and the home URL directly into the href of an <a> tag without HTML-escaping. Activity providers typically supply internal Nextcloud URLs, but defensive escaping closes a potential "-breakout XSS vector should a provider ever expose user-influenced link values.

Wrap the URLs in htmlspecialchars(..., ENT_QUOTES, 'UTF-8') in:

  • DigestSender.php — "and N more" link, rich-subject link parameter
  • MailQueueHandler.php — home link, rich-subject link parameter

Translation-string templates ($l->t('...<a href="%s">...', ...)) are left as-is: their URLs come exclusively from linkToRouteAbsolute(), and escaping inside the gettext source string would force translators to handle escaping for every locale.

@cypress
Copy link
Copy Markdown

cypress Bot commented May 2, 2026

Activity    Run #3672

Run Properties:  status check passed Passed #3672  •  git commit e24d6083f4: fix(security): escape link URLs in activity email templates
Project Activity
Branch Review fix/digest-email-xss
Run status status check passed Passed #3672
Run duration 01m 59s
Commit git commit e24d6083f4: fix(security): escape link URLs in activity email templates
Committer Frank Karlitschek
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 1
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 9
View all changes introduced in this branch ↗︎

@nickvergessen
Copy link
Copy Markdown
Member

ENT_QUOTES, 'UTF-8'

Is not needed in supported PHP versions.

@miaulalala miaulalala force-pushed the fix/digest-email-xss branch 2 times, most recently from 37b99bc to 6467d78 Compare May 5, 2026 19:51
The activity-digest and queued-mail templates interpolate the `link`
attribute of rich-subject parameters and the home URL directly into
the `href` of an `<a>` tag without HTML-escaping. Activity providers
typically supply internal Nextcloud URLs, but defensive escaping
closes a potential `"`-breakout XSS vector should a provider ever
expose user-influenced link values.

Wrap the URLs in `htmlspecialchars(..., ENT_QUOTES, 'UTF-8')` in:
- DigestSender.php — "and N more" link, rich-subject link parameter
- MailQueueHandler.php — home link, rich-subject link parameter

Translation-string templates (`$l->t('...<a href="%s">...', ...)`) are
left as-is: their URLs come exclusively from `linkToRouteAbsolute()`,
and escaping inside the gettext source string would force translators
to handle escaping for every locale.

Signed-off-by: Frank Karlitschek <frank@nextcloud.com>
@miaulalala
Copy link
Copy Markdown
Collaborator

/backport to stable33

@miaulalala
Copy link
Copy Markdown
Collaborator

/backport to stable32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants