Skip to content

fix: script injection in element locators with parameterized scripts#477

Open
Dor-bl wants to merge 1 commit into
serhatbolsu:masterfrom
Dor-bl:fix-script-injection-locators-3234679202092105971
Open

fix: script injection in element locators with parameterized scripts#477
Dor-bl wants to merge 1 commit into
serhatbolsu:masterfrom
Dor-bl:fix-script-injection-locators-3234679202092105971

Conversation

@Dor-bl
Copy link
Copy Markdown
Contributor

@Dor-bl Dor-bl commented May 31, 2026

This pull request refactors the way JavaScript is executed in the element finding methods to improve security and maintainability. The main change is replacing string interpolation in JavaScript execution with the use of argument passing. This helps prevent potential injection issues and makes the code more robust.

JavaScript execution improvements:

  • Updated the _find_by_dom method to use eval(arguments[0]) with argument passing instead of directly interpolating the criteria into the JavaScript string.
  • Modified the _find_by_sizzle_selector method to use jQuery(arguments[0]).get() and pass the criteria as an argument, rather than interpolating it into the JavaScript string.
  • Updated the call to application.execute_script in _find_by_sizzle_selector to pass the criteria as an argument.

Direct string interpolation was used to construct scripts for `execute_script`.
This was replaced with parameterized scripts using `arguments[0]`.
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