fix(security): reject non-same-origin popout URLs#1266
Merged
Conversation
popoutUrl is round-tripped through layout JSON (toJSON serializes the URL of each popout group; fromJSON restores it and feeds it back to window.open). An attacker who can supply layout JSON could embed a javascript:, data:, or cross-origin URL that would execute in a context the browser still associates with the opener via window.opener, exposing cookies, localStorage, and the parent DOM. assertSameOriginPopoutUrl runs at the popout-window open() gate and rejects anything that isn't same-origin http(s). The default '/popout.html' still works; existing dockview-core tests pass without change. Also adds a security caution to the popout-groups documentation page. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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
popoutUrlis round-tripped through layout JSON:toJSON()serializes the URL of each popout group, andfromJSON()restores it and feeds it back towindow.open(). An attacker who can supply layout JSON could embed ajavascript:,data:,blob:, or cross-origin URL that executes in a context the browser still associates with the opener viawindow.opener— exposing cookies,localStorage, and the parent DOM.assertSameOriginPopoutUrlruns at thePopoutWindow.open()gate and rejects anything that isn't same-originhttp(s). The default/popout.htmlkeeps working; existing dockview-core tests pass without change.popoutGroups.mdx.Breaking change (minor)
Consumers that intentionally pass a cross-origin
popoutUrlwill now see a thrown error. This is by design — that configuration was already unsafe — but worth flagging in release notes.Test plan
npx nx test dockview-core— 893/893 pass, including 16 newassertSameOriginPopoutUrlcases covering: relative paths, same-origin absolute,javascript:,data:,blob:,vbscript:,file:, and cross-origin (host, port, scheme)./popout.htmlstill works.addPopoutGroup(group, { popoutUrl: 'javascript:alert(1)' })and confirm it throws.🤖 Generated with Claude Code