T09 · Insecure Skill Coding Practices
- Location
stock_utils.py:26- Finding
Tushare API Token Transmitted over Plaintext HTTP
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly matches its stock-screening purpose, but it handles a user API token insecurely and has misleading financial-strategy logic that users should review before installing.
Install only if you are comfortable reviewing and fixing the HTTP API endpoint first, treating all output as research rather than investment advice, and controlling where result files are saved. Rotate any Tushare token previously used with this version over HTTP.
stock_utils.py:26Tushare API Token Transmitted over Plaintext HTTP
utils/report.py:77Stored HTML Injection in Generated Stock Reports
requirements.txt:1Unbounded Dependency Versions Reduce Supply-Chain Integrity
The skill explicitly says requests for specific stock codes/names and pure data queries should be excluded, yet the documented behavior and return schema show direct per-stock handling and local JSON persistence. In an agent pipeline, this kind of description-behavior mismatch can bypass routing expectations, causing the skill to process data types it was supposed to refuse and to write outputs locally without clear consent.
The skill explicitly says requests for specific stock codes/names and pure data queries should be excluded, yet the documented behavior and return schema show direct per-stock handling and local JSON persistence. In an agent pipeline, this kind of description-behavior mismatch can bypass routing expectations, causing the skill to process data types it was supposed to refuse and to write outputs locally without clear consent.
The skill explicitly says requests for specific stock codes/names and pure data queries should be excluded, yet the documented behavior and return schema show direct per-stock handling and local JSON persistence. In an agent pipeline, this kind of description-behavior mismatch can bypass routing expectations, causing the skill to process data types it was supposed to refuse and to write outputs locally without clear consent.
The skill explicitly says requests for specific stock codes/names and pure data queries should be excluded, yet the documented behavior and return schema show direct per-stock handling and local JSON persistence. In an agent pipeline, this kind of description-behavior mismatch can bypass routing expectations, causing the skill to process data types it was supposed to refuse and to write outputs locally without clear consent.
The module sends the Tushare token and all request parameters to http://api.tushare.pro over plaintext HTTP, exposing credentials and financial query data to interception or tampering by any network adversary on the path. In an agent-integrated environment, this can lead to credential theft, manipulated API responses, and downstream integrity issues in stock-screening results.
The strategy is labeled and marketed as detecting shareholder/executive share increases, but the implementation primarily queries the repurchase API, which represents company buybacks rather than insider or major-holder增持. In a stock-selection skill, this semantic mismatch can directly mislead downstream investment decisions, causing users to act on materially incorrect signals while believing they are screening a different corporate action.
The comments explicitly acknowledge that the chosen interface does not provide shareholder/executive增持 data, yet the function still processes and returns results as if it were an增持 strategy. This contradiction indicates known misrepresentation in the logic path, which is especially risky in a financial screening context because users and other components will trust the output labels and rankings as accurate.
The skill manifest presents a broader strategy set and trigger surface than the code documentation in this file. README.md describes an A-share stock selector with 11 independent strategies, and its strategy table omits several manifest-claimed capabilities such as 北向资金、股东增持、分析师目标价 and others, indicating a mismatch between claimed behavior and documented implementation scope.
The skill documents capabilities that imply environment access, local file read/write, and network use, but it does not declare any tool scope or permissions boundaries. In an agent setting, missing explicit scope increases the risk of over-broad tool access, unintended data exfiltration, or filesystem writes beyond user expectations.
The manifest says requests involving specific stock codes/names are excluded, but examples and return data clearly operate on named stocks and stock identifiers. In agent orchestration, such contradictory contract language can break policy-based routing and cause the skill to handle inputs it should refuse, potentially exposing or persisting unintended data.
The skill states that screening results and HTML reports are automatically saved to local disk, including to a fixed external-drive path, without a clear warning or consent flow. Automatic file creation can expose sensitive financial research, surprise users, leak data onto shared or removable storage, and create persistence where none was expected.
Natural-language strings throughout the file, including the module description, CLI help text, status messages, and result summary, are presented only in Chinese. The policy for this audit flags locale/language constraints when a skill forces a specific language without user opt-in or documented justification.
Natural-language strings in the module docstring and user-facing messages are exclusively Chinese, which effectively forces a specific language without user opt-in. The file does not indicate that this is an intentionally region-specific skill or provide any language selection.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
for attempt in range(retries + 1):
try:
response = requests.post(
TUSHARE_API_URL,
json=payload,
headers=headers,
The utility module exposes arbitrary local file write via save_json_data(data, filename), allowing callers to write attacker-influenced content to any path the process can access. In an agent skill context, generic file-write capability is broader than the advertised stock-screening purpose and could be abused for overwriting local data, planting files, or persisting untrusted outputs.
The _calc_target docstring describes the strategy as '目标价 = 当年预测EPS × 历史行业PE中位数', which implies use of an industry-based valuation benchmark. However, the implementation never fetches or computes any industry PE median; it either multiplies EPS by the forecast PE from the data or derives a target by applying a 20% premium to the stock's implied current PE. This is an active contradiction between documentation and behavior, not merely an omitted detail.
The function claims to measure consecutive dividend years, but it only counts distinct years present in financial records. In a stock-selection skill, this can materially misclassify equities as having stable dividend histories when no dividend evidence was checked, leading to misleading outputs and potentially harmful financial decisions.
The payout-ratio function documents a financial estimate but returns an almost constant value derived from dv_ratio divided by itself, which is effectively ~100% for nearly all inputs. This undermines scoring integrity and can systematically distort recommendations in a finance-related skill, making the output unreliable in a way users may not notice.
The module docstring is entirely in Chinese, and the rest of the inline comments and returned labels are also Chinese-only. For a general-purpose skill file, this imposes a specific language/locale without any visible opt-in, fallback, or documented region-specific constraint.
The manifest presents this as a 北向资金选股 strategy focused on northbound capital flow signals, but the implementation also fetches financial indicator data and incorporates ROE into the final score. That introduces a cross-strategy fundamental factor not justified by the stated strategy description, changing behavior from pure capital-flow screening to mixed factor scoring.
The module docstring uses Chinese-only natural-language descriptions, and additional Chinese-only comments and docstrings appear later in the file. Under the policy rule, forcing a specific language without user opt-in or justification is a natural-language policy violation.
The file's natural-language docstrings and user-facing ImportError message are entirely in Chinese, which imposes a specific language on users and maintainers without offering any opt-in or alternative. Under the stated policy, forcing a specific language without user choice is a locale/language policy violation unless clearly justified as region-specific.
The loader modifies sys.path using directories discovered by walking parent paths, then imports modules by name. This can cause Python to load attacker-controlled stock_utils.py or stock_indicators.py from an unintended location in the workspace tree, resulting in arbitrary code execution at import time if a malicious file is present.
sys.path.insert(0, ws_root)
try:
__import__("stock_utils")
__import__("stock_indicators")
return ws_root or skill_dir or ""
except ImportError:
This import has the same risk pattern as the previous one: once sys.path is prepended with a discovered parent directory, importing stock_indicators by name may execute code from an attacker-planted module outside the intended skill directory. Because Python executes top-level module code during import, exploitation can occur immediately without further checks.
try:
__import__("stock_utils")
__import__("stock_indicators")
return ws_root or skill_dir or ""
except ImportError:
raise ImportError(
Natural-language policy checks apply to all file types. The document presents all user-facing instructions in Chinese and does not indicate that the skill is region-specific by design or provide an opt-in language/locale choice.