[PR #2535] [MERGED] fix(backup): redact custom_tools.webhookUrl from profile exports #5637

Closed
opened 2026-10-22 04:18:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2535
Author: @Romuromylus
Created: 6/9/2026
Status: ✅ Merged
Merged: 6/9/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/profile-export-webhook-redact


📝 Commits (2)

  • 4bc939f fix(backup): redact custom_tools.webhookUrl from profile exports
  • 9a663af Merge branch 'staging' into fix/profile-export-webhook-redact

📊 Changes

1 file changed (+9 additions, -1 deletions)

View changed files

📝 packages/server/src/routes/backup.routes.ts (+9 -1)

📄 Description

Linked issue

Closes #2525

Why this change

sanitizeProfileTableRows() is the single chokepoint that scrubs secrets for every profile-export sink (JSON export, ZIP export, and the on-disk backup envelope). It redacts api_connections.apiKeyEncrypted and agent_configs secrets, then passes every other table through verbatim. custom_tools fell through, so its webhookUrl column was exported in plaintext. For executionType="webhook" tools the webhook URL is a bearer credential — a Discord webhook embeds its token in the URL path — so every exported/shared marinara-profile.json (and ZIP, and backup envelope) leaked the live secret.

What changed

packages/server/src/routes/backup.routes.ts:

  • Added a custom_tools branch to sanitizeProfileTableRows() that blanks webhookUrl, mirroring the api_connections apiKeyEncrypted branch.
  • Scope is webhookUrl only: scriptBody/staticResult are user-authored tool bodies, not credentials, so they are preserved.
  • The function is now exported so it can be unit-tested directly without the Fastify/DB stack.

webhook_url is a nullable column and the import path inserts rows as-is, so a round-tripped export imports cleanly with an empty webhookUrl (the user re-enters the URL — the same accepted trade-off already applied to api_connections.apiKeyEncrypted).

Not a regression: byte-identical on main; long-standing shared bug.

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

Manual verification notes

pnpm check passes locally. Added a local-only node:test (backup-sanitize.test.ts, gitignored): custom_tools.webhookUrl is blanked (the fix), scriptBody/staticResult are preserved (not over-scrubbed), the api_connections branch still blanks apiKeyEncrypted, and unrelated tables pass through untouched. Local run: 4/4 pass.

Still to verify manually against the deploy:

  • Create a Custom Tool with Execution Type = Webhook and a webhook URL, export the profile (JSON and ZIP), and confirm the exported custom_tools entry's webhookUrl is empty while name/description/parametersSchema/executionType remain intact.
  • Re-import the exported profile and confirm the tool imports without error.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

🔄 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/2535 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/9/2026 **Status:** ✅ Merged **Merged:** 6/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/profile-export-webhook-redact` --- ### 📝 Commits (2) - [`4bc939f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4bc939fd7d403be62b49ae93f54767caf06f7e24) fix(backup): redact custom_tools.webhookUrl from profile exports - [`9a663af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9a663af7acd46ec562aa2eae8018c2458af75008) Merge branch 'staging' into fix/profile-export-webhook-redact ### 📊 Changes **1 file changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/backup.routes.ts` (+9 -1) </details> ### 📄 Description ## Linked issue Closes #2525 ## Why this change `sanitizeProfileTableRows()` is the single chokepoint that scrubs secrets for every profile-export sink (JSON export, ZIP export, and the on-disk backup envelope). It redacts `api_connections.apiKeyEncrypted` and `agent_configs` secrets, then passes every other table through verbatim. `custom_tools` fell through, so its `webhookUrl` column was exported in plaintext. For `executionType="webhook"` tools the webhook URL is a bearer credential — a Discord webhook embeds its token in the URL path — so every exported/shared `marinara-profile.json` (and ZIP, and backup envelope) leaked the live secret. ## What changed `packages/server/src/routes/backup.routes.ts`: - Added a `custom_tools` branch to `sanitizeProfileTableRows()` that blanks `webhookUrl`, mirroring the `api_connections` `apiKeyEncrypted` branch. - Scope is `webhookUrl` only: `scriptBody`/`staticResult` are user-authored tool bodies, not credentials, so they are preserved. - The function is now `export`ed so it can be unit-tested directly without the Fastify/DB stack. `webhook_url` is a nullable column and the import path inserts rows as-is, so a round-tripped export imports cleanly with an empty `webhookUrl` (the user re-enters the URL — the same accepted trade-off already applied to `api_connections.apiKeyEncrypted`). Not a regression: byte-identical on `main`; long-standing shared bug. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes `pnpm check` passes locally. Added a local-only node:test (`backup-sanitize.test.ts`, gitignored): `custom_tools.webhookUrl` is blanked (the fix), `scriptBody`/`staticResult` are preserved (not over-scrubbed), the `api_connections` branch still blanks `apiKeyEncrypted`, and unrelated tables pass through untouched. Local run: **4/4 pass**. Still to verify manually against the deploy: - Create a Custom Tool with Execution Type = Webhook and a webhook URL, export the profile (JSON and ZIP), and confirm the exported `custom_tools` entry's `webhookUrl` is empty while name/description/parametersSchema/executionType remain intact. - Re-import the exported profile and confirm the tool imports without error. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:18:02 +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#5637
No description provided.