Back to skill

Security audit

同花顺Level2数据接入

Security checks for vulnerabilities and agentic risk

Overview

Review recommended because the skill includes reverse-engineered market-data access that can read another app's memory, inspect local app data, and use unsafe generated code.

Install only after careful review. Do not run the memory-reading scripts as administrator, do not use packet capture or reverse engineering unless you are authorized to do so, avoid storing live Tushare tokens in the skill directory, and prefer official documented APIs or exported data. Treat generated reports as potentially simulated or incomplete rather than reliable financial advice.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (6)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
ths_memory_reader.py:75
Finding
Privileged Broad Process-Memory Scanning<![CDATA[ ## Vulnerability Details **File Location**: `ths_memory_reader.py:75-106, 145-177, 192-228`; `memory_scan_600276.py:25-97` **Vulnerability Type**: Process-memory access beyond least-privilege boundaries **Risk Level**: High ### Vulnerable Code ```python def open(self) -> bool: """Open the process.""" self.handle = kernel32.OpenProcess( PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, False, self.pid ) return self.handle is not None and self.handle != -1 ``` ```python def scan_memory(self, pattern: bytes, mask: str = None) -> List[int]: """Scan process memory for a pattern.""" results = [] address = 0 mbi = wintypes.MEMORY_BASIC_INFORMATION() mbi_size = ctypes.sizeof(mbi) while kernel32.VirtualQueryEx( self.handle, ctypes.c_void_p(address), ctypes.byref(mbi), mbi_size ) == mbi_size: if mbi.State == MEM_COMMIT and mbi.Protect in [ PAGE_READWRITE, PAGE_EXECUTE_READWRITE ]: try: data = self.read_bytes(mbi.BaseAddress, mbi.RegionSize) if data: offset = 0 while True: pos = data.find(pattern, offset) if pos == -1: break results.append(mbi.BaseAddress + pos) offset = pos + 1 except: pass address = mbi.BaseAddress + mbi.RegionSize if address >= 0x7FFFFFFF: break ``` The standalone scanner also targets a hardcoded PID: ```python PID = 21152 handle = kernel32.OpenProcess( PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, False, PID ) if not handle or handle == -1: print("Failed to open process; run with administrator privileges.") sys.exit(1) ``` ### Technical Analysis The project opens another process with `PROCESS_VM_READ` and `PROCESS_QUERY_INFORM ...[truncated 1880 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `memory_scan_600276.py` and all hardcoded PID access. 2. Avoid requiring administrator privileges for normal stock analysis. 3. Prefer documented vendor APIs, SDKs, or explicitly exported shared-memory interfaces. 4. If memory access is indispensable, require explicit user confirmation immediately before access. 5. Resolve the target PID at runtime and verify: - Exact executable name - Canonical executable path - Expected publisher signature - Expected process architecture 6. Restrict reads to known modules, exact validated offsets, and minimal fixed-size ranges. 7. Never scan all writable or executable-writable regions. 8. Do not print raw surrounding memory or include it in reports and logs. 9. Add maximum region-size limits, access auditing, and deterministic handle cleanup. 10. Fail closed if process identity or expected memory layout cannot be verified. ]]>

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
test_600276.py:44
Finding
Recursive Reconnaissance of User Configuration and Cache Data<![CDATA[ ## Vulnerability Details **File Location**: `test_600276.py:44-78, 147-187` **Vulnerability Type**: Excessive local file access and user-activity inspection **Risk Level**: Medium ### Vulnerable Code ```python config_path = THS_PATH / "bin" / "users" / "config" / "config.xml" if config_path.exists(): with open(config_path, 'r', encoding='utf-8') as f: content = f.read() if '600276' in content: print("The stock is present in the user's recent-view list.") else: print("The stock is not present in the recent-view list.") ``` ```python cache_dirs = [ THS_PATH / "bin" / "users" / "claremouse" / "Cache", THS_PATH / "bin" / "data", ] for cache_dir in cache_dirs: if cache_dir.exists(): print(f"Checking directory: {cache_dir}") for f in cache_dir.rglob("*"): if f.is_file() and f.suffix in ['.dat', '.ini', '.xml', '.json']: try: size = f.stat().st_size if size < 100000: content = f.read_text( encoding='utf-8', errors='ignore' ) if '600276' in content or '恒瑞' in content: print(f"Related data found: {f.name}") except: pass ``` Additional user configuration files are read later in the same script: ```python market_ini = THS_PATH / "bin" / "users" / "internal" / "market.ini" if market_ini.exists(): with open(market_ini, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() ``` ### Technical Analysis The diagnostic script reads recent-view information and recursively enumerates user cache directories. It opens every matching `.dat`, `.ini`, `.xml`, and `.json` file under the selected paths when the file is smaller than 100 KB. This access is broader than necessary to query a single stock or read the documented stock ...[truncated 1338 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove recursive `rglob("*")` cache enumeration. 2. Read only documented, exact files required for a declared feature. 3. Do not inspect recent-view lists unless the user explicitly requests that operation. 4. Replace directory-wide scanning with an allowlist of exact paths and expected fields. 5. Avoid hardcoded local profile names. 6. Display a clear consent prompt describing the paths and data categories before reading user-specific files. 7. Do not print raw user activity or local filenames by default. 8. Add redaction and a quiet mode for automated environments. 9. Run with ordinary user privileges and reject elevated execution when it is unnecessary. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
analyze_protocol.py:189
Finding
Python Source-Code Injection Through XML-Based Client Generation<![CDATA[ ## Vulnerability Details **File Location**: `analyze_protocol.py:94-138, 189-236` **Vulnerability Type**: Unsanitized data embedded into executable Python source **Risk Level**: High ### Vulnerable Code The XML parser accepts protocol metadata directly from a local XML file: ```python for item in root.findall('.//item'): business = item.find('business') operation = item.find('operation') message = item.find('message') analysis = item.find('analysis') if message is not None and message.text: params = self._parse_message(message.text) protocol = { 'business': business.text if business is not None else '', 'operation': operation.text if operation is not None else '', 'message': message.text, 'params': params, 'analysis': analysis.text if analysis is not None else '' } protocols.append(protocol) ``` Those values are interpolated into Python code: ```python for p in protocols: msg_id = p['params'].get('id') if msg_id and msg_id not in seen_ids: seen_ids.add(msg_id) business = p['business'].replace('/', '_').replace(' ', '_') func_name = f"get_{business.lower()}" code += f''' @staticmethod def {func_name}(code: str, **kwargs) -> str: """Get {p['business']} Operation: {p['operation']} """ params = {{'code': code, **kwargs}} return THSProtocol.build_request({msg_id}, **params) ''' ``` The resulting source replaces a Python module in the project: ```python client_code = analyzer.generate_client_code(protocols) code_file = Path(__file__).parent / "ths_protocol_generated.py" with open(code_file, 'w', encoding='utf-8') as f: f.write(client_code) ``` ### Technical Analysis The generator applies only two string replacements to `business` and performs no validation of `operation` or `msg_id`. XML-controlled values are inserted into: - A Python function ...[truncated 1408 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not generate executable Python source from XML metadata; generate JSON or another inert data format instead. 2. If source generation is unavoidable: - Require `msg_id` to match a strict numeric pattern. - Require function names to match `^[A-Za-z_][A-Za-z0-9_]*$`. - Reject all values containing quotes, line breaks, brackets, or control characters. - Encode string literals with `repr()` rather than direct interpolation. 3. Do not embed untrusted content in docstrings. 4. Parse generated output with `ast.parse()` and reject unexpected node types. 5. Write generated output to a non-importable directory and require explicit review before installation. 6. Verify the source XML file's expected path, owner, permissions, and cryptographic digest. 7. Use atomic file creation and avoid silently replacing an existing executable module. 8. Add tests containing malicious XML values to confirm that code injection is rejected. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
ths_client.py:91
Finding
Unauthenticated Plaintext TCP Connections to Hardcoded Market Servers<![CDATA[ ## Vulnerability Details **File Location**: `ths_client.py:91-98, 146-168, 202-220` **Vulnerability Type**: Missing transport encryption, endpoint authentication, and response integrity **Risk Level**: Medium ### Vulnerable Code ```python SERVERS = [ ("hevo-h.10jqka.com.cn", 9601), ("hevo.10jqka.com.cn", 8602), ("110.41.57.53", 9602), ("122.112.248.51", 9602), ("124.71.31.234", 9602), ] ``` ```python def connect(self) -> bool: """Connect to Tonghuashun servers.""" for host, port in self.SERVERS: try: print(f"Attempting connection to {host}:{port}...") self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.settimeout(10) self.socket.connect((host, port)) self.connected = True self._stop_event.clear() self._recv_thread = threading.Thread( target=self._recv_loop, daemon=True ) self._recv_thread.start() print(f"Connected to {host}:{port}") return True except Exception as e: print(f"Connection to {host}:{port} failed: {e}") if self.socket: self.socket.close() self.socket = None continue ``` ```python def _send_request( self, msg_id: int, params: Dict[str, Any], timeout: float = 5.0 ) -> Optional[bytes]: if not self.connected: raise ConnectionError("Not connected to server") request = self._build_request(msg_id, params) self.socket.send(request) try: response = self._response_queue.get(timeout=timeout) return response except queue.Empty: return None ``` ### Technical Analysis The client uses raw TCP sockets. It does not establish TLS, authenticate the remote endpoint, verify a certificate, or cryptographically validate returned market data. The fallback list includes bare IP addresses, wh ...[truncated 1234 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace the reverse-engineered raw TCP protocol with the vendor's documented authenticated API or SDK. 2. Require TLS with certificate and hostname validation. 3. Remove bare-IP fallback servers. 4. Maintain an explicit allowlist of documented vendor hostnames. 5. Fail closed if endpoint authentication cannot be established. 6. Validate message framing, maximum response sizes, schemas, numeric ranges, and expected market identifiers. 7. Associate responses with request IDs instead of accepting the next queue item indiscriminately. 8. Clearly disclose all network destinations and obtain user approval before connecting. 9. Do not use unauthenticated market responses for financial recommendations. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
ths_full_analysis.py:20
Finding
Plaintext Tushare API Token Storage in Project Configuration<![CDATA[ ## Vulnerability Details **File Location**: `ths_full_analysis.py:20-34`; `SKILL.md:52-78`; `INSTALL.md:47-64` **Vulnerability Type**: Plaintext credential storage and insecure secret-management guidance **Risk Level**: Medium ### Vulnerable Code ```python config_path = Path(__file__).parent / 'config.json' token = os.environ.get('TUSHARE_TOKEN', '') if not token and config_path.exists(): try: with open(config_path, 'r') as f: config = json.load(f) token = config.get('tushare_token', '') except: pass if token: try: ts.set_token(token) pro = ts.pro_api() print("Tushare connected") except Exception as e: print(f"Tushare connection failed: {e}") pro = None ``` The documented configuration instructs users to place the secret in a project-local JSON file: ```json { "tushare_token": "your-tushare-token-here", "ths_path": "D:\\同花顺远航版" } ``` ### Technical Analysis The project supports reading a live API token from `config.json` in the Skill directory. This file is part of the directory copied into the Agent's Skill installation and is likely to be backed up, archived, committed, or shared. The code does not check file ownership or permissions and does not distinguish a sample configuration from a secret-bearing local configuration. No intentional token exfiltration was identified in the reviewed project; the token is supplied to the third-party Tushare library for ordinary API initialization. The issue is exposure at rest and during distribution. ### Attack Path 1. A user follows the documentation and stores a live Tushare token in `config.json`. 2. The Skill directory is copied, backed up, uploaded, committed to source control, or shared for troubleshooting. 3. Another party obtains the plaintext configuration file. 4. The exposed token is reused to access the victim's Tushare API allocation until it is revoked. ### Impact Assessment An exposed t ...[truncated 248 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove support for secrets in tracked `config.json`. 2. Use the operating system's credential manager or a dedicated secret-management service. 3. If environment variables remain supported, document their process-level exposure limitations. 4. Ship only a redacted `config.example.json` without a token field. 5. Add `config.json` and local secret files to `.gitignore`. 6. Verify restrictive file permissions before accepting any file-based secret. 7. Add automated secret scanning to development and release workflows. 8. Never print token values or include them in exception messages, reports, or generated artifacts. 9. Document immediate token rotation procedures for accidental disclosure. ]]>

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding
Unpinned and Integrity-Unverified Python Dependencies<![CDATA[ ## Vulnerability Details **File Location**: `requirements.txt:1-3`; `INSTALL.md:31-37, 128`; `SKILL.md:196` **Vulnerability Type**: Uncontrolled third-party dependency resolution **Risk Level**: Medium ### Vulnerable Code ```text akshare>=1.0.0 pandas>=1.3.0 numpy>=1.21.0 ``` The installation documentation also recommends unconstrained installation: ```bash pip install akshare pandas numpy ``` ```bash pip install -r requirements.txt ``` ### Technical Analysis The dependency specifications use open-ended lower bounds and do not include upper bounds, exact versions, hashes, a lockfile, or a restricted package index. Consequently, installation can resolve to any future package version satisfying the minimum. Python packages and their transitive dependencies may execute code during build, installation, or import. A compromised future release, dependency takeover, malicious index mirror, or incompatible transitive update can therefore alter the effective code executed by the Skill after review. No confirmed malicious dependency or typosquatted package was identified in the supplied files. The vulnerability is the absence of reproducible and integrity-verified dependency management. ### Attack Path 1. An attacker compromises a permitted package or transitive dependency, or influences the package index used by the victim. 2. A malicious version is published while still satisfying the open-ended version constraint. 3. The user follows the documented `pip install` command. 4. Pip resolves and installs the malicious or compromised release. 5. Package code executes during installation, import, or later analysis with the user's privileges. ### Impact Assessment A compromised dependency can obtain the same filesystem, network, environment-variable, and process privileges as the Python interpreter. If the user follows the project's administrator recommendation for memory-related features, dependency code may execute with elevated privileges. The issue ...[truncated 93 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin every direct dependency to a reviewed exact version. 2. Generate and commit a lockfile that includes transitive dependencies. 3. Require cryptographic hashes during installation, such as with `pip --require-hashes`. 4. Install dependencies in a dedicated virtual environment rather than the global interpreter. 5. Use an explicitly configured trusted package index. 6. Review release notes and security advisories before updating pins. 7. Add automated software-composition analysis and dependency vulnerability scanning. 8. Rebuild the lockfile through a controlled review process. 9. Document supported Python versions and test the exact locked environment. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (156)

Context-Inappropriate Capability

High
Confidence
95% confidence
Finding
The README explicitly recommends reading another process's memory, using reverse-engineering tools, and capturing protocol traffic to obtain paid market data. Those instructions materially expand the skill from normal market-data consumption into bypass-oriented access methods that can enable unauthorized data extraction, EULA violations, and abuse of a local system or third-party service.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
If the provided chunk lacks any real external data access and mainly performs simulated analysis, the main harm is misrepresentation rather than active exploitation. However, in an agent skill ecosystem this still matters because misrepresentation can be used to obtain broader trust and permissions than warranted.

Static analysis

No suspicious patterns detected.