T09 · Insecure Skill Coding Practices
Error
- Location
- langchain_skill.py:26
- Finding
- Hard-Coded DeepSeek API Credential in Source Code<![CDATA[ ## Vulnerability Details **File Location**: `langchain_skill.py`, lines 26–33 **Vulnerability Type**: Hard-coded secret **Risk Level**: High ### Vulnerable Code ```python if "deepseek" in selected_model: llm = OpenAI( openai_api_base="https://api.deepseek.com/v1", openai_api_key="sk-e7ec5...39506694", # key DeepSeek của Sếp model_name="deepseek-chat", temperature=0.7, max_tokens=1500 ) ``` ### Technical Analysis An API-key-like value is embedded directly in the source code. Secrets committed to a project can be recovered by anyone who can read the package, repository, build artifacts, backups, or source history. The displayed value contains an ellipsis and may be truncated or inactive. Therefore, the audit cannot establish that it is currently usable. Nevertheless, placing credential material directly in source code is an insecure credential-management practice and may reveal portions of a real credential. ### Attack Path 1. An attacker obtains a copy of the skill package, repository, build artifact, or source history. 2. The attacker reads `langchain_skill.py` and extracts the embedded credential value. 3. If the value or an earlier version of it is valid, the attacker submits authenticated requests to the configured DeepSeek endpoint. 4. The requests consume the credential owner's quota and may incur charges until the credential is revoked or restricted. ### Impact Assessment If the embedded value corresponds to a valid credential, an attacker could obtain the API privileges assigned to that key. The likely scope is unauthorized DeepSeek API use, quota exhaustion, billing abuse, and possible access to provider-side resources available to the key. This finding does not establish local system compromise or privilege escalation. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the credential from the source code and repository history. - Revoke and rotate any real credential associated with the exposed value. - Read the key from a protected environment variable or secret manager, for example `DEEPSEEK_API_KEY`. - Refuse to initialize the DeepSeek client when the secret is absent rather than falling back to an embedded value. - Apply provider-side restrictions, spending limits, monitoring, and alerting. - Add secret scanning to pre-commit hooks and continuous integration. - Ensure logs and exception messages never disclose secret values. ]]>
