T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:31
- Finding
- Hard-Coded Shared Scholar API Bearer Credential<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 31–42; repeated at line 59 **Vulnerability Type**: Hard-coded credential and insecure secret handling **Risk Level**: Medium ### Vulnerable Code ```markdown Authentication uses a Bearer token. Resolve the key in this order: 1. Environment variable `SCHOLAR_API_KEY` 2. Built-in free key: `psk_tLzPCmJdUw5oAHGeXL2H_fMrDdSyiF_SBJfn2p5uCO4` Users can get their own higher-quota key at: https://scholar.x49.ai/docs?section=api-keys **Always construct API calls like this:** ```bash SCHOLAR_KEY="${SCHOLAR_API_KEY:-psk_tLzPCmJdUw5oAHGeXL2H_fMrDdSyiF_SBJfn2p5uCO4}" BASE="https://scholar.x49.ai/api/v1" ``` ``` The same credential is repeated in the paper-search example: ```bash SCHOLAR_KEY="${SCHOLAR_API_KEY:-psk_tLzPCmJdUw5oAHGeXL2H_fMrDdSyiF_SBJfn2p5uCO4}" curl -s "https://scholar.x49.ai/api/v1/papers/search" \ -H "Authorization: Bearer ${SCHOLAR_KEY}" \ ``` ### Technical Analysis A reusable bearer credential is embedded directly in the publicly readable Skill definition. The shell parameter expansion automatically selects this credential whenever `SCHOLAR_API_KEY` is unset. Consequently, merely obtaining the Skill package reveals everything required to authenticate as the shared API identity. Bearer tokens provide access based on possession. There is no additional proof binding the token to a particular installation or user. Although the document identifies this as a built-in free key, publishing and automatically using a shared credential prevents reliable attribution, rotation per installation, and effective per-user revocation. ### Attack Path 1. An attacker obtains or reads `SKILL.md`. 2. The attacker copies the plaintext token from line 34, 41, or 59. 3. The attacker submits requests directly to `https://scholar.x49.ai/api/v1` with: ```http Authorization: Bearer psk_tLzPCmJdUw5oAHGeXL2H_fMrDdSyiF_SBJfn2p5uCO4 ``` 4. Requests are processed under the shared API identity wit ...[truncated 1068 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the embedded bearer token from `SKILL.md` and all command examples. 2. Revoke or rotate the exposed token, because removing it from a later revision does not invalidate copies already obtained. 3. Require an explicitly configured environment variable and fail safely when it is missing: ```bash : "${SCHOLAR_API_KEY:?SCHOLAR_API_KEY must be configured}" SCHOLAR_KEY="$SCHOLAR_API_KEY" BASE="https://scholar.x49.ai/api/v1" ``` 4. Store credentials in a protected environment variable, operating-system credential store, or secret-management service rather than source-controlled documentation. 5. Issue separate, least-privilege credentials per user or installation. Apply narrow endpoint permissions, rate limits, quota limits, expiration, and revocation support. 6. Keep examples credential-free by using placeholders such as `${SCHOLAR_API_KEY}`. 7. Add automated secret scanning to the publication workflow to detect bearer tokens and similar credentials before release. 8. Monitor the exposed credential's historical usage for quota abuse or anomalous requests. ]]>
