T09 · Insecure Skill Coding Practices
- Location
lib/torchsdk/tokens.js:272- Finding
Unrestricted On-Chain Metadata Fetch Enables Server-Side Request Forgery
- Content
View full analysis
{ const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), timeoutMs); const opts = { ...options, signal: controller.signal }; try { // If it's an Irys gateway URL, use uploader directly (gateway has SSL issues) if ((0, exports.isIrysUrl)(url)) { const uploaderUrl = (0, exports.irysToUploader)(url); return await fetch(uploaderUrl, opts); } // For non-Irys URLs, fetch normally return await fetch(url, opts); ``` ### Technical Analysis The `getToken()` implementation retrieves the metadata URI from on-chain bonding-curve state and passes it directly to `fetchWithFallback()`. The latter accepts arbitrary non-Irys URLs and calls `fetch()` without validating: - The URL scheme - The destination hostname - Resolved IP addresses - Loopback, private, link-local, or cloud metadata address ranges - Redirect destinations - Response content type - Maximum response size The bot invokes `getToken()` from `snapshotMarket()` for each active market. Consequently, metadata retrieval is part of normal continuous operation rather than an explicitly authorized metadata-fetching action. The local allowlist applied to pending market definitions does not fully mitigate this issue. Already-active market entries are not revalidated, and an allowl ...[truncated 1743 chars]- Remediation
View remediation
