[GH-ISSUE #2525] [Issue]: Profile export ships custom_tools.webhookUrl unredacted (secret leak) #1252

Closed
opened 2026-10-21 05:29:59 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Romuromylus on GitHub.

Summary

Severity: Medium — security (secret leak in export). Profile export ships the custom_tools table verbatim, including webhookUrl, even though the same export path deliberately scrubs secrets from api_connections and agent_configs. A webhook URL is a bearer credential (a Discord webhook URL embeds its token in the path), so any exported/shared profile leaks live webhook secrets.

Expected behavior

sanitizeProfileTableRows() should redact custom_tools.webhookUrl before it is written into any profile export, mirroring how it already blanks api_connections.apiKeyEncrypted and redacts agent_configs secrets.

Actual behavior

packages/server/src/routes/backup.routes.ts:361-369:

function sanitizeProfileTableRows(tableName: string, rows: Array<Record<string, unknown>>) {
  if (tableName === "api_connections") {
    return rows.map((row) => ({ ...row, apiKeyEncrypted: "" }));
  }
  if (tableName === "agent_configs") {
    return rows.map((row) => redactAgentSecrets(row));
  }
  return rows; // <-- custom_tools (with webhook_url secret) falls through unredacted
}

custom_tools is a FILE_BACKED_TABLE (file-backed-store.ts:175) with a webhookUrl column (db/schema/custom-tools.ts:15), so buildProfileTableSnapshot() dumps it row-for-row. The webhook URL is a secret: discord-webhook.ts:9 defines DISCORD_WEBHOOK_REGEX = /^https:\/\/discord(?:app)?\.com\/api\/webhooks\/\d+\/[\w-]+$/, i.e. the token lives in the URL path. The unredacted snapshot reaches all export sinks: profile JSON export (marinara-profile.json, :956), native ZIP export (:859), and the on-disk backup envelope (buildProfileExportEnvelope → :1598).

Steps to reproduce

  1. Configure a custom tool with executionType=webhook (e.g. a Discord webhook).
  2. Export the profile (Settings → Export, any format) or create a backup.
  3. Inspect the resulting marinara-profile.json / export ZIP — the full secret webhook URL is present in plaintext.

Environment

  • Marinara Engine version: 1.6.1 (staging @ a9fdae8)
  • 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: add a custom_tools branch to sanitizeProfileTableRows() that blanks/redacts webhookUrl (and review scriptBody/staticResult for sensitivity), mirroring the existing two branches. The reference implementation is the function's own api_connections/agent_configs handling; the single skipped sibling call site is the custom_tools row set fed through buildProfileTableSnapshot() at :377-378.

Note the export is privileged-gated and requires the user to have configured a webhook tool and then shared the export, hence Medium. The on-disk backup additionally copies the raw SQLite DB, so the JSON/ZIP export (intended to be portable and shareable) is the meaningful incremental leak.

Regression notes: found via static audit; sanitizeProfileTableRows is byte-identical on main (65a0395, same two branches and return rows fall-through), so this is a long-standing shared bug, not a main→staging regression.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 9, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2525 Originally assigned to: @Romuromylus on GitHub. ## Summary **Severity: Medium — security (secret leak in export).** Profile export ships the `custom_tools` table verbatim, including `webhookUrl`, even though the same export path deliberately scrubs secrets from `api_connections` and `agent_configs`. A webhook URL is a bearer credential (a Discord webhook URL embeds its token in the path), so any exported/shared profile leaks live webhook secrets. ## Expected behavior `sanitizeProfileTableRows()` should redact `custom_tools.webhookUrl` before it is written into any profile export, mirroring how it already blanks `api_connections.apiKeyEncrypted` and redacts `agent_configs` secrets. ## Actual behavior `packages/server/src/routes/backup.routes.ts:361-369`: ```ts function sanitizeProfileTableRows(tableName: string, rows: Array<Record<string, unknown>>) { if (tableName === "api_connections") { return rows.map((row) => ({ ...row, apiKeyEncrypted: "" })); } if (tableName === "agent_configs") { return rows.map((row) => redactAgentSecrets(row)); } return rows; // <-- custom_tools (with webhook_url secret) falls through unredacted } ``` `custom_tools` is a `FILE_BACKED_TABLE` (`file-backed-store.ts:175`) with a `webhookUrl` column (`db/schema/custom-tools.ts:15`), so `buildProfileTableSnapshot()` dumps it row-for-row. The webhook URL is a secret: `discord-webhook.ts:9` defines `DISCORD_WEBHOOK_REGEX = /^https:\/\/discord(?:app)?\.com\/api\/webhooks\/\d+\/[\w-]+$/`, i.e. the token lives in the URL path. The unredacted snapshot reaches all export sinks: profile JSON export (`marinara-profile.json`, `:956`), native ZIP export (`:859`), and the on-disk backup envelope (`buildProfileExportEnvelope` → `:1598`). ## Steps to reproduce 1. Configure a custom tool with `executionType=webhook` (e.g. a Discord webhook). 2. Export the profile (Settings → Export, any format) or create a backup. 3. Inspect the resulting `marinara-profile.json` / export ZIP — the full secret webhook URL is present in plaintext. ## Environment - Marinara Engine version: 1.6.1 (`staging @ a9fdae8`) - 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: add a `custom_tools` branch to `sanitizeProfileTableRows()` that blanks/redacts `webhookUrl` (and review `scriptBody`/`staticResult` for sensitivity), mirroring the existing two branches. The reference implementation is the function's own `api_connections`/`agent_configs` handling; the single skipped sibling call site is the `custom_tools` row set fed through `buildProfileTableSnapshot()` at `:377-378`. Note the export is privileged-gated and requires the user to have configured a webhook tool and then shared the export, hence Medium. The on-disk backup additionally copies the raw SQLite DB, so the JSON/ZIP export (intended to be portable and shareable) is the meaningful incremental leak. Regression notes: found via static audit; `sanitizeProfileTableRows` is byte-identical on `main` (`65a0395`, same two branches and `return rows` fall-through), so this is a long-standing shared bug, not a `main`→`staging` regression. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:29:59 +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#1252
No description provided.