[GH-ISSUE #419] [Issue]: CSP introduced in f35f8a47 blocks all extensions (script-src 'self' missing 'unsafe-eval') #177

Closed
opened 2026-10-20 17:25:55 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @cha1latte on GitHub (May 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/419

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The CSP introduced in f35f8a47 sets script-src 'self' without 'unsafe-eval', which blocks the extension loader's new Function(...) call and prevents any extension from loading. This worked correctly in 159f5a2. Original Discord post: https://discord.com/channels/1417099416812392641/1501008256355668098

Expected behavior

The MVP extension loads and prints [MVP-Ext] Loaded successfully. to the browser console.

Actual behavior

The extension fails to execute. Two errors appear in the console:

[Extension:MVP Extension] Failed to execute: EvalError: call to Function() blocked by CSP
Content-Security-Policy: The page's settings blocked a JavaScript eval (script-src) from being executed because it violates the following directive: "script-src 'self'" (Missing 'unsafe-eval')

This affects all extensions — the user was able to reproduce it with a do-nothing minimum-viable extension.

Steps to reproduce

  1. Check out any commit at or after f35f8a47 (confirmed broken on current main; last known-good commit is 159f5a2).
  2. Install the minimum-viable extension from this gist: https://gist.github.com/jake9000/1e47d7c57453d812ceef211d52cc9ba9
  3. Open the browser dev console and reload Marinara Engine.

The MVP extension is just:

{
  "name": "MVP Extension",
  "description": "Prints a simple message into your js console and nothing else.",
  "js": "console.log(\"[MVP-Ext] Loaded successfully.\");\n",
  "enabled": true
}

Environment

  • Marinara Engine version:
  • Install type:
  • OS + version:
  • Browser or app shell:

Logs, screenshots, or video

Console output on load:

[Extension:MVP Extension] Failed to execute: EvalError: call to Function() blocked by CSP
Content-Security-Policy: The page's settings blocked a JavaScript eval (script-src) from being executed because it violates the following directive: "script-src 'self'" (Missing 'unsafe-eval')

Additional context

The extension loader appears to compile extension JS strings into functions via new Function(...), which browsers treat as eval for CSP purposes. The new policy doesn't include 'unsafe-eval', so every extension is blocked regardless of content.

A few directions for a fix, in order of effort:

  1. Add 'unsafe-eval' to script-src — easiest, but undoes part of the hardening from f35f8a47.
  2. Load extension JS as a Blob + dynamic import() so it runs as a real ES module; allow blob: in script-src. More targeted than 'unsafe-eval'.
  3. Materialize extensions to files at install time and load them as static <script type="module"> from a known directory. Strictest, but a bigger refactor to the extension install flow.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @cha1latte on GitHub (May 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/419 Originally assigned to: @SpicyMarinara on GitHub. ## Summary <!-- What is wrong in one or two sentences? --> The CSP introduced in `f35f8a47` sets `script-src 'self'` without `'unsafe-eval'`, which blocks the extension loader's `new Function(...)` call and prevents any extension from loading. This worked correctly in `159f5a2`. Original Discord post: https://discord.com/channels/1417099416812392641/1501008256355668098 ## Expected behavior <!-- What should have happened? --> The MVP extension loads and prints `[MVP-Ext] Loaded successfully.` to the browser console. ## Actual behavior <!-- What happened instead? --> The extension fails to execute. Two errors appear in the console: ``` [Extension:MVP Extension] Failed to execute: EvalError: call to Function() blocked by CSP ``` ``` Content-Security-Policy: The page's settings blocked a JavaScript eval (script-src) from being executed because it violates the following directive: "script-src 'self'" (Missing 'unsafe-eval') ``` This affects all extensions — the user was able to reproduce it with a do-nothing minimum-viable extension. ## Steps to reproduce 1. Check out any commit at or after `f35f8a47` (confirmed broken on current `main`; last known-good commit is `159f5a2`). 2. Install the minimum-viable extension from this gist: https://gist.github.com/jake9000/1e47d7c57453d812ceef211d52cc9ba9 3. Open the browser dev console and reload Marinara Engine. The MVP extension is just: ```json { "name": "MVP Extension", "description": "Prints a simple message into your js console and nothing else.", "js": "console.log(\"[MVP-Ext] Loaded successfully.\");\n", "enabled": true } ``` ## Environment - Marinara Engine version: <!-- fill in: commit SHA or tag of the broken build you tested --> - Install type: <!-- fill in: source / installer / docker / termux / other --> - OS + version: <!-- fill in --> - Browser or app shell: <!-- fill in — error wording suggests Firefox; confirm version --> ## Logs, screenshots, or video <!-- Paste relevant logs and add screenshots when possible --> Console output on load: ``` [Extension:MVP Extension] Failed to execute: EvalError: call to Function() blocked by CSP Content-Security-Policy: The page's settings blocked a JavaScript eval (script-src) from being executed because it violates the following directive: "script-src 'self'" (Missing 'unsafe-eval') ``` ## Additional context <!-- Optional: related issue links, temporary workaround, etc. --> The extension loader appears to compile extension JS strings into functions via `new Function(...)`, which browsers treat as `eval` for CSP purposes. The new policy doesn't include `'unsafe-eval'`, so every extension is blocked regardless of content. A few directions for a fix, in order of effort: 1. Add `'unsafe-eval'` to `script-src` — easiest, but undoes part of the hardening from `f35f8a47`. 2. Load extension JS as a `Blob` + dynamic `import()` so it runs as a real ES module; allow `blob:` in `script-src`. More targeted than `'unsafe-eval'`. 3. Materialize extensions to files at install time and load them as static `<script type="module">` from a known directory. Strictest, but a bigger refactor to the extension install flow. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:25:55 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (May 5, 2026):

Fixed,

<!-- gh-comment-id:4377974157 --> @SpicyMarinara commented on GitHub (May 5, 2026): Fixed,
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#177
No description provided.