Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances security by validating the origin and source of incoming MessageEvents in ExtensionIFrameController, ExtensionManager, and SimulatedDevToolsController before processing them. This prevents the execution of messages from untrusted origins or unexpected window sources. Comprehensive unit tests have been added to verify these validation rules. The feedback points out that the CHANGELOG entry should be updated to use the past tense to comply with the repository's style guide.
johnpryan
force-pushed
the
validate-message-origin
branch
from
November 24, 2026 17:50
13967ca to
4ef9029
Compare
This change validates `MessageEvent.origin` and `MessageEvent.source` on `postMessage` events between DevTools and extensions. Before this change, incoming `message` events were parsed without checking their sender, allowing untrusted origins or unrelated windows to spoof extension or host events. * Validate that `event.origin` matches the expected HTTP(S) origin of `extensionUrl` and verify `event.source` strictly equals `extensionIFrame.contentWindow` in `ExtensionIFrameController._handleMessage`, dropping and logging unexpected messages. * Add `isAllowedDevToolsOrigin` to `devtools_extensions` to reject empty (`null`), non-HTTP(S), and malformed origins, allowing only the extension's own `window.origin` or loopback HTTP(S) hosts. * Validate `event.origin` with `isAllowedDevToolsOrigin` and verify `event.source` strictly equals the expected window (`window.parent` when embedded, or `window` in the simulated environment) in `ExtensionManager._handleMessage` and `SimulatedDevToolsController._handleMessage`. * Guard against `null` message payloads in `tryParseExtensionEvent` instead of force-unwrapping `data.dartify()`. * Add browser unit tests covering origin and source validation for `ExtensionIFrameController`, `ExtensionManager`, and `isAllowedDevToolsOrigin`, and update `packages/devtools_extensions/CHANGELOG.md`. Fixes flutter/dash-devexp-internal#86
johnpryan
force-pushed
the
validate-message-origin
branch
from
November 24, 2026 17:51
4ef9029 to
cb171f2
Compare
Contributor
Author
|
@kenzieschmoll @srawlins could you take a look? |
This branch has not been deployed
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.
This change validates
MessageEvent.originandMessageEvent.sourceonpostMessageevents between DevTools and extensions. Before this change, incomingmessageevents were parsed without checking their sender, allowing untrusted origins or unrelated windows to spoof extension or host events.event.originmatches the expected HTTP(S) origin ofextensionUrland verifyevent.sourcestrictly equalsextensionIFrame.contentWindowinExtensionIFrameController._handleMessage, dropping and logging unexpected messages.isAllowedDevToolsOrigintodevtools_extensionsto reject empty (null), non-HTTP(S), and malformed origins, allowing only the extension's ownwindow.originor loopback HTTP(S) hosts.event.originwithisAllowedDevToolsOriginand verifyevent.sourcestrictly equals the expected window (window.parentwhen embedded, orwindowin the simulated environment) inExtensionManager._handleMessageandSimulatedDevToolsController._handleMessage.nullmessage payloads intryParseExtensionEventinstead of force-unwrappingdata.dartify().ExtensionIFrameController,ExtensionManager, andisAllowedDevToolsOrigin, and updatepackages/devtools_extensions/CHANGELOG.md.Fixes https://github.com/flutter/dash-devexp-internal/issues/86