T09 · Insecure Skill Coding Practices
- Location
scripts/ts_data.py:10- Finding
Hardcoded API Token Transmitted to an Undocumented Plaintext Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ts_data.py:10-18
Vulnerability Type: Hardcoded credential and plaintext transmission to a custom service
Risk Level: MediumVulnerable Code
python TOKEN = '676658a3dc1be0f7b5b2c884777d325f133b1f6f6973d4caa61b6476f854' _http_url = 'http://140.143.209.128:5000' def _get_pro(): """获取初始化好的 pro 对象""" pro = ts.pro_api(TOKEN) pro._DataApi__token = TOKEN pro._DataApi__http_url = _http_url return proThe affected method is invoked by the primary data-fetching path in
scripts/diagnose.py:28-30:python df, name = get_quote_history_ts( code, start_date='20200101', end_date='20500101' )Technical Analysis
The source code contains a reusable API token and directly assigns it to a private field of the Tushare client. It also overrides the client's service URL with the bare-IP endpoint
http://140.143.209.128:5000.The use of plain HTTP provides neither transport confidentiality nor server authentication. Consequently, the token and request data may be observable by an on-path attacker, while request or response content may be modified in transit. Because the endpoint supplies historical market data used by the scoring engine, tampered responses can influence the generated stock ratings and recommendations.
The custom endpoint is not disclosed in
SKILL.md, which describes Efinance as the data-fetching provider. The implementation instead prioritizes this custom Tushare-compatible service before Baostock and Efinance.Attack Path
- A user invokes
scripts/diagnose.pywith one or more stock codes. diagnose_with_retry()attempts the Tushare adapter before the other providers._get_pro()loads the embedded token and replaces the client's endpoint with the plaintext custom service.- The client sends the credential and requested stock information toward that endpoint without TLS protec ...[truncated 1048 chars]
- A user invokes
- Remediation
View remediation
Remediation Suggestions
- Immediately revoke or rotate the exposed token.
- Remove credentials from source control and load them from an environment variable or protected secret manager.
- Remove the assignment to the private
_DataApi__http_urlfield and use the official Tushare HTTPS endpoint. - If a proxy is operationally required, use an authenticated HTTPS hostname with valid certificate verification rather than a plaintext bare-IP URL.
- Make any alternative endpoint an explicit, validated configuration option rather than silently overriding private client state.
- Document every remote provider, destination, and transmitted data field in
SKILL.md. - Restrict the replacement token to the minimum required permissions, apply usage limits where supported, and monitor it for unauthorized access.
- Add automated secret scanning and a policy check that rejects plaintext HTTP service endpoints in future changes.
