mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3122] [Issue]: Game audio blocked by CSP — media-src is missing data: (data:audio/wav clip rejected) #1671
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#1671
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 @kolacheee on GitHub (Jun 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3122
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
In Game mode, the browser blocks a small
data:audio/wavclip the app tries to play, and logs a Content-Security-Policy error:The app's CSP allows
data:URIs for images and fonts, but themedia-srcdirective was never givendata:— so anydata:audio/video is blocked. The specific clip here is the silent "unlock audio" primer the game audio manager plays on first interaction to let subsequent SFX/music autoplay; with it blocked, that priming fails and the console fills with the CSP violation.How to reproduce (try it yourself)
You'll see:
Loading media from 'data:audio/wav;base64,…' violates … "media-src 'self' blob: https:". The action has been blocked.Expected: the
data:audio clip plays (or is at least allowed by the CSP), with no violation, likedata:images already are.Where it is
packages/server/src/middleware/security-headers.ts:32—"media-src 'self' blob: https:". It's missingdata:. Note the sibling directives that do allow it:img-src 'self' data: blob: https:(line 31) andfont-src 'self' data:(line 33).packages/client/src/lib/game-audio.ts:13definesSILENT_AUDIO_DATA_URIas exactly thisdata:audio/wav;base64,UklGRkQD…clip, andprimeMediaElement()(lines 217-220) plays it vianew Audio(SILENT_AUDIO_DATA_URI)(muted, volume 0) to unlock autoplay. Thatnew Audio(...)is what tripsmedia-src.What's happening
data:was added toimg-srcandfont-srcbut notmedia-src, so the game audio manager's silent-WAV primer (and any otherdata:audio the app might play) is blocked by CSP.data:media is self-contained (no network request), so allowing it carries no real risk — it's just an omission relative to the image/font directives.Suggested fix
Add
data:to themedia-srcdirective insecurity-headers.ts:32:(That matches
img-src/font-src, which already allowdata:.) Alternatively, convert the silent primer to ablob:URL instead of adata:URI —blob:is already inmedia-src— but the CSP one-liner is the minimal, consistent fix.AI-investigated against the current tree (v2.0.9); the CSP directive and the
SILENT_AUDIO_DATA_URI/primeMediaElementsource read and confirmed. Please verify before fixing.@SpicyMarinara commented on GitHub (Jul 2, 2026):
Codex is taking this in branch codex/issue-sweep-3119-3135 for a staging-targeted fix sweep.
@SpicyMarinara commented on GitHub (Jul 2, 2026):
Fix is ready in PR #3138 with CI passing. This issue will close automatically when the PR merges into staging.