Repository navigation
feat(security): collect CSP violation reports so report-only means something #3470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
faf0978
feat(security): collect CSP violation reports so report-only means so…
kojiwakayama 4909f4b
fix(security): make the CSP report body limit real
kojiwakayama 2bc232c
fix(security): make the report endpoint reachable and its limits hold
kojiwakayama 2de7feb
docs(security): document the reporting directives the floor now emits
kojiwakayama 9512864
docs(security): drop an em dash from the reporting section
kojiwakayama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Where the platform CSP asks browsers to send violation reports. | ||
| * | ||
| * The policy is built in the security module and the reports are received by a | ||
| * server handler, so the path and the group name live here, on the side both | ||
| * can depend on. They have to agree: a `report-to` directive naming a group the | ||
| * `Reporting-Endpoints` header does not define makes the browser send nothing, | ||
| * and it fails silently. | ||
| */ | ||
|
|
||
| /** Path serving {@link CSP_REPORT_ENDPOINT_NAME}, on the project's own origin. */ | ||
| export const CSP_REPORT_PATH = "/_vf/csp-report"; | ||
|
|
||
| /** Reporting group tying the CSP `report-to` directive to `Reporting-Endpoints`. */ | ||
| export const CSP_REPORT_ENDPOINT_NAME = "veryfront-csp"; | ||
|
|
||
| /** | ||
| * Whether a request is the platform's own CSP report submission. | ||
| * | ||
| * The auth and CSRF gates both run ahead of the handler and both refuse a | ||
| * browser-generated report: it carries no credentials and no CSRF token, | ||
| * because a violation report is not a user action. Left alone, any project | ||
| * enabling either feature advertises a reporting endpoint that silently | ||
| * collects nothing. | ||
| * | ||
| * Exempting it is safe on the terms those gates exist for. The endpoint reads | ||
| * no credentials, changes no state, and answers 204 regardless of the body, so | ||
| * it discloses nothing about a protected project; what it writes is a bounded, | ||
| * sanitized, rate-limited log line. | ||
| */ | ||
| export function isCspReportRequest(method: string, pathname: string): boolean { | ||
| return method.toUpperCase() === "POST" && pathname === CSP_REPORT_PATH; | ||
| } |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.