T09 · Insecure Skill Coding Practices
Error
- Location
- 2025.11.24-2025.11.28.txt:12
- Finding
- Hard-Coded Bearer Token in API Example<![CDATA[ ## Vulnerability Details **File Location**: `2025.11.24-2025.11.28.txt`, line 12 **Vulnerability Type**: Hard-coded API credential **Risk Level**: High ### Vulnerable Code ```bash curl -X POST http://10.73.171.38:30110/largemodel/api/v2/completions -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlfa2V5IjoiNjhmNTkwN2QxYTk0ODM3MTM1ZmY2OTI0IiwiZXhwIjoxNzYzNjYxNDM4LCJ0aW1lc3RhbXAiOjE3NjM2MDE0Mzh9.GEFQg_eux0esIH7HHfCIfFktokE4aY6MnWfrKSRB1b4" -d '{"prompt": "北京还有什么其它景点","history":[["北京的景点","圆明园和故宫"]],"appId":"691d8e2264c4ec7578636236","stream":false }' ``` ### Technical Analysis A complete JSON Web Token is embedded directly in a reusable API invocation. The decoded payload contains an `api_key` claim and an expiration timestamp, demonstrating that this was an authentication credential rather than a harmless example value. The embedded expiration indicates that this particular token is now expired. Therefore, current replay of this exact token should fail if expiration is correctly enforced. Nevertheless, committing an active credential exposes it to every person and system with access to the file or its version-control history. It also establishes an insecure documentation pattern that may lead to future valid credentials being committed. ### Attack Path 1. An attacker obtains the file or an earlier repository revision. 2. The attacker extracts the bearer token from the `Authorization` header. 3. While the token remains valid, the attacker submits requests to `/largemodel/api/v2/completions`. 4. The service accepts the attacker as the token's principal if signature, expiration, and authorization checks pass. 5. The attacker consumes model resources or accesses functionality permitted to the associated API key. The exact token shown is currently expired, so successful present-day exploitation would require deficient expiration enforcement or another unrotated credential copied through the sam ...[truncated 412 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Revoke and rotate the exposed API credential, even though the embedded token appears expired. 2. Remove the token from the current file and purge it from version-control history where operationally possible. 3. Replace credentials in examples with unmistakable placeholders such as `${LLM_API_TOKEN}`. 4. Load development credentials from an approved secret manager or protected environment variable. 5. Add automated secret scanning to local hooks and CI pipelines. 6. Configure short token lifetimes, minimum required scopes, audience restrictions, and server-side revocation. 7. Review API access logs for use of this token from unexpected clients or locations during its validity period. ]]>
