[GH-ISSUE #2369] [Issue]: Discord webhook mirror sends model/card content with no allowed_mentions, enabling @everyone / mass-mention injection #1168

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

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

Originally assigned to: @Romuromylus on GitHub.

Summary

Severity: Low — injection (notification abuse).

When Discord mirroring is enabled for a chat, every assistant turn is mirrored to the webhook with no allowed_mentions field. Discord webhooks parse mentions in content by default, so any @everyone / @here / <@&roleId> / <@userId> string the model emits (or that an imported card steers it into emitting) fires real Discord mentions, mass-pinging the mirrored server/role/user.

Expected behavior

The webhook payload should always set allowed_mentions: { parse: [] } (Discord's documented way to suppress all mentions regardless of content), so mirrored model output cannot trigger pings the user did not intend.

Actual behavior

discord_webhook_send (src-tauri/src/commands/storage/integrations/discord.rs:16-34) builds the payload with content / username / avatar_url and never sets allowed_mentions:

let content = required_string(&body, "content")?.trim();
let mut payload = Map::new();
payload.insert(
    "content".to_string(),
    Value::String(truncate_for_discord(content, DISCORD_CONTENT_LIMIT)),
);
// ... username / avatar_url inserted ...
// NOTE: no allowed_mentions key -> Discord parses @everyone/@here/role/user mentions in `content` by default

The untrusted-input → sink path: saved assistant message content (model output) → mirrorDiscordMessage (src/engine/generation/start-generation.ts:392-420, content = args.content.trim() with no mention stripping) → integrationGateway.discord.mirrorMessage (src/shared/api/integration-gateway.ts:65-72) → Tauri discord_webhook_send → POST to discord.com/api/webhooks/.... A grep confirms zero allowed_mentions / allowedMentions occurrences anywhere in src/ or src-tauri/. The outbound-URL fields here are hardened (is_valid_discord_webhook_url + is_allowed_outbound_url), but that is SSRF defense — there is no mention-suppression guard on the content body.

Blast radius is low: mirroring is opt-in and off until the user pastes a webhook URL into chat settings, the webhook targets a channel the user controls and opted into, and @everyone only fires if that channel grants the webhook mention rights. Impact is notification-spam / mass-ping in the user's own mirrored channel, not exfil or code execution.

Steps to reproduce

  1. Enable Discord mirroring on a chat (set a webhook URL in chat settings) for a server/channel where the webhook can mention.
  2. Have the model emit an assistant message containing @everyone (e.g. via a jailbreak or an imported card steering it).
  3. Observe the mirrored webhook message fire a real @everyone ping in the channel.

Impact area

  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime

Environment

  • Branch or commit: refactor @ 330f69a8
  • Run mode: Tauri desktop (also the remote/Docker runtime)
  • OS + version: not relevant (static source audit)
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: Discord webhook integration

Logs, screenshots, or video

Static source audit. Cited: integrations/discord.rs:16-34 (payload, no allowed_mentions); feeder start-generation.ts:392-420 (no mention stripping), integration-gateway.ts:65-72; grep confirms zero allowed_mentions occurrences across src/ and src-tauri/.

Regression notes

Found via static audit; not a regression. The web build's postToDiscordWebhook (packages/server/src/services/discord-webhook.ts) builds { content, username?, avatar_url? } with the identical missing allowed_mentions, so main has the same gap and the refactor neither broke nor inverted it.

Additional context

In discord_webhook_send, always insert payload.insert("allowed_mentions".to_string(), json!({ "parse": [] })); — Discord's documented mention-suppression for any content. Optionally also strip @everyone/@here in mirrorDiscordMessage as defense-in-depth. The sibling outbound-URL validation on this same command is the model to follow — the content body just lacks an equivalent guard.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2369 Originally assigned to: @Romuromylus on GitHub. ## Summary **Severity: Low — injection (notification abuse).** When Discord mirroring is enabled for a chat, every assistant turn is mirrored to the webhook with no `allowed_mentions` field. Discord webhooks parse mentions in `content` by default, so any `@everyone` / `@here` / `<@&roleId>` / `<@userId>` string the model emits (or that an imported card steers it into emitting) fires real Discord mentions, mass-pinging the mirrored server/role/user. ## Expected behavior The webhook payload should always set `allowed_mentions: { parse: [] }` (Discord's documented way to suppress all mentions regardless of content), so mirrored model output cannot trigger pings the user did not intend. ## Actual behavior `discord_webhook_send` (`src-tauri/src/commands/storage/integrations/discord.rs:16-34`) builds the payload with `content` / `username` / `avatar_url` and never sets `allowed_mentions`: ```rust let content = required_string(&body, "content")?.trim(); let mut payload = Map::new(); payload.insert( "content".to_string(), Value::String(truncate_for_discord(content, DISCORD_CONTENT_LIMIT)), ); // ... username / avatar_url inserted ... // NOTE: no allowed_mentions key -> Discord parses @everyone/@here/role/user mentions in `content` by default ``` The untrusted-input → sink path: saved assistant message content (model output) → `mirrorDiscordMessage` (`src/engine/generation/start-generation.ts:392-420`, `content = args.content.trim()` with no mention stripping) → `integrationGateway.discord.mirrorMessage` (`src/shared/api/integration-gateway.ts:65-72`) → Tauri `discord_webhook_send` → POST to `discord.com/api/webhooks/...`. A grep confirms zero `allowed_mentions` / `allowedMentions` occurrences anywhere in `src/` or `src-tauri/`. The outbound-URL fields here **are** hardened (`is_valid_discord_webhook_url` + `is_allowed_outbound_url`), but that is SSRF defense — there is no mention-suppression guard on the content body. Blast radius is low: mirroring is opt-in and off until the user pastes a webhook URL into chat settings, the webhook targets a channel the user controls and opted into, and `@everyone` only fires if that channel grants the webhook mention rights. Impact is notification-spam / mass-ping in the user's own mirrored channel, not exfil or code execution. ## Steps to reproduce 1. Enable Discord mirroring on a chat (set a webhook URL in chat settings) for a server/channel where the webhook can mention. 2. Have the model emit an assistant message containing `@everyone` (e.g. via a jailbreak or an imported card steering it). 3. Observe the mirrored webhook message fire a real `@everyone` ping in the channel. ## Impact area - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime ## Environment - Branch or commit: refactor @ 330f69a8 - Run mode: Tauri desktop (also the remote/Docker runtime) - OS + version: not relevant (static source audit) - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: Discord webhook integration ## Logs, screenshots, or video Static source audit. Cited: `integrations/discord.rs:16-34` (payload, no `allowed_mentions`); feeder `start-generation.ts:392-420` (no mention stripping), `integration-gateway.ts:65-72`; grep confirms zero `allowed_mentions` occurrences across `src/` and `src-tauri/`. ## Regression notes Found via static audit; **not a regression**. The web build's `postToDiscordWebhook` (`packages/server/src/services/discord-webhook.ts`) builds `{ content, username?, avatar_url? }` with the identical missing `allowed_mentions`, so main has the same gap and the refactor neither broke nor inverted it. ## Additional context In `discord_webhook_send`, always insert `payload.insert("allowed_mentions".to_string(), json!({ "parse": [] }));` — Discord's documented mention-suppression for any content. Optionally also strip `@everyone`/`@here` in `mirrorDiscordMessage` as defense-in-depth. The sibling outbound-URL validation on this same command is the model to follow — the content body just lacks an equivalent guard. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:15 +07:00
Author
Owner

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

Fixed by #2375, merged into refactor (squash 96686c79).

<!-- gh-comment-id:4637085508 --> @Romuromylus commented on GitHub (Jun 6, 2026): Fixed by #2375, merged into `refactor` (squash 96686c79).
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#1168
No description provided.