Skip to content

Commit 603e41d

Browse files
committed
Protect dashboard HEAD responses
1 parent 1cec6b9 commit 603e41d

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎scripts/orbit-slice1-worker-tests.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,18 @@ describe('Orbit V6 deployment-mode contract', () => {
268268
assert.match(await robots.text(), /Allow: \//u);
269269
});
270270

271+
test('applies dashboard privacy and frame protection to GET and HEAD', async () => {
272+
const env = productionBindings('live');
273+
for (const method of ['GET', 'HEAD']) {
274+
const response = await worker.fetch(new Request(`${LIVE_ORIGIN}/dashboard/`, { method }), env);
275+
assert.equal(response.status, 200);
276+
assert.equal(response.headers.get('cache-control'), 'no-store');
277+
assert.match(response.headers.get('content-security-policy') ?? '', /frame-ancestors 'none'/u);
278+
assert.equal(response.headers.get('x-frame-options'), 'DENY');
279+
await response.arrayBuffer();
280+
}
281+
});
282+
271283
test('preserves local and test validation without adding crawler denial', async () => {
272284
for (const env of [localBindings('local'), localBindings('test')]) {
273285
assert.doesNotThrow(() => assertIdentityBindings(env));

‎src/worker.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ export async function handleWorkerRequest(
8888
}
8989
return response;
9090
}
91-
if ((url.pathname === '/dashboard' || url.pathname === '/dashboard/') && request.method === 'GET') {
91+
if (
92+
(url.pathname === '/dashboard' || url.pathname === '/dashboard/')
93+
&& (request.method === 'GET' || request.method === 'HEAD')
94+
) {
9295
if (!env.ASSETS) return new Response('Not found', { status: 404 });
9396
return await dashboardAssetResponse(request, env.ASSETS);
9497
}

0 commit comments

Comments
 (0)