Skip to content

fix: escape user values in fill/type/select to prevent JS injection#141

Open
hobostay wants to merge 1 commit intojustrach:mainfrom
hobostay:fix/js-injection-cmdaction
Open

fix: escape user values in fill/type/select to prevent JS injection#141
hobostay wants to merge 1 commit intojustrach:mainfrom
hobostay:fix/js-injection-cmdaction

Conversation

@hobostay
Copy link
Copy Markdown

Summary

  • Fix JS injection vulnerability in cmdAction where user-supplied values for fill, type, and select commands are injected directly into JavaScript single-quoted strings without escaping
  • Add escapeForJsString() helper that escapes ', \, \n, \r, \t for safe embedding in JS string literals

Vulnerability details

Before this fix, running something like:

kuri-agent fill e1 "test'); alert('xss"

Would generate JavaScript:

function() { this.focus(); this.value = 'test'); alert('xss'; ... }

This breaks out of the string literal and allows arbitrary JavaScript execution through CDP.

Test plan

  • Verify kuri-agent fill <ref> "it's a test" correctly handles values with single quotes
  • Verify kuri-agent fill <ref> "back\\slash" correctly handles backslashes
  • Verify kuri-agent select <ref> "option'1" no longer breaks the JS function
  • Run zig build

🤖 Generated with Claude Code

The fill, type, and select actions in cmdAction injected user-supplied
values directly into JavaScript single-quoted strings without escaping.
A value containing a single quote (e.g. "test');alert('xss") would break
out of the string literal and allow arbitrary JS execution via CDP.

Add escapeForJsString() helper that escapes single quotes, backslashes,
and newlines for safe embedding in JS string literals, and apply it to
the value parameter before interpolation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.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