Skip to content

Potential fix for code scanning alert no. 12: Server-side request forgery#719

Merged
jamespepper81 merged 2 commits into
devfrom
alert-autofix-12
May 27, 2026
Merged

Potential fix for code scanning alert no. 12: Server-side request forgery#719
jamespepper81 merged 2 commits into
devfrom
alert-autofix-12

Conversation

@jamespepper81
Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/BitSleuthAI/Analyzer/security/code-scanning/12

Best fix: add a dedicated strict sanitizer for pathname and apply it before new URL(...).

  • General approach: Normalize and validate untrusted path input before URL construction, then validate canonicalized path after construction.
  • Specific change in src/lib/blockchain-api.ts:
    1. Add sanitizeProviderPathname(pathname: string): string near other sanitizers.
    2. In fetchJson, call this sanitizer and use its output in new URL(...).
  • Sanitizer behavior:
    • Require non-empty string.
    • Reject absolute URLs (http://, https://, any scheme), protocol-relative (//...), and backslashes.
    • Enforce leading /.
    • Reject raw and percent-encoded dot segments (., .., %2e, %2f, etc.).
    • Return sanitized pathname unchanged for existing valid callers.
  • No new imports or dependencies needed.

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

jamespepper81 and others added 2 commits May 27, 2026 19:14
Fix server-side request forgery code scanning alert
…gery

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@jamespepper81 jamespepper81 changed the base branch from main to dev May 27, 2026 18:20
@jamespepper81 jamespepper81 marked this pull request as ready for review May 27, 2026 18:23
@jamespepper81 jamespepper81 merged commit 9f08299 into dev May 27, 2026
5 checks passed
@jamespepper81 jamespepper81 deleted the alert-autofix-12 branch May 27, 2026 18:23
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