mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #430] [CLOSED] fix(csp): allow 'unsafe-eval' in script-src so JS extensions run #4617
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#4617
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/430
Author: @kolacheee
Created: 5/5/2026
Status: ❌ Closed
Base:
main← Head:claude/wonderful-tu-e803be📝 Commits (1)
0a33cfcfix(csp): allow 'unsafe-eval' in script-src so JS extensions run📊 Changes
1 file changed (+7 additions, -1 deletions)
View changed files
📝
packages/server/src/middleware/security-headers.ts(+7 -1)📄 Description
The extension system in CustomThemeInjector executes user-installed extension JS via
new Function("marinara", ext.js)so extensions can receive the marinara API. The page CSP setscript-src 'self'with no 'unsafe-eval', which the browser enforces againstnew Function/eval, so every JS extension failed with EvalError and was effectively unusable.Grant 'unsafe-eval' on script-src only. All other directives remain strict — scripts must still be same-origin ('self'), so this does not permit inline script injection or remote script loading. The trade-off is documented inline next to the directive.
Linked issue
Closes #419
Why this change
EvalError: ... 'unsafe-eval' is not an allowed source of script: script-src 'self'. The extension system is effectively broken — anyone who installs a JS extension hits this.CustomThemeInjector.tsxruns user-installed extension JS vianew Function("marinara", ext.js)so extensions can receive the marinara API, but the server CSP insecurity-headers.tssetsscript-src 'self'with no'unsafe-eval'. The two contradict each other.What changed
packages/server/src/middleware/security-headers.ts: add'unsafe-eval'to thescript-srcdirective only. All other directives are unchanged — scripts must still be same-origin ('self'), so this does not permit inline script injection or remote script loading.CustomThemeInjectoras the consumer.Why not a stricter fix?
The architecturally cleaner alternative — running extension JS inside a sandboxed iframe with a postMessage RPC bridge — would let the main page CSP keep its strict
script-src 'self'. But it would break every existing extension's API surface (addStyle,addElement,observe, direct DOM access). That's a major rewrite, not a patch. This PR is the minimum coherent fix to restore extensions; tightening the sandbox is a follow-up.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
EvalErrorand thatmarinaraAPI methods (addStyle,addElement,on,observe, etc.) work.Docs and release impact
UI evidence (if applicable)
N/A — no UI changes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.