Skip to content

fix: enforce webview security prefs from main process#10172

Open
jackkav wants to merge 1 commit into
developfrom
claude/quizzical-zhukovsky-7bba59
Open

fix: enforce webview security prefs from main process#10172
jackkav wants to merge 1 commit into
developfrom
claude/quizzical-zhukovsky-7bba59

Conversation

@jackkav

@jackkav jackkav commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a will-attach-webview handler on mainBrowserWindow.webContents in window-utils.ts
  • Security-critical WebPreferences (nodeIntegration, nodeIntegrationInSubFrames, allowRunningInsecureContent, preload, preloadURL) are now pinned in the main process and cannot be overridden by renderer-supplied attributes
  • The renderer's webpreferences string is still parsed for the one pref we trust: javascript (controls JS execution in HTML response preview — a legitimate user setting)
  • disableDialogs=true is always enforced from main regardless of renderer input

Background

window-utils.ts enables webviewTag: true for the main window (line 208). ResponseWebView renders untrusted response bodies inside a <webview> and sets prefs via a renderer-side string attribute (disableDialogs=true, javascript=yes/no). Without a will-attach-webview guard, a renderer compromise could supply arbitrary webpreferences values (e.g. nodeIntegration=true, a custom preload script) and the main process would apply them. This change moves enforcement to the main process.

Test plan

  • Open an HTTP response with HTML content type — verify the webview renders with JS enabled/disabled matching the "Disable JS" toggle
  • Confirm no regression in HTML preview rendering
  • Verify nodeIntegration is still false for webviews (default Electron behaviour, now also explicitly enforced)

Add a will-attach-webview handler on mainBrowserWindow.webContents so
that security-critical WebPreferences (nodeIntegration, preload, etc.)
are pinned in the main process regardless of what the renderer supplies
via the webpreferences attribute string.

The renderer-supplied string is still parsed for the one user-controlled
preference we trust (javascript on/off for HTML preview), but everything
else is overridden: nodeIntegration=false, nodeIntegrationInSubFrames=false,
allowRunningInsecureContent=false, disableDialogs=true.
@github-actions

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-06-26T13:03:38.617Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 9 9 0 (0.00%)
Click to view all circular references in PR (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

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.

1 participant