mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #401] [Issue]: Backup and Export Profile return 403 on loopback after v1.5.7 privileged-gate hardening #168
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#168
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cha1latte on GitHub (May 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/401
Originally assigned to: @SpicyMarinara on GitHub.
Summary
After v1.5.7's privileged-API hardening,
Settings → Download BackupandSettings → Export Profile (JSON)return 403 on a fresh install, even on loopback. The new gate requiresADMIN_SECRETto be configured server-side, but there is no in-app surface for setting it and the error toast doesn't point at the cause.Expected behavior
On a fresh install running on
127.0.0.1, clicking Download Backup should produce a backup file and clicking Export Profile (JSON) should produce a profile export, with no manual env-var setup required.Actual behavior
Both buttons show generic failure toasts ("Failed to create backup" / "Failed to export profile"). DevTools Network tab shows:
GET :7860/api/backup/download→ 403 ForbiddenGET :7860/api/backup/export-profile?format=compatible→ 403 ForbiddenResponse body for both:
The 403 originates from
requirePrivilegedAccessinpackages/server/src/middleware/privileged-gate.ts(added inf35f8a4, "Harden security defaults and privileged flows").isBasicAuthSatisfiedcorrectly short-circuits for loopback, butgetAdminSecret()then fails because the env var is unset on a fresh install. Affected routes include backup, profile-export, profile-import, custom-tools, sidecar, updates, and import.Client side is already wired up —
getAdminSecretHeader()inpackages/client/src/lib/api-client.tsreadsmarinara_admin_secretfrom localStorage and adds it asX-Admin-Secret, and Settings → Advanced → Admin Access provides a UI for setting that localStorage key. The wire format and the client-side UI are fine; what's missing is any in-app surface or prompt for the server-sideADMIN_SECRETenv var, and any indication that both halves are required.This looks like a regression rather than intended UX:
marinara_admin_secret, but there is no in-app surface or prompt for the server-sideADMIN_SECRETenv var, and no indication that both halves are required. A user who only fills in the Admin Access field still gets 403s.127.0.0.1:7860can also readpackages/server/datadirectly, so the gate provides no real confidentiality on loopback.Steps to reproduce
.env, noADMIN_SECRETconfigured).start.bat, open the UI onhttp://localhost:7860.Download Backup(orExport Profile (JSON)).Environment
8325c75)Likely affects all platforms — the logic is in server middleware and is platform-independent.
Logs, screenshots, or video
Network → Response body for both failing requests:
Additional context
Ruled out:
GET /export-profileis also affected, and the response body is the admin-secret message — not CSRF's "Request origin is not trusted" / "Missing x-marinara-csrf header".b40bb19. Different code path.start.batas administrator does not help. FS errors would surface as 500, not 403.non-precached-urlconsole error: Separate sw.js bug, filed as #402 .Proposed fix (one of):
MARINARA_REQUIRE_ADMIN_SECRET_ON_LOOPBACK(defaultfalse) for users who want strict behavior. Non-loopback requests continue to requireADMIN_SECRETas today.ADMIN_SECRETto.envvia a one-time, loopback-only bootstrap endpoint and saves the matching value to localStorage in the same action. Closes the loop without lowering the security bar.In either case, the 403 response body should grow a machine-readable code so the toast can render something actionable instead of "Failed to create backup."
Temporary workaround:
ADMIN_SECRET=<long random string>to.envin the install dir.Template check
@SpicyMarinara commented on GitHub (May 4, 2026):
Addressed in a fix.