Skip to content

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

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#717
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

General fix approach: ensure user-influenced path input is canonicalized and validated after URL parsing, not just pre-checked by regex on raw input. This prevents encoded traversal or normalization edge cases and guarantees the final fetched path matches strict allow-list expectations.

Best fix in this file: in fetchJson (around lines 55–70), parse URL first, then validate url.pathname (canonical pathname) against the host allow-list, and reject pathnames containing dot-segments (./..) as an extra guard. Keep existing functionality otherwise (same host allow-list, same query handling, same fetch behavior).

Needed changes:

  • In src/lib/blockchain-api.ts, reorder validation so it checks url.pathname rather than raw pathname.
  • Add explicit canonical path segment traversal check.
  • Keep existing origin/protocol check intact.

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

jamespepper81 and others added 2 commits May 27, 2026 18:44
Fix code scanning alert for externally-controlled format string
…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 17:57
@jamespepper81 jamespepper81 marked this pull request as ready for review May 27, 2026 18:03
@jamespepper81 jamespepper81 merged commit e261d58 into dev May 27, 2026
5 checks passed
@jamespepper81 jamespepper81 deleted the alert-autofix-12 branch May 27, 2026 18:04
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