T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/jwt_token.py:32
- Finding
- Hardcoded Reusable API Credentials<![CDATA[ ## Vulnerability Details **File Location**: `scripts/jwt_token.py`, lines 32–36 **Vulnerability Type**: Hardcoded credentials **Risk Level**: High ### Vulnerable Code ```python API_BASE_URL = "http://192.168.60.241:1120" # Server base address LOGIN_PATH = "/api/GenUser/TokenLogin" # Login endpoint USERNAME = "kang" # Login account PASSWORD = "kang123456" # Login password LOGIN_MESSAGE = "测试,手机端e12a5481c32d23b024226d5e2d7a47aac0870cfc5252b055282b668004a0ebbd,Rule" ``` ### Technical Analysis A reusable username and password are embedded directly in the distributed source code. Any person or process with read access to the Skill package can recover these credentials without executing the Skill. The credentials are used by `fetch_token()` to authenticate to the fixed `/api/GenUser/TokenLogin` endpoint. Source-level secrets cannot be effectively restricted to authorized operators, and rotating them requires modifying and redistributing the package. The hardcoded `LOGIN_MESSAGE` also appears to contain a persistent client or device identifier. Although it is not proven to be an authentication secret, embedding it may facilitate impersonation of the expected client. ### Attack Path 1. An attacker obtains read access to the Skill package, source archive, deployment image, backup, or source repository. 2. The attacker opens `scripts/jwt_token.py` and extracts `USERNAME`, `PASSWORD`, and the client-identifying message. 3. The attacker establishes network access to `192.168.60.241:1120`, such as from the same internal network or through a compromised internal host. 4. The attacker submits the extracted values to `/api/GenUser/TokenLogin`. 5. If the credentials remain valid, the attacker receives a JWT and uses it against API operations available to that account. ### Impact Assessment Successful exploitation grants the API privileges assigned to the `kang` account. The exact server-side ...[truncated 354 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Immediately rotate the exposed password and invalidate JWTs issued from it where supported. 2. Remove usernames, passwords, and reusable client identifiers from source code and version-control history. 3. Retrieve credentials from an approved secret manager, protected OS credential store, or explicitly supplied runtime secret. 4. Use a dedicated service identity with only the permissions required to request a narrowly scoped product-submission token. 5. Prefer short-lived workload identity, mutual TLS, or another non-password machine-authentication mechanism. 6. Prevent secrets from appearing in command-line arguments, logs, exception messages, or ordinary output files. 7. Add secret scanning to source-control and release pipelines. ]]>
