Skip to content

Potential fix for code scanning alert no. 3: Server-side request forgery#701

Merged
jamespepper81 merged 9 commits into
devfrom
alert-autofix-3
May 27, 2026
Merged

Potential fix for code scanning alert no. 3: Server-side request forgery#701
jamespepper81 merged 9 commits into
devfrom
alert-autofix-3

Conversation

@jamespepper81
Copy link
Copy Markdown
Contributor

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

Use defense in depth:

  1. At sink (fetchJson): parse the URL with new URL, enforce https: and enforce hostname allowlist (blockstream.info, mempool.space, api.coingecko.com) before issuing fetch.
  2. At source/path construction (getBlockDetails): validate hash format and normalize startIndex to a safe non-negative integer; URL-encode hash when interpolating.

Best minimal fix without changing intended functionality:

  • In src/lib/blockchain-api.ts, add URL validation at the top of fetchJson.
  • In src/lib/mempool.ts, add strict block-hash regex (^[a-fA-F0-9]{64}$), sanitize startIndex, and use encodeURIComponent(hash) in URLs.

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

jamespepper81 and others added 7 commits May 20, 2026 13:38
Bump vite dependency from 7.3.1 to 7.3.3
Manage LICENSE file uploads and deletions
Prepare repository for open-source release and configure testing
Enhance README with Community section and reorganize documentation
Add automated GitHub Release workflow for version tags
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 11:10
@jamespepper81 jamespepper81 marked this pull request as ready for review May 27, 2026 11:12
@jamespepper81
Copy link
Copy Markdown
Contributor Author

@claude can you code review the pr 701 and make any changes required

… api.alternative.me

The Copilot Autofix allowlist only included three hosts, but fetchJson() is also
called with blockchain.info (BTC ticker) and api.alternative.me (Fear & Greed
Index). Without these, address pages, wallet dashboard, and market page would
throw "Disallowed provider URL" errors. Also moved the Set to module scope to
avoid re-creating it on every call.

https://claude.ai/code/session_01SKn49yBtsK4JtGvpyfauqB
Refactor: Extract allowed hosts to module-level constant
@jamespepper81 jamespepper81 merged commit b9a6e49 into dev May 27, 2026
4 checks passed
@jamespepper81 jamespepper81 deleted the alert-autofix-3 branch May 27, 2026 11:59
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.

2 participants