Back to skill

Security audit

Wenshu Search - 裁判文书网搜索通用技能

Security checks for vulnerabilities and agentic risk

Overview

The skill matches its court-document search purpose, but it handles login credentials and under-discloses reading session secrets and decrypting protected responses.

Review before installing. Use only with an account and data you are authorized to access, avoid full-mode bulk runs unless permitted by the service, protect exported Excel files, and run it in a private environment because the password is visible during entry and account/search settings are stored locally.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/wenshu_search.py:38
Finding

Account Identifier Stored Without Restrictive File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/wenshu_search.py, lines 38-56
Vulnerability Type: Unprotected local storage of sensitive account information
Risk Level: Medium

Vulnerable Code

python
_CONFIG_FILE = Path(__file__).parent / ".wenshu_config.json"


def _load_config():
    if _CONFIG_FILE.exists():
        try:
            return json.loads(_CONFIG_FILE.read_text(encoding="utf-8"))
        except Exception:
            return None
    return None


def _save_config(cfg: dict):
    safe_cfg = dict(cfg)
    safe_cfg["PASSWORD"] = "********"
    _CONFIG_FILE.write_text(
        json.dumps(safe_cfg, ensure_ascii=False, indent=2),
        encoding="utf-8"
    )

The configuration passed to _save_config() includes the registered account identifier under USERNAME. Although the password is replaced with a mask, the account identifier—documented as a registered mobile number—is written in plaintext to .wenshu_config.json.

Technical Analysis

Path.write_text() creates the configuration file using permissions derived from the process umask. The code does not explicitly require owner-only permissions. Under a permissive umask or shared project directory, other local users may be able to read the registered mobile number and search configuration.

Placing the file beside the script also increases the possibility of accidental disclosure through source-control commits, project archives, shared directories, or backups. The password masking is appropriate but does not protect the remaining account information.

The file is used only to remember configuration and therefore does not require access by users other than the account running the Skill. Broader access would exceed the minimum privileges necessary for the declared functionality.

Attack Path

  1. A victim runs the Skill, causing .wenshu_config.json to be created beside the script.
  2. The host has a permissi ...[truncated 906 chars]
Remediation
View remediation

Remediation Suggestions

  1. Store configuration in a user-private platform configuration directory rather than beside the script.
  2. Create the file with owner-only permissions, such as mode 0600 on POSIX systems.
  3. Write through a securely created temporary file and atomically replace the destination.
  4. Avoid retaining the mobile number unless persistent login convenience is explicitly enabled by the user.
  5. Consider storing the account identifier in an operating-system credential manager.
  6. Add .wenshu_config.json to source-control ignore rules and warn users not to include it in shared archives.
  7. Validate permissions when loading an existing configuration and reject or warn about files readable by other users.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/wenshu_search.py:133
Finding

Password Entry Is Visible in the Terminal

Content
View full analysis

Vulnerability Details

File Location: scripts/wenshu_search.py, lines 133-135 and 199-217
Vulnerability Type: Echoed plaintext password input
Risk Level: Medium

Vulnerable Code

python
PASSWORD = input("Password: ").strip()
if not PASSWORD:
    raise SystemExit("Password cannot be empty.")

The same terminal-input pattern is used during both initial configuration and subsequent quick-login runs.

Technical Analysis

Python's input() echoes entered characters to the terminal. It is unsuitable for passwords because the plaintext value can be observed by nearby users, captured by terminal-session recording, exposed during screen sharing, or retained in copied terminal output.

The password is not written to .wenshu_config.json, which limits persistence risk. It is subsequently entered into the official declared domain, https://wenshu.court.gov.cn/, through Playwright. That network transmission is necessary for authenticated search functionality, and the reviewed code contains no evidence that the password is sent to an unrelated host.

The vulnerability is therefore in local password collection rather than unauthorized network exfiltration.

Attack Path

  1. The victim starts the Skill and is prompted for the court-site password.
  2. The victim enters the password using a terminal that is visible, shared, remotely monitored, or session-recorded.
  3. Because input() echoes every character, the plaintext password appears on screen.
  4. An observer or recording operator retrieves the password.
  5. The attacker combines it with the registered mobile number to attempt authentication to the victim's court-site account.

Impact Assessment

Successful observation discloses the complete account password. If the attacker also knows or obtains the registered account identifier, the attacker may gain the same authenticated court-site access as the victim, subject to any CAPTCHA or additional ...[truncated 224 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace input() with getpass.getpass() for every password prompt:

    python
    from getpass import getpass
    
    PASSWORD = getpass("Password: ").strip()
    
  2. Ensure error messages and diagnostic logs never include the password.

  3. Keep the password only in process memory for the shortest practical duration.

  4. Do not place the password in command-line arguments or environment variables as an alternative, because those may be exposed through process inspection or logs.

  5. Consider an operating-system credential manager if optional secure password retention is desired.

  6. Document that credentials are submitted only to the official court domain and advise users to verify the domain before authentication.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (6)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill explicitly states that account information is 'automatically remembered' after first use, but it does not explain whether credentials are stored in plaintext, encrypted, or protected by OS keychain facilities. For a skill that logs into a legal-information platform, unclear credential handling creates a real risk of credential disclosure, account compromise, and unauthorized reuse on shared systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill exports full judgment text and party information into Excel, which can include personally identifiable and sensitive legal data. Because the documentation lacks a privacy warning, retention guidance, or data-minimization controls, users may collect, store, and share sensitive case data insecurely, increasing privacy and compliance risk.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The header claims the tool is 'pure UI' and does not intercept or tamper with requests, but the implementation includes logic to obtain a session secret and decrypt server API responses. Even if traffic is not actively modified, harvesting a client-side secret and decoding protected responses is a form of bypassing intended access boundaries and misleads users and reviewers about the tool's behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The script solicits account credentials and uses them for automated login to a third-party judicial service, but does not clearly disclose the full automation flow, browser submission, or associated risks. In this context, the skill targets a real remote service and handles sensitive login data, so insufficient notice increases the chance of credential misuse, policy violations, or unsafe user trust.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code explicitly extracts a secret key from window state or localStorage after login and uses it to decrypt protected server responses. Accessing hidden session material without prominent user disclosure is dangerous because it expands the script's privilege beyond visible UI automation and can enable bulk data extraction or misuse of authenticated session artifacts.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The inline comment says the password is not written to disk, but the code persists a PASSWORD key in the saved JSON with a placeholder value and also documents this as '自动记忆(密码除外)'. Although the real password is masked, the comment is still inaccurate because a password-related field is in fact written to the file.

Content

No source excerpt is available for this finding.