Back to skill

Security audit

AKShare

Security checks for vulnerabilities and agentic risk

Overview

The skill is aimed at public financial data, but its helper can run arbitrary Python code on the user's machine.

Install only if you trust the skill author and will ensure expressions passed to the helper are written by a trusted user, not copied from untrusted prompts or market-data text. A safer version would replace --expr/eval with an allowlisted AKShare function dispatcher and pinned dependency versions.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/akshare_eval.py:12
Finding
Unrestricted Python Expression Evaluation Enables Arbitrary Code Execution<![CDATA[ ## Vulnerability Details **File Location**: `scripts/akshare_eval.py`, lines 12–18 **Vulnerability Type**: Arbitrary Python code execution through unsafe `eval()` **Risk Level**: High ### Vulnerable Code ```python parser.add_argument('--expr', required=True, help='Python expression using ak, pd, or json.') parser.add_argument('--max-rows', type=int, default=20, help='Max rows to print for tabular outputs.') parser.add_argument('--format', choices=['csv', 'json', 'text'], default='csv') args = parser.parse_args() env = {'ak': ak, 'pd': pd, 'json': json} try: result = eval(args.expr, {'__builtins__': __builtins__}, env) ``` ### Technical Analysis The helper passes the entire user-supplied `--expr` value directly to Python's `eval()`. Although the documentation presents this argument as an expression using only `ak`, `pd`, or `json`, no such restriction is enforced. The global namespace explicitly exposes the complete `__builtins__` object. Consequently, an expression can access import functionality and other powerful built-ins rather than being limited to AKShare queries. It can load operating-system, subprocess, networking, and filesystem modules; inspect environment variables; read or modify files; initiate outbound connections; or execute local programs. This behavior materially exceeds the minimum privileges required to retrieve public financial data. Merely placing selected modules in the local environment does not create a security boundary when unrestricted built-ins and arbitrary attribute access remain available. ### Attack Path 1. An attacker supplies a financial-data request containing content designed to be incorporated into the `--expr` argument. 2. The agent or another caller invokes `scripts/akshare_eval.py` with that attacker-influenced expression. 3. The script passes the expression to `eval()` without syntax validation, method allowlisting, or isolation. 4. The expression uses exposed Python built-ins to import system-capa ...[truncated 1323 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Remove `eval()` and replace the expression interface with a constrained invocation format: 1. Accept an explicitly validated AKShare function name and JSON-encoded arguments. 2. Maintain an allowlist of supported AKShare methods appropriate for public market-data retrieval. 3. Resolve only direct attributes on the `akshare` module after validating the function name against the allowlist. 4. Validate argument names, types, lengths, symbols, and date ranges before invocation. 5. Reject private or dunder attributes and nested attribute traversal. 6. Do not expose Python built-ins, imports, arbitrary pandas operations, lambdas, comprehensions, or caller-supplied executable syntax. 7. Apply execution timeouts and response-size limits to constrain expensive data requests. 8. Run the query process in a sandbox with minimal filesystem access, a restricted environment, no unnecessary credentials, and network access limited to required financial-data endpoints. 9. Add tests confirming that imports, filesystem access, process creation, arbitrary attribute access, and network primitives cannot be reached through query input. If compatibility temporarily requires expression parsing, parse input with `ast.parse()` and permit only a narrowly defined grammar consisting of calls to allowlisted AKShare functions with literal arguments. AST filtering is still less robust than replacing the expression interface entirely. ]]>

T08 · Insecure Dependencies

Warning
Location
scripts/bootstrap_akshare_env.sh:9
Finding
Unpinned Online Dependency Installation Creates Supply-Chain Risk<![CDATA[ ## Vulnerability Details **File Location**: `scripts/bootstrap_akshare_env.sh`, lines 9–10 **Vulnerability Type**: Unpinned and integrity-unverified dependency installation **Risk Level**: Medium ### Vulnerable Code ```bash "$VENV/bin/python" -m pip install --upgrade pip setuptools wheel "$VENV/bin/pip" install --upgrade akshare ``` ### Technical Analysis The bootstrap script installs the latest available releases of `pip`, `setuptools`, `wheel`, AKShare, and AKShare's transitive dependencies whenever it runs. No exact versions, lock file, artifact hashes, or reviewed package repository are specified. Python packages and installation metadata can execute code during installation, and installed packages execute code when imported. Because dependency resolution occurs against the live package index, the effective code installed by this Skill can change after the Skill itself has been audited. A compromised upstream release, package-index account, distribution artifact, or transitive dependency could therefore introduce malicious code. The package name `akshare` is consistent with the Skill's declared functionality, and the reviewed script does not use an obviously misspelled package or an untrusted custom index. The issue is the absence of reproducibility and integrity controls rather than evidence that the current package is malicious. ### Attack Path 1. An attacker compromises an upstream package release, maintainer account, package-index distribution channel, or transitive dependency. 2. A user runs `scripts/bootstrap_akshare_env.sh`. 3. The unrestricted `--upgrade` operations resolve the current package versions from the live index. 4. The compromised artifact is downloaded and installed without comparison against reviewed versions or cryptographic hashes. 5. Malicious package code executes during installation or later when `akshare` or a related dependency is imported. 6. The code gains the permissions of the user running the bootstrap or q ...[truncated 755 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin exact reviewed versions of AKShare and all direct and transitive dependencies. 2. Generate a lock file containing cryptographic hashes for every permitted distribution artifact. 3. Install with hash enforcement, such as `pip install --require-hashes -r requirements.lock`. 4. Remove unconditional `--upgrade` behavior from routine bootstrap operations. 5. Pin the packaging tools as well, or provision them from a controlled and reviewed environment. 6. Use a trusted, controlled package mirror where practical. 7. Add automated vulnerability, provenance, and malware scanning to the dependency update process. 8. Review dependency changes before regenerating the lock file and document a controlled update cadence. 9. Prefer binary wheels from verified sources and prevent unexpected source builds where operationally feasible. 10. Run installation with the least-privileged account and without unrelated secrets in the environment. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (5)

eval() call detected

High
Category
Dangerous Code Execution
Content
env = {'ak': ak, 'pd': pd, 'json': json}
    try:
        result = eval(args.expr, {'__builtins__': __builtins__}, env)
    except Exception as e:
        print(f'EVAL_ERROR: {e}', file=sys.stderr)
        raise
Confidence
99% confidence
Finding
The script evaluates a user-supplied Python expression with eval() and explicitly exposes full __builtins__, which enables arbitrary code execution rather than limited AKShare data access. An attacker can invoke builtins such as __import__ to access os/subprocess, read files, run commands, or exfiltrate secrets, making this far more dangerous than the skill’s stated market-data purpose.

Context-Inappropriate Capability

High
Confidence
97% confidence
Finding
The skill claims to retrieve market and macro-finance data, but instead accepts arbitrary Python expressions, greatly expanding capability beyond the advertised trust boundary. This mismatch increases the chance that higher-level agents or users pass untrusted input into a general-purpose code execution surface, enabling misuse unrelated to AKShare.

Missing User Warnings

High
Confidence
93% confidence
Finding
The script performs arbitrary expression evaluation and network-capable library calls without any confirmation, sandboxing, or user-visible warning, so a single crafted request can trigger dangerous behavior immediately. In an agent skill context, this is more dangerous because tool invocations may be composed automatically from user input, amplifying the risk of prompt-to-code execution.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
Line L66 instructs the skill to "translate raw columns into plain Chinese when answering in Chinese," while the skill description and scope are centered on Chinese-market data without offering any explicit user language choice. This creates a locale/language policy concern because it biases output toward a specific language rather than making language selection explicit or opt-in.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
The headings and notes in this markdown file are written entirely in Chinese, including usage guidance and warnings, with no indication that users may choose another language. The policy explicitly flags language or locale constraints when a skill forces a specific language without user opt-in.

Static analysis

Detected: suspicious.dynamic_code_execution

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
scripts/akshare_eval.py:19