[GH-ISSUE #2481] [Issue]: Backup / profile zip ships raw apiKeyEncrypted in connections.json, defeating the profile.json masking #1224

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Severity: Low — security (secret export) regression. Managed backup / download-profile zip masks apiKeyEncrypted in the marinara-profile.json snapshot, but then also copies the raw data/ directory verbatim into the same archive — so data/collections/connections.json ships the real apiKeyEncrypted ciphertext, defeating the masking applied to its sibling file.

Expected behavior

The backup/profile zip should not contain apiKeyEncrypted. Either exclude data/collections/connections.json from the raw data/ copy (rely on the masked marinara-profile.json for connections), or pass it through mask_connection_for_read before copying — so both members of the archive agree.

Actual behavior

// src-tauri/src/commands/storage/backup.rs:11 (BACKUP_DIRS includes "data")
// write_backup_payload (101-117):
let profile = profile::profile_backup_snapshot(state)?;   // masked — apiKeyEncrypted stripped
fs::write(target.join("marinara-profile.json"), to_vec_pretty(&profile)?)?;
for dir in BACKUP_DIRS {                                   // 110-114 — copies data/ verbatim
    let source = state.data_dir.join(dir);
    if source.exists() { copy_dir_contents(&source, &target.join(dir))?; }
}

marinara-profile.json is masked (connections routed through connections_for_export → mask_connection_for_read, which removes apiKeyEncrypted), but copy_dir_contents copies data/collections/connections.json unfiltered, and that on-disk row carries the real AES-256-GCM apiKeyEncrypted. The test at backup.rs:325-327 confirms data/collections/*.json lands in the archive. All three entry points (create_backup, download_backup, download_profile_zip) route through write_backup_payload.

Steps to reproduce

  1. With at least one connection that has a saved API key, create a managed backup / download backup / download profile zip.
  2. Inspect data/collections/connections.json inside the resulting zip — apiKeyEncrypted is present, even though marinara-profile.json shows apiKey: "••••••••".

Impact area

  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime

Environment

  • Branch or commit: refactor @ 1fae2c42
  • Run mode: Tauri desktop
  • OS + version: found via static source audit (not runtime-reproduced)
  • Node + pnpm versions: n/a (static audit)
  • Rust version, if relevant: n/a (static audit)
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: any connection with a saved key

Logs, screenshots, or video

Static trace: backup.rs:11 (BACKUP_DIRS includes data), :101-117 (masked profile.json + verbatim data/ copy), copy_dir_contents:76-99, masking path connection_secrets.rs:82-92 + :28; test :325-327.

Regression notes

Regression vs main, whose ZIP export carries no apiKeyEncrypted at all. The refactor's verbatim data/ copy reintroduced the encrypted-credential material into the archive, defeating the intended masking.

Additional context

Severity caveat (not a refutation): apiKeyEncrypted is AES-256-GCM ciphertext and the master key lives at data/secrets/connection-master.key, which is not in BACKUP_DIRS — so the zip alone is not plaintext-decryptable. This is therefore a hardened-but-real export-sanitization-contract break (defense-in-depth), hence Low. Fix: exclude or mask data/collections/connections.json in write_backup_payload to match profile_collections().

Template check

Please uncheck 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 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2481 Originally assigned to: @SpicyMarinara on GitHub. ## Summary **Severity: Low — security (secret export) regression.** Managed backup / download-profile zip masks `apiKeyEncrypted` in the `marinara-profile.json` snapshot, but then also copies the raw `data/` directory verbatim into the same archive — so `data/collections/connections.json` ships the real `apiKeyEncrypted` ciphertext, defeating the masking applied to its sibling file. ## Expected behavior The backup/profile zip should not contain `apiKeyEncrypted`. Either exclude `data/collections/connections.json` from the raw `data/` copy (rely on the masked `marinara-profile.json` for connections), or pass it through `mask_connection_for_read` before copying — so both members of the archive agree. ## Actual behavior ```rust // src-tauri/src/commands/storage/backup.rs:11 (BACKUP_DIRS includes "data") // write_backup_payload (101-117): let profile = profile::profile_backup_snapshot(state)?; // masked — apiKeyEncrypted stripped fs::write(target.join("marinara-profile.json"), to_vec_pretty(&profile)?)?; for dir in BACKUP_DIRS { // 110-114 — copies data/ verbatim let source = state.data_dir.join(dir); if source.exists() { copy_dir_contents(&source, &target.join(dir))?; } } ``` `marinara-profile.json` is masked (connections routed through `connections_for_export` → `mask_connection_for_read`, which removes `apiKeyEncrypted`), but `copy_dir_contents` copies `data/collections/connections.json` unfiltered, and that on-disk row carries the real AES-256-GCM `apiKeyEncrypted`. The test at `backup.rs:325-327` confirms `data/collections/*.json` lands in the archive. All three entry points (`create_backup`, `download_backup`, `download_profile_zip`) route through `write_backup_payload`. ## Steps to reproduce 1. With at least one connection that has a saved API key, create a managed backup / download backup / download profile zip. 2. Inspect `data/collections/connections.json` inside the resulting zip — `apiKeyEncrypted` is present, even though `marinara-profile.json` shows `apiKey: "••••••••"`. ## Impact area - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime ## Environment - Branch or commit: refactor @ 1fae2c42 - Run mode: Tauri desktop - OS + version: found via static source audit (not runtime-reproduced) - Node + pnpm versions: n/a (static audit) - Rust version, if relevant: n/a (static audit) - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: any connection with a saved key ## Logs, screenshots, or video Static trace: `backup.rs:11` (`BACKUP_DIRS` includes `data`), `:101-117` (masked profile.json + verbatim `data/` copy), `copy_dir_contents:76-99`, masking path `connection_secrets.rs:82-92` + `:28`; test `:325-327`. ## Regression notes Regression vs main, whose ZIP export carries no `apiKeyEncrypted` at all. The refactor's verbatim `data/` copy reintroduced the encrypted-credential material into the archive, defeating the intended masking. ## Additional context Severity caveat (not a refutation): `apiKeyEncrypted` is AES-256-GCM ciphertext and the master key lives at `data/secrets/connection-master.key`, which is **not** in `BACKUP_DIRS` — so the zip alone is not plaintext-decryptable. This is therefore a hardened-but-real export-sanitization-contract break (defense-in-depth), hence Low. Fix: exclude or mask `data/collections/connections.json` in `write_backup_payload` to match `profile_collections()`. ## Template check Please uncheck 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:18 +07:00
Author
Owner

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

Fixed on refactor in 038b7220.

Backup/profile export now masks connections.json through the connection secret masking path, so raw apiKeyEncrypted values are not shipped in managed backups.

Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.

<!-- gh-comment-id:4638718757 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed on refactor in 038b7220. Backup/profile export now masks connections.json through the connection secret masking path, so raw apiKeyEncrypted values are not shipped in managed backups. Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.
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#1224
No description provided.