T09 · Insecure Skill Coding Practices
Error
- Location
- clawtank.js:12
- Finding
- Bearer Token Can Be Redirected to an Arbitrary Network Endpoint## Vulnerability Details **File Location**: `clawtank.js:12-13`, with credential transmission at `clawtank.js:60-62`, `103-113`, `130-141`, `158-170`, and `220-231` **Vulnerability Type**: Unrestricted credential forwarding to a configurable endpoint **Risk Level**: High ### Vulnerable Code ```js const IDENTITY_FILE = path.resolve(process.cwd(), '.clawtank_identity'); const DEFAULT_HUB = 'https://clawtank.vercel.app'; const HUB_URL = process.env.CLAW_HUB_URL || DEFAULT_HUB; ``` Representative authenticated request: ```js const res = await fetch(`${HUB_URL}/api/swarm/signals?unresolved=true`, { headers: { 'Authorization': `Bearer ${auth.api_key}` } }); ``` The same bearer-token pattern is used for peer reviews, finding submissions, votes, and chat messages: ```js headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${auth.api_key}` } ``` ### Technical Analysis The `CLAW_HUB_URL` environment variable can replace the documented hub with any URL. The implementation does not validate the URL scheme, hostname, port, or origin before attaching the bearer token. Consequently, authenticated commands may transmit the token to an attacker-controlled server or over unencrypted HTTP. Supporting custom deployments can be legitimate, but unrestricted forwarding of an existing production credential is broader than the minimum privileges required. The documentation only identifies the default hub and does not warn users that an environment variable can redirect credentials. This is not evidence of deliberate exfiltration because the default destination is the documented HTTPS service. It is nevertheless an exploitable credential-disclosure path. ### Attack Path 1. An attacker gains influence over the execution environment, such as a shell profile, environment file, task runner, wrapper script, CI configuration, or parent process. 2. The attacker sets `CLAW_H ...[truncated 1197 chars]
- Remediation
- ## Remediation Suggestions 1. Parse the configured endpoint with `new URL()` and reject malformed values. 2. Require the `https:` scheme; permit plaintext HTTP only for an explicitly enabled local-development mode restricted to loopback addresses. 3. Use an allowlist of trusted hostnames and ports. If custom hubs are necessary, require explicit enrollment rather than trusting an ambient environment variable. 4. Store separate credentials per hub. Never send the default service's bearer token to a custom origin. 5. Disable automatic cross-origin redirects for authenticated requests, or verify every redirect target before forwarding authorization headers. 6. Document `CLAW_HUB_URL`, its security implications, and the exact destination receiving credentials. 7. Consider displaying the authenticated destination before first use and requiring confirmation when it differs from the default origin. 8. Apply short token lifetimes, narrowly scoped API permissions, rotation support, and server-side revocation.
