Skip to content

security(ensemble): sanitize global script handler call arguments#2287

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

security(ensemble): sanitize global script handler call arguments#2287
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/application-security-review-003e

Conversation

@cursor

@cursor cursor Bot commented Jun 17, 2026

Copy link
Copy Markdown

Vulnerability summary

Untrusted input passed to ScreenController.runGlobalScriptHandler was embedded directly into generated JavaScript as functionName(<argument>). Callers that forgot to JSON-encode (as BLE previously did) could allow breakout from the argument position and execute arbitrary JavaScript.

Affected location

  • modules/ensemble/lib/screen_controller.dart
  • modules/ensemble/lib/framework/global_script_handler_security.dart

Security impact

  • Attacker: External party supplying deeplink, push notification, or BLE payload data consumed by global script handlers
  • Controlled input: Raw string interpolated into the generated JS call snippet
  • Attack path: Crafted payload like "); maliciousCode();// breaks out of the call argument and runs in the Ensemble JS interpreter context
  • Severity: Medium — arbitrary in-app script execution when handlers process external data

Fix approach

Add toSafeJavaScriptCallArgument() that passes through valid JSON literals and JSON-encodes any other value before embedding in the generated snippet.

Tests

  • modules/ensemble/test/global_script_handler_security_test.dart
Open in Web View Automation 

Coerce untrusted handler inputs into safe JavaScript call arguments before
embedding them in generated function snippets. Valid JSON from callers is
passed through; raw strings are JSON-encoded to prevent breakout from
deeplink, notification, and BLE handler paths.

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