Skip to content

Reject non-JSON Drand responses and add web security headers (#663, #665) - #689

Open
sojetunde8 wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
sojetunde8:feat/663-665-drand-json-check-web-security-headers
Open

sojetunde8 wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
sojetunde8:feat/663-665-drand-json-check-web-security-headers

Conversation

@sojetunde8

Copy link
Copy Markdown

Summary

#663 drand-tools: reject non-JSON beacon responses

  • getChainInfo and getBeacon check the response Content-Type before parsing. application/json is accepted, with or without a charset parameter and in any case; anything else (HTML, text/plain, text/json, application/jsonp, a missing header) is rejected.
  • Every such failure is a DrandResponseError with the stable category "non-json-response" (also used when a JSON content type carries an unparsable body). Non-success statuses keep their existing HTTP <status> error.
  • services/drand-tools/src/quicknet.test.ts (added to the package test script) covers the accepted and rejected shapes for both endpoints.

#665 web: clickjacking and content-type security headers

  • apps/web/src/lib/security-headers.ts is the single source: Content-Security-Policy: frame-ancestors 'none', X-Frame-Options: DENY, X-Content-Type-Options: nosniff.
  • Sent by the Vite dev and preview servers (vite.config.ts) and shipped to static hosts in apps/web/public/_headers.
  • docs/web-security-headers.md documents where deployment headers are configured, and what other hosts need.
  • apps/web/src/lib/security-headers.test.ts (added to the web test script) fails if _headers, the Vite config or the doc drift from the constant.

Tests

  • pnpm --filter @sub-rosa/drand-tools exec node --import tsx --test src/quicknet.test.ts: 9 pass
  • pnpm --filter @sub-rosa/web exec node --import tsx --test src/lib/security-headers.test.ts: 5 pass

pnpm typecheck currently fails on main in files this change does not touch (packages/tlock/src/seal.ts, services/agent/src/bidder.ts); the touched files typecheck cleanly.

Closes #663
Closes #665

…ders from the web app

- drand-tools validates the response Content-Type (application/json with an optional charset) before parsing chain info and beacons, and fails with one stable error category (Sub-Rosa-Issue#663)
- the web app sends Content-Security-Policy frame-ancestors 'none', X-Frame-Options DENY and X-Content-Type-Options nosniff from the Vite dev and preview servers and ships them in public/_headers; docs/web-security-headers.md says where they are configured, and a test keeps the places in step (Sub-Rosa-Issue#665)

Closes Sub-Rosa-Issue#663
Closes Sub-Rosa-Issue#665
@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@sojetunde8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web(high/easy): add clickjacking and content-type security headers drand-tools(high/easy): reject non-JSON beacon responses

1 participant