T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:46
- Finding
- Tushare API Token Exposed Through Command-Line Expansion## Vulnerability Details **File Location**: `SKILL.md`, line 46 **Vulnerability Type**: Credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```bash python3 -c "import tushare as ts; ts.set_token('$TUSHARE_TOKEN'); pro = ts.pro_api(); print(pro.stock_basic(ts_code='600519.SH'))" ``` ### Technical Analysis The verification command places `$TUSHARE_TOKEN` inside a double-quoted shell argument. Before Python starts, the shell expands this variable and embeds the actual token in the `python3 -c` command-line argument. Consequently, the credential may be visible through: - Process inspection tools while the command is running. - Process accounting or endpoint-monitoring systems. - Shell tracing, debugging, or command-execution telemetry. - Logs produced by wrappers that record complete argument vectors. This exposure is unnecessary because the main implementation already uses the safer pattern at `scripts/a_share_dcf.py:34`, where Python reads the token directly from the environment. ### Attack Path 1. A user exports a valid `TUSHARE_TOKEN` and runs the documented verification command. 2. The shell substitutes the token into the argument passed to `python3`. 3. A local process observer, monitoring agent, or command-logging wrapper records the expanded argument. 4. An attacker with access to that data extracts the token. 5. The attacker uses the token against Tushare APIs within the permissions and quota associated with the affected account. ### Impact Assessment Successful exploitation exposes the user's Tushare API credential. The attacker could consume the account's API quota, access data available under the account's Tushare permissions, and potentially cause service disruption or account-level abuse. This issue does not directly grant operating-system privilege escalation. Its scope is limited to the affected Tushare account and the capabilities assigned to the leaked ...[truncated 7 chars]
- Remediation
- ## Remediation Suggestions Read the token from the environment inside Python so that its value is not embedded in the command-line argument: ```bash python3 -c "import os, tushare as ts; ts.set_token(os.environ['TUSHARE_TOKEN']); pro = ts.pro_api(); print(pro.stock_basic(ts_code='600519.SH'))" ``` Additional hardening measures: 1. Recommend storing the token in a dedicated secret manager or a permission-restricted environment configuration rather than a globally sourced shell profile. 2. Warn users not to enable shell tracing while configuring or testing credentials. 3. Avoid printing, logging, or including the token in exception messages. 4. Revoke and rotate any token that may already have been exposed through process or telemetry logs.
