[PR #7818] [MERGED] fix(security): harden ssrf #7944

Closed
opened 2026-10-24 04:09:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7818
Author: @SpicyMarinara
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/19/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/harden-ssrf


📝 Commits (1)

  • 1e7c611 fix(security): keep chat outside addresses on the install that set them

📊 Changes

6 files changed (+357 additions, -5 deletions)

View changed files

📝 packages/server/src/routes/backup.routes.ts (+66 -0)
📝 packages/server/src/routes/chat-presets.routes.ts (+8 -2)
📝 packages/server/src/routes/chats.routes.ts (+3 -1)
📝 packages/server/src/services/import/st-chat.importer.ts (+3 -1)
📝 packages/shared/src/types/chat-preset.ts (+21 -1)
➕ scripts/regressions/chat-local-destination-security.regression.ts (+256 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

No public issue. This is pre-release hardening the maintainer asked for.

Why this change

A few chat settings tell the server where to send chat text, or hold the key for such a service: the Discord mirror webhook, the DeepLX address, the DeepL API key and the Intiface (haptics) server address. Until now these settings travelled with shared files. A chat log or settings profile made on another install could set them when imported, and exports included the owner's own webhook token and DeepL key. Only the person who set up an install should decide where its chats are sent. This change keeps those settings on the install where they were entered, the same way connection API keys and custom tool webhooks already stay local.

What changed

  • packages/shared: added CHAT_METADATA_LOCAL_DESTINATION_KEYS (discordWebhookUrl, translationDeeplxUrl, translationDeeplApiKey, hapticIntifaceUrl) and an omitChatMetadataLocalDestinations helper. Updated the comment on the settings profile type.
  • Chat log import (importSTChat, which covers /import/st-chat, /import/st-chat-into-group and SillyTavern bulk import): drops these keys from the imported Marinara metadata.
  • Chat log export (JSONL): leaves them out of the header metadata.
  • Settings profile import and export (/chat-presets/import, /chat-presets/:id/export): leaves them out. Profiles saved on this install still keep them, so applying your own profile still sets your Discord mirror.
  • Full profile export (sanitizeProfileTableRows): leaves them out of chat metadata, settings profile metadata and the translator defaults for new chats.
  • Full profile import: an imported chat, settings profile or translator default gets none of these values. A row restored over a row that already exists here keeps this install's values.
  • New regression scripts/regressions/chat-local-destination-security.regression.ts. It covers every path above, checks that ordinary settings (auto-translate, provider, context limit) still carry over, and checks that local profiles keep the mirror.

Behaviour change: when you move a chat, settings profile or full profile to another install, the Discord mirror webhook, DeepLX address, DeepL key and Intiface address have to be entered again there. Restoring a full profile onto the same install keeps them.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Commands run by the agent:

  • pnpm check: passed. The only lint output is one existing client warning in a file this PR does not touch.
  • pnpm regression:security: passed, including the new regression.
  • Ran the new regression with each server change reverted in turn: it fails each time and passes with all changes in place.
  • Related regressions also passed: chat-profile-followers, chat-export-swipes-batch, chat-branch-lineage, bulk-export-zips, profile-export-agent-settings, profile-import-noodle, profile-apply-hide-summarised, sillytavern-group-import, open-issues, background-translation, haptic, world-save-state, roleplay-interrupt-storage, chat-settings-hint, chat-window-defaults, and the backup regressions.

No browser or container testing was done.

Manual verification notes

  • Manually verify in the browser: set a Discord mirror webhook on a chat, export it as JSONL, and confirm the file's header metadata has no discordWebhookUrl.
  • Manually verify: import a JSONL chat log whose marinara_metadata contains a Discord webhook, DeepLX URL, DeepL key and Intiface URL. Open Chat Settings on the new chat and confirm the Discord Mirror, DeepLX URL, DeepL key and Intiface address fields are empty. Auto-translate and the provider choice should still come through.
  • Manually verify: import a .marinara-settings-profile.json that contains those keys while a chat is open. Confirm the chat's Discord Mirror and translator address fields are not filled from the file.
  • Manually verify: save a settings profile from a chat that has a Discord mirror set, then apply it to another chat on the same install. Confirm the mirror is copied.
  • Manually verify: export a full profile, then import it on the same install. Confirm each chat's Discord Mirror and the translator defaults are unchanged.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No user-facing doc mentions the Discord mirror or translator settings travelling with exports, so no docs were changed.

UI evidence (if applicable)

No UI changes.

Summary by CodeRabbit

  • Bug Fixes
    • Profile and chat-log exports no longer include installation-specific destination addresses or keys, such as Discord, translation, and haptics settings.
    • Imported profiles no longer apply those external destinations. Where matching local settings exist, they are preserved; otherwise, the destination values are omitted.
    • Other app settings remain unaffected.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7818 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/harden-ssrf` --- ### 📝 Commits (1) - [`1e7c611`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e7c6111c70a0a317029220803d7ddc45f4548d9) fix(security): keep chat outside addresses on the install that set them ### 📊 Changes **6 files changed** (+357 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/backup.routes.ts` (+66 -0) 📝 `packages/server/src/routes/chat-presets.routes.ts` (+8 -2) 📝 `packages/server/src/routes/chats.routes.ts` (+3 -1) 📝 `packages/server/src/services/import/st-chat.importer.ts` (+3 -1) 📝 `packages/shared/src/types/chat-preset.ts` (+21 -1) ➕ `scripts/regressions/chat-local-destination-security.regression.ts` (+256 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue No public issue. This is pre-release hardening the maintainer asked for. ## Why this change A few chat settings tell the server where to send chat text, or hold the key for such a service: the Discord mirror webhook, the DeepLX address, the DeepL API key and the Intiface (haptics) server address. Until now these settings travelled with shared files. A chat log or settings profile made on another install could set them when imported, and exports included the owner's own webhook token and DeepL key. Only the person who set up an install should decide where its chats are sent. This change keeps those settings on the install where they were entered, the same way connection API keys and custom tool webhooks already stay local. ## What changed - `packages/shared`: added `CHAT_METADATA_LOCAL_DESTINATION_KEYS` (`discordWebhookUrl`, `translationDeeplxUrl`, `translationDeeplApiKey`, `hapticIntifaceUrl`) and an `omitChatMetadataLocalDestinations` helper. Updated the comment on the settings profile type. - Chat log import (`importSTChat`, which covers `/import/st-chat`, `/import/st-chat-into-group` and SillyTavern bulk import): drops these keys from the imported Marinara metadata. - Chat log export (JSONL): leaves them out of the header metadata. - Settings profile import and export (`/chat-presets/import`, `/chat-presets/:id/export`): leaves them out. Profiles saved on this install still keep them, so applying your own profile still sets your Discord mirror. - Full profile export (`sanitizeProfileTableRows`): leaves them out of chat metadata, settings profile metadata and the translator defaults for new chats. - Full profile import: an imported chat, settings profile or translator default gets none of these values. A row restored over a row that already exists here keeps this install's values. - New regression `scripts/regressions/chat-local-destination-security.regression.ts`. It covers every path above, checks that ordinary settings (auto-translate, provider, context limit) still carry over, and checks that local profiles keep the mirror. Behaviour change: when you move a chat, settings profile or full profile to another install, the Discord mirror webhook, DeepLX address, DeepL key and Intiface address have to be entered again there. Restoring a full profile onto the same install keeps them. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Commands run by the agent: - `pnpm check`: passed. The only lint output is one existing client warning in a file this PR does not touch. - `pnpm regression:security`: passed, including the new regression. - Ran the new regression with each server change reverted in turn: it fails each time and passes with all changes in place. - Related regressions also passed: chat-profile-followers, chat-export-swipes-batch, chat-branch-lineage, bulk-export-zips, profile-export-agent-settings, profile-import-noodle, profile-apply-hide-summarised, sillytavern-group-import, open-issues, background-translation, haptic, world-save-state, roleplay-interrupt-storage, chat-settings-hint, chat-window-defaults, and the backup regressions. No browser or container testing was done. ### Manual verification notes - Manually verify in the browser: set a Discord mirror webhook on a chat, export it as JSONL, and confirm the file's header metadata has no `discordWebhookUrl`. - Manually verify: import a JSONL chat log whose `marinara_metadata` contains a Discord webhook, DeepLX URL, DeepL key and Intiface URL. Open Chat Settings on the new chat and confirm the Discord Mirror, DeepLX URL, DeepL key and Intiface address fields are empty. Auto-translate and the provider choice should still come through. - Manually verify: import a `.marinara-settings-profile.json` that contains those keys while a chat is open. Confirm the chat's Discord Mirror and translator address fields are not filled from the file. - Manually verify: save a settings profile from a chat that has a Discord mirror set, then apply it to another chat on the same install. Confirm the mirror is copied. - Manually verify: export a full profile, then import it on the same install. Confirm each chat's Discord Mirror and the translator defaults are unchanged. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No user-facing doc mentions the Discord mirror or translator settings travelling with exports, so no docs were changed. ## UI evidence (if applicable) No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Profile and chat-log exports no longer include installation-specific destination addresses or keys, such as Discord, translation, and haptics settings. * Imported profiles no longer apply those external destinations. Where matching local settings exist, they are preserved; otherwise, the destination values are omitted. * Other app settings remain unaffected. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:09:03 +07:00
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#7944
No description provided.