feat(security): report-only Content-Security-Policy for renderer#10169
Draft
jackkav wants to merge 1 commit into
Draft
feat(security): report-only Content-Security-Policy for renderer#10169jackkav wants to merge 1 commit into
jackkav wants to merge 1 commit into
Conversation
Electron security checklist item 7. Adds a Content-Security-Policy-Report-Only header to the index.html document served by the custom https protocol handler. Report-only mode does not block any flow; Chromium logs violations to the renderer console so the policy can be tuned from real data before a follow-up flips it to enforcing. Policy lives in content-security-policy.ts and is pinned by a unit test.
✅ Circular References ReportGenerated at: 2026-06-26T09:42:03.310Z Summary
Click to view all circular references in PR (9)Click to view all circular references in base branch (9)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
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
Implements item 7 of the Electron security checklist ("Define a Content-Security-Policy") for the main renderer.
The app currently ships no CSP. This adds one to the
index.htmldocument served by the customhttps://insomnia-app.localprotocol handler.Report-only first (by design)
The renderer is a large surface (Monaco, web workers, analytics, OAuth, custom protocols), so an over-strict enforcing policy would break flows silently. This PR ships
Content-Security-Policy-Report-Only, which:[Report Only] Refused to ...).A follow-up will tune the directives from observed reports and then flip the header to the enforcing
Content-Security-Policy.Where it's applied
protocol.handle(https)handler inapi.protocol.ts, since the document is served via a custom protocol (sowebRequest.onHeadersReceiveddoes not fire for it).index.htmlonly; subresources inherit the document policy. Static/assetsresponses are untouched.APP_RENDER_URL), not this handler, so the policy applies to packaged/production builds.Policy (first draft — to be tuned from reports)
Test plan
vitest run packages/insomnia/src/main/content-security-policy.test.ts[Report Only]violations to inform the enforcing follow-upChecklist context
2 of 2 follow-up PRs from a security-checklist audit of the main window (companion: the session permission handler PR). Item 12 (webview options) is handled by #9942.