From 4794c5a0320fb23748bfec7c5f4c7fe5857efb5b Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 3 Oct 2026 16:43:47 -0500 Subject: [PATCH] Public pages can be framed (surf/rotator sites showed 'refused to connect'); board, sign-in, admin and member APIs keep X-Frame-Options DENY + frame-ancestors 'none' Co-Authored-By: Claude Opus 5.5 --- server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index cc4c091..f3fab44 100644 --- a/server.js +++ b/server.js @@ -110,7 +110,10 @@ function explorer() { return Number(process.env.HUNT_CHAIN_ID) === 80002 ? 'http // ---- helpers ------------------------------------------------------------------------------- const TYPES = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'application/javascript', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.webp': 'image/webp', '.mp4': 'video/mp4' }; -const SEC = { 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-Frame-Options': 'DENY' }; +// framing (2026-10-03, diannt's traffic-exchange 'refused to connect'): public pages may be shown in other sites' frames (surf +// and rotator sites); the signed-in board, sign-in, admin and member APIs never are (clickjacking guard set per request below) +const SEC = { 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin' }; +const NO_FRAME = p => /^\/(app|admin|auth|logout)(\/|$)/.test(p) || /^\/api\/(my|admin)(\/|$)/.test(p); function json(res, code, body, extra) { res.writeHead(code, Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }, SEC, extra || {})); res.end(JSON.stringify(body)); } function sendFile(res, file, extra) { // video streams with byte ranges (iOS Safari refuses to play without 206 support) @@ -159,6 +162,7 @@ const pubMission = m => ({ id: m.id, site: m.site, name: m.name, brief: m.brief, const server = http.createServer(async (req, res) => { try { const u = new URL(req.url, 'http://x'); const p = u.pathname; + if (NO_FRAME(p)) { res.setHeader('X-Frame-Options', 'DENY'); res.setHeader('Content-Security-Policy', "frame-ancestors 'none'"); } if (p === '/health') return json(res, 200, { ok: true, outbound: outbound(), signups: signupsOpen(), curtain: !!CURTAIN && !(LIVE_AT && live()), live: live(), liveAt: LIVE_AT ? new Date(LIVE_AT).toISOString() : null, faucet: faucetOn, sso: sso.enabled(), chain: Number(process.env.HUNT_CHAIN_ID) || null }); // the embed talks to us from the mission sites: it must work through the curtain, and it must