T09 · Insecure Skill Coding Practices
- Location
SKILL.md:46- Finding
Tushare API Token Exposed Through Command-Line Expansion
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 46
Vulnerability Type: Credential exposure through process arguments
Risk Level: MediumVulnerable 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_TOKENinside a double-quoted shell argument. Before Python starts, the shell expands this variable and embeds the actual token in thepython3 -ccommand-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
- A user exports a valid
TUSHARE_TOKENand runs the documented verification command. - The shell substitutes the token into the argument passed to
python3. - A local process observer, monitoring agent, or command-logging wrapper records the expanded argument.
- An attacker with access to that data extracts the token.
- 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
View 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:
- Recommend storing the token in a dedicated secret manager or a permission-restricted environment configuration rather than a globally sourced shell profile.
- Warn users not to enable shell tracing while configuring or testing credentials.
- Avoid printing, logging, or including the token in exception messages.
- Revoke and rotate any token that may already have been exposed through process or telemetry logs.
