mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2529] [Issue]: /api/extensions skips requirePrivilegedAccess that /api/custom-tools applies #1254
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#1254
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 @Romuromylus on GitHub (Jun 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2529
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Low — security (privilege-gate asymmetry). The
/api/extensionscreate/update/delete routes store an extension'sjs, which the client auto-executes in the browser whenenabledis true — yet they skiprequirePrivilegedAccess, the gate the sibling/api/custom-toolsroute applies to its less-dangerous artifacts. On a shared-credential basic-auth deployment, a lower-trust authenticated user can install persistent self-executing JS without the admin secret that creating a custom tool requires.Expected behavior
Creating/updating/deleting a self-executing-JS extension should require at least the same trust level as creating a custom tool — i.e.
requirePrivilegedAccesson the mutating handlers, matchingcustom-tools.routes.ts.Actual behavior
packages/server/src/routes/extensions.routes.ts:22-25:The POST/PATCH/DELETE handlers carry only the global basic-auth + CSRF hooks; none call
requirePrivilegedAccess. The siblingcustom-tools.routes.ts:31/45/59gates each mutating handler withrequirePrivilegedAccess, which on a non-loopback request additionally requires theADMIN_SECRETX-Admin-Secretheader (privileged-gate.ts:15-54). The extensionjsis the more dangerous artifact:CustomThemeInjector.tsx:109-261builds a blob-URL ES module fromext.jsandimport()s it with full DOM/window access wheneverext.enabledis true, with no per-load confirmation.Steps to reproduce
POST /api/extensionswith{ name, js: "<arbitrary JS>", enabled: true }.ADMIN_SECRETrequired (unlike a custom tool); its JS auto-executes in every operator's browser on the next extension-list poll.Environment
staging @ a9fdae8)Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix: apply
requirePrivilegedAccess(req, reply, { feature: "Extension install/update/delete" })to the POST/PATCH/DELETE handlers inextensions.routes.ts, mirroringcustom-tools.routes.ts:31/45/59; keep GET ungated for the client loader.requirePrivilegedAccessis already used by the admin, backup, custom-tools, haptic, import, sidecar, and updates routes — extensions is the lone CRUD route that creates a self-executing artifact yet omits it.Scope is Low: CSRF blocks a pure cross-site forge, so this matters only in the multi-operator shared-credential case; a single-operator install already fully trusts the operator. Filing it as the fix-pattern-already-in-repo gap it is.
Regression notes: found via static audit;
extensions.routes.tsis byte-identical onmain(65a0395), andmain's custom-tools route already carries the gate, so the asymmetry pre-exists — not amain→stagingregression.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: