Skip to content

fix(security): CSP report-only and security headers#424

Open
gabitoesmiapodo wants to merge 2 commits intofix/seofrom
fix/security
Open

fix(security): CSP report-only and security headers#424
gabitoesmiapodo wants to merge 2 commits intofix/seofrom
fix/security

Conversation

@gabitoesmiapodo
Copy link
Collaborator

Summary

  • Add Content-Security-Policy-Report-Only header via vercel.json to capture violations without breaking the app
  • Add X-Content-Type-Options, X-Frame-Options, Referrer-Policy headers

Test plan

  • pnpm test passes
  • Deploy preview and check response headers contain CSP-Report-Only
  • Monitor CSP report endpoint for violations before switching to enforced mode

Copilot AI review requested due to automatic review settings March 23, 2026 21:45
@vercel
Copy link

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components.dappbooster Ready Ready Preview, Comment Mar 25, 2026 7:10pm
demo.dappbooster Ready Ready Preview Mar 25, 2026 7:10pm
docs.dappbooster Ready Ready Preview, Comment Mar 25, 2026 7:10pm

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds security-related response headers at the Vercel edge to begin monitoring Content Security Policy violations (in Report-Only mode) and to set several baseline hardening headers for all routes.

Changes:

  • Configure Content-Security-Policy-Report-Only for all paths via vercel.json.
  • Add X-Content-Type-Options, X-Frame-Options, and Referrer-Policy headers globally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"headers": [
{
"key": "Content-Security-Policy-Report-Only",
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri /csp-report"
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report-uri /csp-report points to an endpoint that doesn’t appear to exist in the repo, and the current catch-all SPA rewrite (/(.*) -> /) will also rewrite /csp-report to /. As a result, CSP violation reports won’t be received/processed, which defeats the stated purpose of this PR. Consider either (a) implementing a real report ingestion endpoint (e.g., a Vercel Function) and exempting it from the rewrite, or (b) sending reports to an external HTTPS endpoint instead of a rewritten path.

Suggested change
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri /csp-report"
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri https://csp-report.example.com/report"

Copilot uses AI. Check for mistakes.
"headers": [
{
"key": "Content-Security-Policy-Report-Only",
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri /csp-report"
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This CSP is extremely permissive for a report-only rollout (script-src includes 'unsafe-inline' and 'unsafe-eval', and connect-src allows any https:/wss:). With those allowances, many important violations won’t be reported, making the collected data much less actionable when switching to enforced mode. For the report-only phase, it’s usually better to start from a stricter baseline and add exceptions based on real violations.

Suggested change
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri /csp-report"
"value": "default-src 'self'; script-src 'self' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https://va.vercel-scripts.com; frame-ancestors 'none'; report-uri /csp-report"

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +10
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri /csp-report"
},
{
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report-uri is deprecated in favor of report-to / Reporting-Endpoints. If you’re adding CSP reporting infrastructure now, consider switching to the newer reporting directives (and adding the corresponding Report-To/Reporting-Endpoints header) to avoid having to migrate later.

Suggested change
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-uri /csp-report"
},
{
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https: blob:; connect-src 'self' https: wss:; frame-ancestors 'none'; report-to csp-endpoint"
},
{
"key": "Report-To",
"value": "{\"group\":\"csp-endpoint\",\"max_age\":10886400,\"endpoints\":[{\"url\":\"/csp-report\"}]}"
},
{

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add Content-Security-Policy-Report-Only via vercel.json headers
  to capture violations without breaking existing functionality
- Add X-Content-Type-Options, X-Frame-Options, and Referrer-Policy headers
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.

3 participants