[GH-ISSUE #2615] [Issue]: Discord webhook mirror omits allowed_mentions — LLM/user content can @everyone/@here-ping the server #1288

Closed
opened 2026-10-21 05:30:44 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Romuromylus on GitHub (Jun 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2615

Originally assigned to: @Romuromylus on GitHub.

Summary

Severity: Medium — security. The Discord webhook mirror posts message content with no allowed_mentions field. Discord's default when that field is omitted is to parse all mentions, so @everyone/@here/role/user pings in mirrored LLM output, imported-card-injected output, or user messages reach Discord and ping the whole channel/server.

Expected behavior

Mirrored content should never trigger Discord mentions. The webhook payload should suppress @everyone/@here/role/user pings on relayed text.

Actual behavior

postToDiscordWebhook builds a payload with only content/username/avatar_url — no allowed_mentions:

// packages/server/src/services/discord-webhook.ts
interface WebhookPayload {            // ~16-20
  content: string;
  username?: string;
  avatar_url?: string;
}
// ~78-80: body = { content: opts.content, username, avatar_url } — POSTed with no allowed_mentions

The relayed content is raw and unsanitized on all call paths: generate.routes.ts:6070 (content: fullResponse, raw LLM output), generate.routes.ts:1208 (content: pendingUserDiscordMsg, raw user input from input.userMessage), and game.routes.ts:971 (mirrorGameMessageToDiscord). A grep over packages/server for allowed_mentions/@everyone/@here returns no matches — there is no mention stripping anywhere. A malicious imported card/lorebook/persona can prompt-inject the model to emit @everyone/<@&ROLE_ID>, the model can emit them spontaneously, or a user message carrying them is mirrored verbatim — the bot then mass-pings on every mirrored turn.

Steps to reproduce

  1. Enable the per-chat Discord webhook mirror.
  2. Send (or have the model emit, e.g. via an injected card) a message containing @everyone or <@&ROLE_ID>.
  3. Observe Discord pings the entire channel/server scope.

Environment

  • Marinara Engine version: staging @ 56f700cd (v2.0.0)
  • Install type: source
  • OS + version: n/a — static source audit
  • Browser or app shell: n/a

Logs, screenshots, or video

Static source audit, cited to file:line above.

Additional context

Fix sketch. Extend WebhookPayload with allowed_mentions?: { parse: string[]; roles?: string[]; users?: string[] } and set allowed_mentions: { parse: [] } on every body built in postToDiscordWebhook, so Discord suppresses @everyone/@here/role/user pings while leaving the relayed text intact. This neutralizes mention-injection from LLM output and imported content at the single choke point.

Regression notes. Not a regression — discord-webhook.ts is byte-identical on main (same interface, same body, no allowed_mentions). Shared engine code on both branches. (The prior matching finding #2369 was on the discontinued refactor line, not this staging/web line.)

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2615 Originally assigned to: @Romuromylus on GitHub. ## Summary **Severity: Medium — security.** The Discord webhook mirror posts message content with no `allowed_mentions` field. Discord's default when that field is omitted is to parse **all** mentions, so `@everyone`/`@here`/role/user pings in mirrored LLM output, imported-card-injected output, or user messages reach Discord and ping the whole channel/server. ## Expected behavior Mirrored content should never trigger Discord mentions. The webhook payload should suppress `@everyone`/`@here`/role/user pings on relayed text. ## Actual behavior `postToDiscordWebhook` builds a payload with only `content`/`username`/`avatar_url` — no `allowed_mentions`: ```ts // packages/server/src/services/discord-webhook.ts interface WebhookPayload { // ~16-20 content: string; username?: string; avatar_url?: string; } // ~78-80: body = { content: opts.content, username, avatar_url } — POSTed with no allowed_mentions ``` The relayed `content` is raw and unsanitized on all call paths: `generate.routes.ts:6070` (`content: fullResponse`, raw LLM output), `generate.routes.ts:1208` (`content: pendingUserDiscordMsg`, raw user input from `input.userMessage`), and `game.routes.ts:971` (`mirrorGameMessageToDiscord`). A `grep` over `packages/server` for `allowed_mentions`/`@everyone`/`@here` returns no matches — there is no mention stripping anywhere. A malicious imported card/lorebook/persona can prompt-inject the model to emit `@everyone`/`<@&ROLE_ID>`, the model can emit them spontaneously, or a user message carrying them is mirrored verbatim — the bot then mass-pings on every mirrored turn. ## Steps to reproduce 1. Enable the per-chat Discord webhook mirror. 2. Send (or have the model emit, e.g. via an injected card) a message containing `@everyone` or `<@&ROLE_ID>`. 3. Observe Discord pings the entire channel/server scope. ## Environment - Marinara Engine version: `staging @ 56f700cd` (v2.0.0) - Install type: source - OS + version: n/a — static source audit - Browser or app shell: n/a ## Logs, screenshots, or video Static source audit, cited to file:line above. ## Additional context **Fix sketch.** Extend `WebhookPayload` with `allowed_mentions?: { parse: string[]; roles?: string[]; users?: string[] }` and set `allowed_mentions: { parse: [] }` on every body built in `postToDiscordWebhook`, so Discord suppresses `@everyone`/`@here`/role/user pings while leaving the relayed text intact. This neutralizes mention-injection from LLM output and imported content at the single choke point. **Regression notes.** Not a regression — `discord-webhook.ts` is byte-identical on `main` (same interface, same body, no `allowed_mentions`). Shared engine code on both branches. (The prior matching finding #2369 was on the discontinued refactor line, not this staging/web line.) ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:30:44 +07:00
  • closed this issue
  • added the
    server
    bug
    labels
Author
Owner

@Romuromylus commented on GitHub (Jun 18, 2026):

Fixed in #2623, merged to staging (e1132e5b). Closing manually since the PR targeted staging rather than the default branch.

<!-- gh-comment-id:4742295447 --> @Romuromylus commented on GitHub (Jun 18, 2026): Fixed in #2623, merged to `staging` (e1132e5b). Closing manually since the PR targeted `staging` rather than the default branch.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1288
No description provided.