Skip to content

security(webview): restrict native JS channel callbacks to configured origin#2285

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/application-security-review-8801
Draft

security(webview): restrict native JS channel callbacks to configured origin#2285
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/application-security-review-8801

Conversation

@cursor

@cursor cursor Bot commented Jun 16, 2026

Copy link
Copy Markdown

Vulnerability summary

Native InAppWebView JavaScript channel handlers executed YAML actions for messages from any document loaded in the WebView, without validating the sender origin.

Affected location

  • modules/ensemble/lib/widget/webview/native/webviewstate.dart
  • modules/ensemble/lib/widget/webview/webview_javascript_bridge_security.dart

Security impact

Medium — A malicious iframe or redirect inside the WebView can invoke configured javascriptChannels and trigger privileged Ensemble actions.

Attack path

  • Attacker: page/iframe inside the WebView or post-redirect content
  • Controlled input: callHandler(channel, data) payloads
  • Path: addJavaScriptHandler callback (no origin check)
  • Impact: onMessageReceived YAML actions run with attacker data

Fix

Validate controller.getUrl()?.origin against the origin derived from the configured WebView URL before executing actions. Fail closed on mismatch.

Tests

modules/ensemble/test/webview_javascript_bridge_security_test.dart

Open in Web View Automation 

… origin

Native InAppWebView JavaScript channel handlers accepted postMessage
callbacks from any document loaded in the WebView, including malicious
iframes or redirect targets. Mirror the existing web iframe origin
check by validating the current page origin against the configured
WebView URL before executing YAML actions.

Adds unit tests for origin derivation and validation helpers.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
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