Skip to content

Comments

Potential fix for code scanning alert no. 20: Incomplete URL substring sanitization#3

Draft
Tanker187 wants to merge 1 commit intomainfrom
alert-autofix-20
Draft

Potential fix for code scanning alert no. 20: Incomplete URL substring sanitization#3
Tanker187 wants to merge 1 commit intomainfrom
alert-autofix-20

Conversation

@Tanker187
Copy link
Owner

Potential fix for https://github.com/Tanker187/stagehand/security/code-scanning/20

In general, fix this by parsing the URL and validating structured components (origin/hostname) instead of checking for a substring. For this case we want to confirm that the loaded page is actually on store.steampowered.com using the browser’s own URL parsing, not string matching.

The best fix here is to replace the substring check on line 21 with a host/origin check using the standard URL constructor. For example:

  • Get the current URL string via page.url().
  • Construct a new URL(currentUrl).
  • Compare url.hostname to store.steampowered.com (or, if you ever need flexibility, compare url.origin to https://store.steampowered.com).
  • Use that boolean as the success flag instead of includes.

We can implement this directly at the existing success assignment without changing behavior elsewhere. No new imports are required because URL is a global in modern Node/TypeScript environments. The only change is in packages/evals/tasks/agent/steam_games.ts around line 21.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…g sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@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