[GH-ISSUE #1920] [Issue]: remote runtime privileged commands do not use Admin Access guard #937

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Remote /api/invoke exposes several high-risk commands through the hostable runtime, but the refactor path does not currently have a per-command Admin Access / ADMIN_SECRET guard equivalent to the legacy protected server routes.

Expected behavior

Remote runtime calls that create backups, import profiles, browse server folders, apply updates, or clear/expunge data should require the same privileged-access boundary as the legacy server surface, or they should be explicitly documented as covered by a different refactor security model.

Actual behavior

Static inspection on current origin/refactor shows:

  • src/shared/api/remote-runtime.ts allowlists high-risk commands including profile_import, profile_import_upload, backup_create, backup_delete, backup_download, import_list_directory, admin_expunge_command, admin_clear_all_command, and update_apply.
  • src-tauri/src/http_dispatch.rs dispatches those commands directly through /api/invoke.
  • src-tauri/src/http_server.rs applies global hostable runtime checks for IP allowlist, Basic Auth, and browser-origin CSRF, but there is no per-command Admin Access / ADMIN_SECRET check in the dispatch path.
  • The current Settings Admin Access field stores marinara-admin-secret locally, but the shared API wrappers do not send an admin header to /api/invoke.

Legacy server routes used requirePrivilegedAccess for comparable high-risk endpoints such as admin expunge/clear-all, backup create/delete/download, profile import/export, bulk import, folder browsing, update apply, and haptic control.

Steps to reproduce

  1. Inspect the remote command allowlist in src/shared/api/remote-runtime.ts.
  2. Inspect the matching dispatch arms in src-tauri/src/http_dispatch.rs.
  3. Compare those paths with the global hostable middleware in src-tauri/src/http_server.rs.
  4. Compare legacy protected routes that call requirePrivilegedAccess in packages/server/src/routes/*.

No destructive runtime call was made for this report.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: origin/refactor at 0afe673
  • Run mode: remote runtime / /api/invoke
  • OS + version: not captured
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not captured
  • Remote Runtime URL configured? yes
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

No runtime screenshot attached. Static evidence:

  • src/shared/api/remote-runtime.ts: remote allowlist includes the high-risk commands named above.
  • src-tauri/src/http_dispatch.rs: /api/invoke dispatches those commands.
  • src-tauri/src/http_server.rs: hostable middleware enforces global IP/auth/CSRF checks.
  • src/features/shell/settings/components/SettingsPanel.tsx: Admin Access persists an ADMIN_SECRET value locally.
  • src/shared/api/admin-api.ts: admin clear/expunge wrappers call invokeTauri without an admin-access argument.
  • Legacy packages/server/src/middleware/privileged-gate.ts and protected routes require X-Admin-Secret for privileged operations outside the loopback exception.

Regression notes

This overlaps the hostable-runtime security lane in #1855, but it is a focused current refactor issue. It does not affect public release builds while refactor remains unreleased.

Additional context

Suggested fix:

  • Define which remote commands are privileged.
  • Add an Admin Access header/body path to invokeRemote or to specific shared API wrappers.
  • Enforce the privileged boundary in http_server.rs or http_dispatch.rs before dispatching high-risk commands.
  • Add focused Rust coverage for at least one allowed non-privileged command and one denied privileged command, with a negative control.

Related tracker: #1904 target 3, remote runtime parity.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jun 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1920 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Remote `/api/invoke` exposes several high-risk commands through the hostable runtime, but the refactor path does not currently have a per-command Admin Access / `ADMIN_SECRET` guard equivalent to the legacy protected server routes. ## Expected behavior Remote runtime calls that create backups, import profiles, browse server folders, apply updates, or clear/expunge data should require the same privileged-access boundary as the legacy server surface, or they should be explicitly documented as covered by a different refactor security model. ## Actual behavior Static inspection on current `origin/refactor` shows: - `src/shared/api/remote-runtime.ts` allowlists high-risk commands including `profile_import`, `profile_import_upload`, `backup_create`, `backup_delete`, `backup_download`, `import_list_directory`, `admin_expunge_command`, `admin_clear_all_command`, and `update_apply`. - `src-tauri/src/http_dispatch.rs` dispatches those commands directly through `/api/invoke`. - `src-tauri/src/http_server.rs` applies global hostable runtime checks for IP allowlist, Basic Auth, and browser-origin CSRF, but there is no per-command Admin Access / `ADMIN_SECRET` check in the dispatch path. - The current Settings Admin Access field stores `marinara-admin-secret` locally, but the shared API wrappers do not send an admin header to `/api/invoke`. Legacy server routes used `requirePrivilegedAccess` for comparable high-risk endpoints such as admin expunge/clear-all, backup create/delete/download, profile import/export, bulk import, folder browsing, update apply, and haptic control. ## Steps to reproduce 1. Inspect the remote command allowlist in `src/shared/api/remote-runtime.ts`. 2. Inspect the matching dispatch arms in `src-tauri/src/http_dispatch.rs`. 3. Compare those paths with the global hostable middleware in `src-tauri/src/http_server.rs`. 4. Compare legacy protected routes that call `requirePrivilegedAccess` in `packages/server/src/routes/*`. No destructive runtime call was made for this report. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `origin/refactor` at `0afe673` - Run mode: remote runtime / `/api/invoke` - OS + version: not captured - Node + pnpm versions: not relevant - Rust version, if relevant: not captured - Remote Runtime URL configured? yes - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video No runtime screenshot attached. Static evidence: - `src/shared/api/remote-runtime.ts`: remote allowlist includes the high-risk commands named above. - `src-tauri/src/http_dispatch.rs`: `/api/invoke` dispatches those commands. - `src-tauri/src/http_server.rs`: hostable middleware enforces global IP/auth/CSRF checks. - `src/features/shell/settings/components/SettingsPanel.tsx`: Admin Access persists an `ADMIN_SECRET` value locally. - `src/shared/api/admin-api.ts`: admin clear/expunge wrappers call `invokeTauri` without an admin-access argument. - Legacy `packages/server/src/middleware/privileged-gate.ts` and protected routes require `X-Admin-Secret` for privileged operations outside the loopback exception. ## Regression notes This overlaps the hostable-runtime security lane in #1855, but it is a focused current refactor issue. It does not affect public release builds while refactor remains unreleased. ## Additional context Suggested fix: - Define which remote commands are privileged. - Add an Admin Access header/body path to `invokeRemote` or to specific shared API wrappers. - Enforce the privileged boundary in `http_server.rs` or `http_dispatch.rs` before dispatching high-risk commands. - Add focused Rust coverage for at least one allowed non-privileged command and one denied privileged command, with a negative control. Related tracker: #1904 target 3, remote runtime parity. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:23:48 +07:00
Author
Owner

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

Fixed on refactor in a4ba3c90: privileged remote commands now require Admin Access on non-loopback clients via X-Admin-Secret/ADMIN_SECRET, and the remote client sends the stored Admin Access secret for privileged commands. Verification passed: typecheck, architecture, docs, build, cargo check, diff check.

<!-- gh-comment-id:4601639282 --> @SpicyMarinara commented on GitHub (Jun 2, 2026): Fixed on refactor in a4ba3c90: privileged remote commands now require Admin Access on non-loopback clients via X-Admin-Secret/ADMIN_SECRET, and the remote client sends the stored Admin Access secret for privileged commands. Verification passed: typecheck, architecture, docs, build, cargo check, diff check.
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#937
No description provided.