Skip to content

Alerts: defuse mentions, links and line breaks in user-set text - #91

Merged
maca134 merged 5 commits into
mainfrom
fix/alert-text-escaping
Oct 19, 2026
Merged

maca134 merged 5 commits into
mainfrom
fix/alert-text-escaping

Conversation

@maca134

@maca134 maca134 commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Alert titles and bodies included task names and IdP emails verbatim, so a user could make an alert ping a channel (<!channel>, @here, _@channel) or carry a link (<url|text>, [x](url), plain URLs) to the admins' alert channel.

What changed (apps/api/src/lib/alerts.ts):

  • Whole alert title + body, service-neutral (one text goes to every shoutrrr service, so no per-service escapes showing up as &lt; or \[):
    • < > → ‹ ›
    • zero-width space after an @ that starts a word (emails like a@b.c unchanged)
    • zero-width space in ](
    • control characters except the body's own newlines → space
  • User-set text only (task name, email/sub, ended-session sub): newlines and U+2028/2029 → space so they can't add lines; :// split by a zero-width space so URLs don't autolink.
  • Tests: one shared task POST helper in alerts.test.ts.

Tested: new cases in apps/api/test/alerts.test.ts for a hostile email on a terminal alert and a hostile task name + email on a task_failed alert (title and body); both fail on the old code. bun run verify passes (api 140 pass / 10 skip, web 22, root 13).

Not covered: bare domains without a scheme can still autolink in Slack; rendering wasn't checked in real Slack/Discord/Mattermost, only the text handed to shoutrrr.

@maca134
maca134 merged commit c11ed1a into main Oct 19, 2026
4 checks passed
@maca134
maca134 deleted the fix/alert-text-escaping branch October 19, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant