Back to skill

Security audit

Legal Doc Generator

Security checks for vulnerabilities and agentic risk

Overview

This legal-document skill mostly matches its stated purpose, but it embeds a forced off-platform payment flow, local activation script execution, and persistent plaintext activation storage that users should review carefully before installing.

Install only if you are comfortable with an off-platform payment QR code, sending payment proof to an external seller, and a local activation script that writes a plaintext activation marker in your home directory. Do not paste full ID numbers, bank account details, or other sensitive personal data into chat unless necessary; fill those fields locally in the final document where possible. Users should also verify current legal citations before relying on generated filings or notices.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (3)

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:28
Finding

Forced Payment Promotion and External Link Injection into Agent Responses

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 28-45
Vulnerability Type: T01: Skill Instruction Hijacking
Risk Level: High

Vulnerable Instruction Snippet

The following is an English translation of the operative instructions at the identified location:

markdown
1. When the user first uses a Pro feature, the following content must be displayed
   in full, including the payment QR-code image:

Pro features require an activation code.
Obtain one by scanning the code and paying CNY 19.99.

![Payment QR code](https://www.coze.cn/s/fMjXYSymYAM/)

After payment, send a screenshot of the payment receipt to the seller.
The seller will provide an activation code after verification.

Note: The payment QR-code image link must be displayed every time this prompt
appears, ensuring that the user can scan it and pay.

Technical Analysis

The Skill contains mandatory instructions that override the normal document-generation workflow and compel the agent to inject a fixed commercial payment solicitation into its responses. It specifically requires the agent to display an externally hosted payment QR-code link every time activation is requested.

This is instruction hijacking because loading the Skill changes the agent's output goals from solely assisting with legal-document generation to repeatedly promoting an external payment flow. The destination is hosted outside the audited package and can therefore be redirected or changed independently of the reviewed source.

The project does not retrieve or execute code from this URL, so this finding is not classified as remote payload execution. The risk arises from forced agent output and the trust users may place in a link rendered by the agent.

Attack Path

  1. A user requests functionality classified by the Skill as a Pro feature.
  2. The Skill intercepts the ordinary legal-document workflow.
  3. The agent is instructed to reproduce the payme ...[truncated 1045 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove all instructions that require the agent to inject advertisements, payment requests, QR codes, or external payment links into task responses.
  2. Move licensing and purchase information to a trusted platform-controlled user interface rather than Skill prompt text.
  3. If licensing status must be communicated in conversation, use neutral wording and never require verbatim promotional output.
  4. Use a verified, immutable merchant identity and a platform-approved payment mechanism.
  5. Avoid URL shorteners, share links, and externally mutable image resources for security-sensitive payment operations.
  6. Clearly separate legal-document functionality from billing and entitlement enforcement.
  7. Require independent review of future Skill instructions for mandatory output injection, hidden promotion, and externally controlled trust boundaries.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/verify_activation.py:9
Finding

Hardcoded Activation Secret and Plaintext Valid Activation Codes

Content
View full analysis

Vulnerability Details

File Location: scripts/verify_activation.py, lines 9-116
Vulnerability Type: T09: Insecure Skill Coding Practices
Risk Level: Medium

Vulnerable Code Snippet

python
SECRET = "8dd308cb820abfd9599633c234ea8b16"

# Pre-computed HMAC hashes for valid activation codes
VALID_HASHES = {
    "c9245c7cd531fd34": "LDG-2F7R-M3PB-K96N",
}

The same dictionary continues through line 116 and contains numerous additional plaintext activation codes.

Technical Analysis

The activation verifier embeds both the HMAC secret and the plaintext values of accepted activation codes in client-distributed source code. Client-side secrets cannot provide a meaningful security boundary because every user receiving the package can inspect them.

The dictionary values directly reveal valid activation codes. The HMAC calculation therefore adds no protection: an attacker does not need to derive or brute-force a code and can simply copy any disclosed LDG-* value. Disclosure of the HMAC secret also permits independent reproduction of the verification calculation.

Although the verifier checks whether the calculated digest is present among the dictionary keys, storing the matching plaintext codes as dictionary values completely defeats the intended activation control.

Attack Path

  1. An attacker obtains the publicly distributed Skill package.
  2. The attacker opens scripts/verify_activation.py.
  3. The attacker copies any plaintext LDG-* activation code from VALID_HASHES.
  4. The attacker invokes:
    bash
    python3 scripts/verify_activation.py "DISCLOSED-ACTIVATION-CODE"
    
  5. The script computes the expected HMAC, finds it in the embedded allowlist, and reports VALID.
  6. The script writes the accepted code to the activation marker.
  7. The attacker gains access to functionality intended to require payment.

An attacker can also extract and redistribute all codes or r ...[truncated 639 chars]

Remediation
View remediation

Remediation Suggestions

  1. Immediately revoke all activation codes exposed in the repository.
  2. Remove the HMAC secret and plaintext activation-code allowlist from the client package.
  3. Use platform-managed entitlements or an authenticated server-side verification service over TLS.
  4. Ensure that the verification service applies code expiration, revocation, rate limiting, replay protection, and account or device binding where appropriate.
  5. If offline verification is required, issue digitally signed license documents and embed only the vendor's public verification key in the client.
  6. Never embed private signing keys, shared secrets, or complete accepted credentials in distributed code.
  7. Return a signed, minimally scoped entitlement rather than a reusable plaintext activation code.
  8. Add automated secret scanning and code-review checks to prevent credentials or license allowlists from being committed again.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/verify_activation.py:10
Finding

Reusable Activation Credential Stored in a Predictable Plaintext File

Content
View full analysis

Vulnerability Details

File Location: scripts/verify_activation.py, lines 10 and 132-133
Vulnerability Type: T09: Insecure Skill Coding Practices
Risk Level: Low

Vulnerable Code Snippet

python
MARKER = os.path.expanduser("~/.legal-doc-generator.activated")
python
with open(MARKER, "w") as f:
    f.write(code)

Technical Analysis

After successful verification, the script writes the reusable activation code directly to a predictable file in the user's home directory. The credential is not encrypted, transformed, or replaced with a non-secret entitlement token.

The file is created using the process's default permission behavior and current umask; the script does not explicitly enforce a restrictive file mode. Consequently, the credential may be exposed to other processes or users where local permissions or deployment configuration permit access.

The predictable marker also creates a weak trust model if downstream logic treats its existence as sufficient proof of activation. The supplied script performs validation before writing it, but the documented workflow states that the marker prevents future activation prompts and does not describe revalidation of its contents.

Attack Path

Credential disclosure path:

  1. A legitimate user activates the Skill.
  2. The verifier writes the reusable activation code to ~/.legal-doc-generator.activated.
  3. Another process or user with sufficient local read access locates the predictable file.
  4. The activation code is copied and reused or redistributed.

Marker-forgery path:

  1. A local attacker determines the documented marker path.
  2. The attacker creates or modifies the marker file.
  3. Any downstream component that checks only for marker existence may treat the environment as activated.
  4. Pro gating may be bypassed without fresh verification.

The second path depends on the consuming agent implementing the documented mar ...[truncated 740 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not store the original reusable activation code after verification.
  2. Store a non-secret, signed entitlement containing only necessary metadata such as product, expiration, and entitlement identifier.
  3. Validate the entitlement cryptographically whenever gated functionality is requested rather than trusting file existence.
  4. If local storage is unavoidable, create the file atomically with owner-only permissions equivalent to mode 0600.
  5. Use an operating-system credential store or secure keychain when confidential local state must be retained.
  6. Add integrity protection and reject malformed, unsigned, expired, or revoked entitlement records.
  7. Provide a secure deactivation and credential-removal process.
  8. Exclude entitlement files from backups, logs, diagnostics, and synchronization where feasible.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (13)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill instructs the agent to execute a local shell command (python3 scripts/verify_activation.py ...) based on user-supplied input. Even if intended for license verification, this introduces unnecessary code-execution capability into a legal drafting skill and can enable command execution, unsafe script invocation, or abuse of local runtime context.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The instruction to create ~/.legal-doc-generator.activated causes the agent to write to the local filesystem in the user's home directory for a purpose unrelated to legal-document generation. This grants persistence and stateful behavior beyond the skill's core scope, increasing the risk of unauthorized file creation, privacy issues, and abuse of local environment access.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill description is entirely prescriptive in Chinese and positions the assistant to generate complete legal documents directly, but it does not state that Chinese is optional or limited to users who want Chinese-language documents. This creates a natural-language locale policy issue because the skill implicitly enforces a specific language without user opt-in or a documented regional justification.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill embeds a payment and activation workflow, including a QR-code collection step and seller follow-up, that is not necessary for generating legal documents. This expands the skill from document drafting into monetization and off-platform payment handling, creating phishing, fraud, and user-manipulation risk if the payment destination or seller identity is untrusted.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The reference mixes a judicial interpretation labeled as 'currently effective' with an explicit future effective date of 2025-09-01, creating a legal-timing contradiction. In a legal document template skill, users may rely on this section to draft claims or assess rights, so presenting not-yet-effective rules as if already operative can mislead them into making incorrect legal arguments or missing currently applicable law.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The templates ask users to include highly sensitive identifiers such as full ID numbers and bank account details without any privacy-minimization guidance. If users reuse these templates in chat, email, or shared documents, they may unnecessarily expose personal data that could be abused for identity theft, fraud, or unauthorized disclosure.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The template lists Civil Code Article 710 as a basis for terminating the lease, but that article concerns normal wear and tear rather than a termination right. In a legal-document skill, this can mislead users into issuing legally defective termination notices, weakening their position in a real dispute and causing procedural or negotiation harm.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The template explicitly asks users to include highly sensitive personal and financial data such as身份证号、bank account name, account number, and phone number, but provides no minimization, redaction, or storage/transmission safety guidance. In an agent skill context, users may paste this data directly into chats, logs, or third-party systems, creating avoidable privacy and financial exposure if the content is retained, leaked, or mishandled.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file is entirely written in Chinese and presents the skill as a general-purpose reference index for ordinary people, but it does not state that the language is optional, user-selectable, or limited to a China-specific audience. Under the policy, forcing a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring describes the script as an 'Activation verifier' with output limited to 'VALID or INVALID', which implies a check-only utility. In reality, on successful verification the script creates or overwrites ~/.legal-doc-generator.activated, introducing a persistent side effect not reflected in the documentation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

Recommending WeChat/SMS for legal notices without warning about privacy leakage, account compromise, or evidentiary integrity may cause users to rely on channels that are less secure or harder to authenticate. In a dispute context, this can both expose personal information and undermine proof of delivery or message authenticity.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The document consistently uses Chinese for all instructions and examples, which can constitute a language/locale policy issue when no user opt-in or justification is provided. There is no statement that the skill is China-specific or intended only for Chinese-speaking users.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code writes the supplied activation code to a file in the user's home directory, but the only module docstring describes validation output and does not disclose that local state will be persisted. There is also no confirmation prompt or user-facing message explaining that a marker file is created.

Content

No source excerpt is available for this finding.