Skip to content

Fix: Incomplete Data Cleaning Could Allow Malicious Content Through in lib/handlers/handlerUtils/actHandlerUtils.ts #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kira-offgrid
Copy link

Context and Purpose:

This PR automatically remediates a security vulnerability:

  • Description: val.trim().replace method will only replace the first occurrence when used with a string argument ("%"). If this method is used for escaping of dangerous data then there is a possibility for a bypass. Try to use sanitization library instead or use a Regex with a global flag.
  • Rule ID: javascript.lang.security.audit.incomplete-sanitization.incomplete-sanitization
  • Severity: LOW
  • File: lib/handlers/handlerUtils/actHandlerUtils.ts
  • Lines Affected: 242 - 242

This change is necessary to protect the application from potential security risks associated with this vulnerability.

Solution Implemented:

The automated remediation process has applied the necessary changes to the affected code in lib/handlers/handlerUtils/actHandlerUtils.ts to resolve the identified issue.

Please review the changes to ensure they are correct and integrate as expected.

…e-sanitization-lib-handlers-handlerUtils-actHandlerUtils.ts
Copy link

changeset-bot bot commented Jul 14, 2025

⚠️ No Changeset found

Latest commit: f663bdb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR fixes a security vulnerability in the parsePercent function within actHandlerUtils.ts. The change addresses incomplete string sanitization where the original code only replaced the first occurrence of the '%' character using replace('%', ''). The fix implements a global regex replacement using replace(/%/g, '') to ensure all '%' characters are properly removed from the input string.

This function is used in the scroll functionality of Stagehand, specifically in the scrollElementToPercentage handler, which allows scrolling elements or the page to a specific percentage. While the impact of this vulnerability was limited (since the parsed value is always clamped between 0 and 100), proper input sanitization is crucial for maintaining secure coding practices.

Confidence score: 5/5

  1. This PR is completely safe to merge and improves code security
  2. The change is minimal, focused, and uses a well-established pattern for global string replacement
  3. No specific files need additional attention - the change is self-contained and straightforward

1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile

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