Repository navigation
Reject non-JSON Drand responses and add web security headers (#663, #665) - #689
Open
sojetunde8 wants to merge 1 commit into
Open
sojetunde8 wants to merge 1 commit into
sojetunde8 wants to merge 1 commit into
Conversation
…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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#663 drand-tools: reject non-JSON beacon responses
getChainInfoandgetBeaconcheck the responseContent-Typebefore parsing.application/jsonis 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.DrandResponseErrorwith the stablecategory"non-json-response"(also used when a JSON content type carries an unparsable body). Non-success statuses keep their existingHTTP <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.tsis the single source:Content-Security-Policy: frame-ancestors 'none',X-Frame-Options: DENY,X-Content-Type-Options: nosniff.vite.config.ts) and shipped to static hosts inapps/web/public/_headers.docs/web-security-headers.mddocuments 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 passpnpm --filter @sub-rosa/web exec node --import tsx --test src/lib/security-headers.test.ts: 5 passpnpm typecheckcurrently fails onmainin 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