Skip to content

Validate the Horizon URL, encode the public key, and add a timeout in AccountLoader.fetchAccount #68

Description

@N-thnI

Description

Bring account loading up to the endpoint-safety standard the rest of the SDK enforces.

Problem Statement

src/account/loader.ts:79-98 does const url = \${horizonUrl}/accounts/${publicKey}`; const response = await fetch(url);`

This bypasses validateUrl from src/network/index.ts entirely — the module whose header documents exactly this failure (a plaintext or hostile endpoint misreporting on-chain state, vero-guardian-dashboard#288).

publicKey is interpolated unencoded, so a caller-supplied value containing ../ or ?/# redirects the request to a different Horizon resource. There is no AbortSignal, so a non-responding Horizon hangs the caller indefinitely.

The catch on lines 92-97 also flattens every failure into new Error(...), discarding status codes and defeating the SDK's own VeroError/normalizeError contract.

Proposed Changes

  • Call validateUrl(horizonUrl, opts) before building the request
  • Use new URL(\accounts/${encodeURIComponent(publicKey)}`, base)and assert the resulting origin matches, mirroringsrc/rpc/index.ts:125-131`
  • Pass an AbortController signal with a configurable timeout
  • Throw VeroError with AccountNotFound / RpcRequestFailed codes via normalizeError instead of a bare Error

Technical Implementation Scaffolding

  • Target Repository: vero-sdk
  • Target Path: src/account/loader.ts
  • Branch Naming: fix/issue--account-loader-url-safety
  • Authority Context: Security-sensitive — endpoint validation bypass

Acceptance Criteria

  • loadAccount('http://evil.example', ...) throws VeroError with code INVALID_URL
  • A publicKey of ../ledgers/1 does not produce a request outside /accounts/
  • A stubbed fetch that never resolves causes loadAccount to reject within the timeout
  • A 404 rejects with VeroErrorCode.AccountNotFound

Definition of Done

  • Reviewed by lead maintainer
  • Pull request merged via verified status check

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions