feat(browser): in-app browser tab with webview security hardening - #3181
feat(browser): in-app browser tab with webview security hardening#3181MattPua wants to merge 18 commits into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
- Globe button in panel tab bars opens an embedded browser tab (Electron <webview>), gated behind posthog-code-browser-tab flag - Main-process hardening: preload/node stripped from guests, scheme allowlist (http/https/about), link-local metadata range blocked, powerful permissions denied, popups routed http(s)-only to OS browser - Address bar normalizes input (scheme passthrough, host detection, search fallback); disallowed schemes become searches - Last committed url persists on the tab for restore-on-reload Generated-By: PostHog Code Task-Id: 4bc7193a-bc2b-4365-8435-a6b20cd00c08
b4db740 to
7ca9a4e
Compare
|
Addressed the review feedback (PostHog Code, on behalf of the author):
|
|
React Doctor found 11 issues in 4 files · 11 warnings. 11 warnings
Reviewed by React Doctor for commit |
Single "+" opens a Terminal/Browser menu instead of a row of icon buttons; falls back to the direct add-terminal button when the browser flag is off (a one-item menu is worse than a plain button). Generated-By: PostHog Code Task-Id: 4bc7193a-bc2b-4365-8435-a6b20cd00c08
- Indeterminate top bar (shared quill-section-loading swoop) over the page area during loads - Reload button becomes a stop button mid-load Generated-By: PostHog Code Task-Id: 4bc7193a-bc2b-4365-8435-a6b20cd00c08
Generated-By: PostHog Code Task-Id: 4bc7193a-bc2b-4365-8435-a6b20cd00c08
82f4907 to
deae0e5
Compare
Generated-By: PostHog Code Task-Id: 29a0c450-6d5c-454e-a2c0-608d280d4737
Generated-By: PostHog Code Task-Id: 29a0c450-6d5c-454e-a2c0-608d280d4737
Block the IPv6-mapped metadata address and GCP's metadata DNS name, which the IPv4-only host check let through. Extract the pure navigation guard to a testable module with regression coverage. Generated-By: PostHog Code Task-Id: 29a0c450-6d5c-454e-a2c0-608d280d4737
…elper updateTabLabel/updateTabMetadata/updateBrowserTabUrl shared the same find-tab-walk-and-map dance. Extract updateTabById; add coverage for the two transforms that lacked it. Generated-By: PostHog Code Task-Id: 29a0c450-6d5c-454e-a2c0-608d280d4737
There was a problem hiding this comment.
Security-sensitive Electron change (webviewTag enabled, navigation guards, permission handlers) with zero independent human review — all comments are from the PR author (self-review via AI) or a bot. Per policy, higher-risk changes need at least one independent human reviewer before auto-approval.
|
Did we implement these already in #3221? |
|
@charlesvien i believe those are "tab implementations" and this is actually running the browser |
Posted in error; review feedback will be shared privately with the requester.
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
PR overviewThis pull request adds an in-app browser tab backed by a webview and introduces navigation-guard logic for controlling where the webview can load content from. The touched code focuses on handling browser navigation rules for local and web origins. There is one open low-risk issue in the navigation guard: the loopback hostname check can incorrectly treat crafted remote DNS names as local loopback-style HTTP destinations. That could allow a webview to load plaintext remote content where HTTPS would normally be required, creating an opportunity for content tampering by an on-path attacker. One issue has already been addressed, so the remaining work is narrowed to tightening the loopback IPv4 validation. Open issues (1)
Fixed/addressed: 1 · PR risk: 4/10 |
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
Generated-By: PostHog Code Task-Id: b23f944d-dd7f-465b-9fed-1a1d028f35e1
| // solely as the src a new blank browser tab mounts with before | ||
| // the user enters a url. | ||
| const LOOPBACK_HOSTS = new Set(["localhost", "0.0.0.0", "[::1]"]); | ||
| const LOOPBACK_IPV4 = /^127\./; |
There was a problem hiding this comment.
Low: Loopback check accepts remote DNS names
A hostname such as 127.attacker.example matches this expression, so a page can redirect the guest to a remote plaintext HTTP origin that would otherwise require HTTPS. An on-path attacker can then replace the content loaded in the webview; require a complete canonical IPv4 literal instead.
| const LOOPBACK_IPV4 = /^127\./; | |
| const LOOPBACK_IPV4 = /^127(?:\.\d{1,3}){3}$/; |
|
This PR has had no activity for 7 days and has been marked stale. We are moving to the monorepo and tightening PR staleness in preparation, so it will be closed in 7 days if no further activity occurs. |
|
Closing stale PRs ahead of Friday's monorepo migration. If this is a mistake, rebase and reopen for review. |
Problem
Working on web changes means bouncing between the app and an external browser. There is no way to view docs, a local dev server, or another page inside the app next to a task.
Changes
CleanShot.2026-07-06.at.13.12.17.mp4
Adds an embedded browser tab, gated behind
posthog-code-browser-taband enabled by default in local development.<webview>.dom-ready, surfaces attachment failures, and queues early Enter navigation until the webview is ready.about:blankfor main-frame navigation.How did you test this?
dom-ready.Automatic notifications
Created with PostHog Code