Skip to content

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

Merged
Tanker187 merged 1 commit intomainfrom
alert-autofix-20
Feb 28, 2026
Merged

Potential fix for code scanning alert no. 20: Incomplete URL substring sanitization#3
Tanker187 merged 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>
@Tanker187 Tanker187 marked this pull request as ready for review February 28, 2026 03:41
@Tanker187 Tanker187 merged commit cece102 into main Feb 28, 2026
18 of 25 checks passed
@Tanker187 Tanker187 self-assigned this Feb 28, 2026
Repository owner locked and limited conversation to collaborators Feb 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant