T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/lib/providers.mjs:290
- Finding
- Ark API Credential Exfiltration Through an Unrestricted Custom Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `scripts/lib/providers.mjs:290-301` **Vulnerability Type**: Arbitrary credential-bearing network destination **Risk Level**: High ### Vulnerable Code ```js describe(req) { return `POST ${env.ARK_BASE_URL || 'https://ark.cn-beijing.volces.com/api/v3'}/images/generations model=${ark.model() || '<需设 ARK_MODEL>'}` }, async run(req) { if (!ark.model()) throw new Error('火山方舟需指定模型:export ARK_MODEL=<你开通的 seedream 模型 ID>') const base = env.ARK_BASE_URL || 'https://ark.cn-beijing.volces.com/api/v3' const body = { model: ark.model(), prompt: req.prompt, size: req.size || '2K', response_format: 'url', watermark: false, } if (req.images?.length) body.image = await Promise.all(req.images.map(asDataUri)) const j = await postJson(`${base}/images/generations`, body, { authorization: `Bearer ${env.ARK_API_KEY}` }, req.timeoutMs) ``` ### Technical Analysis The Ark provider permits `ARK_BASE_URL` to override the official service endpoint without validating the URL scheme, hostname, port, resolved IP address, or redirect behavior. The code then unconditionally attaches `ARK_API_KEY` as a bearer credential to the selected endpoint. As a result, any party capable of influencing the process environment can redirect an otherwise legitimate Ark request to an attacker-controlled server. The request may contain: - The Ark API key in the `Authorization` header. - The user's generation prompt. - Base64-encoded local reference images. - Remote image URLs supplied as references. - Generation parameters and model identifiers. Supporting a completely arbitrary credential-bearing endpoint is not required for the Skill's declared image-generation functionality. It exceeds the minimum network privileges needed to communicate with the official Ark service. ### Attack Path 1. The attacker gains influence over the environment used to invoke the Skill, such as through a wrapper script, CI configuration, inherite ...[truncated 1225 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `ARK_BASE_URL` configurability unless it is operationally necessary. 2. If custom endpoints are required, parse the endpoint with `new URL()` and enforce: - HTTPS only. - An explicit hostname allowlist. - Approved ports only. - No embedded username or password. - No loopback, private, link-local, multicast, or cloud metadata destinations. 3. Revalidate every redirect destination or disable automatic redirects. 4. Attach `ARK_API_KEY` only when the final destination exactly matches an approved Ark hostname. 5. Require explicit user confirmation before sending credentials to a non-default endpoint. 6. Document the endpoint override and associated data flow. 7. Avoid including credentials or request contents in error messages and logs. ]]>
