From 30ff8de1e82fdbb78f6c6e65b4e711dfa76a6ef1 Mon Sep 17 00:00:00 2001 From: ergosteur <1992147+ergosteur@users.noreply.github.com> Date: Fri, 14 Aug 2026 12:51:42 -0400 Subject: [PATCH] fix: allow WebAssembly in the CSP so xz sidecars can be decoded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The xz decompressor for Instaloader's .json.xz sidecars is WebAssembly, embedded as a data: URL that it fetches at startup. The CSP added in 1.3.0 blocked both halves of that: fetch('data:application/wasm;...') -> TypeError: Failed to fetch WebAssembly.instantiate(...) -> CompileError: violates script-src 'self' The first surfaces through new Response(stream).json() as a bare "Failed to fetch" with no stack, which reads like a network fault and is why this was mis-diagnosed twice. Vite's dev server never sends the CSP, so it reproduced only in production — every Instaloader archive silently lost its captions, story flags and profile metadata from 1.3.0 onward. script-src now allows 'wasm-unsafe-eval', which permits WebAssembly compilation without permitting eval() of JavaScript, and connect-src allows data: for the embedded module. Verified against the production bundle: rivvsofficial goes from 188 posts / 0 followers / no stories to 68 posts, 120 stories, 10,337 followers and its real name, bio and link — with zero decode errors. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_011uBWhwV3wFQ5MBCcMHHem7 --- package-lock.json | 4 ++-- package.json | 2 +- server.ts | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f96bb2d..bcde33d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "instaarchive-viewer", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "instaarchive-viewer", - "version": "1.6.0", + "version": "1.6.1", "dependencies": { "@tailwindcss/vite": "^4.1.14", "@vitejs/plugin-react": "^5.0.4", diff --git a/package.json b/package.json index 9f26bda..4c77021 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "instaarchive-viewer", "private": true, - "version": "1.6.0", + "version": "1.6.1", "type": "module", "scripts": { "dev": "vite --port=3000 --host=0.0.0.0", diff --git a/server.ts b/server.ts index 5192ccb..a3024d4 100644 --- a/server.ts +++ b/server.ts @@ -80,10 +80,16 @@ app.use((req, res, next) => { "default-src 'self'", "img-src 'self' blob: data:", "media-src 'self' blob: data:", - "script-src 'self'", + // 'wasm-unsafe-eval' permits WebAssembly compilation without allowing + // eval() of JavaScript. The xz decompressor used for Instaloader's + // .json.xz sidecars is WebAssembly, embedded as a data: URL it fetches at + // startup — so connect-src must allow data: too. Without both, decoding + // fails with a bare "TypeError: Failed to fetch" and every archive silently + // loses its captions, story flags and profile metadata. + "script-src 'self' 'wasm-unsafe-eval'", "style-src 'self' 'unsafe-inline'", "font-src 'self'", - "connect-src 'self'", + "connect-src 'self' data:", "worker-src 'self' blob:", "frame-ancestors 'self'", "object-src 'none'",