Back to skill

Security audit

发票查验

Security checks for vulnerabilities and agentic risk

Overview

This invoice-checking skill has a coherent purpose, but it can send arbitrary local files and the API key to configurable network destinations and includes an unsigned persistent update path.

Install only if you are comfortable sending invoice data and invoice files to ClawMate and can prevent untrusted prompts or wrappers from choosing file paths or API URLs. Avoid --api-url, --file-base64, and --verbose with real data, review any saved markdown output for sensitive fields, and do not run the documented update commands unless the publisher provides a verified checksum or signed release. The published Python script also appears syntactically invalid at the SKILL_CODE assignment, so it may not run as-is.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/invoice_validate_client.py:67
Finding

Arbitrary API Endpoint Override Discloses Credentials and Invoice Data

Content
View full analysis

Vulnerability Details

File Location: scripts/invoice_validate_client.py:67-136, 399-403
Vulnerability Type: Unrestricted destination for authenticated sensitive-data transmission
Risk Level: High

Vulnerable Code

python
if api_url is None:
    api_url = DEFAULT_API_URL

payload = {
    "platform": "api",
    "apiVersion": "1",
    "skillCode": SKILL_CODE,
    "skillVersion": SKILL_VERSION,
}

if validate_mode is not None:
    payload["validateMode"] = validate_mode

if validate_mode is not None and validate_mode >= 2:
    if file_base64:
        payload["fileBase64"] = file_base64
else:
    payload["fphm"] = fphm
    payload["kprq"] = kprq
    if fpdm:
        payload["fpdm"] = fpdm
    if kjje:
        payload["kjje"] = kjje
    if jshj:
        payload["jshj"] = jshj
    if jym:
        payload["jym"] = jym

headers = {
    "Content-Type": "application/json",
    "apiKey": api_key,
}

request_data = json.dumps(payload).encode("utf-8")
request = urllib.request.Request(
    api_url, data=request_data, headers=headers, method="POST"
)

try:
    with urllib.request.urlopen(request, timeout=60) as response:
        response_data = response.read().decode("utf-8")
        return json.loads(response_data)

The destination is exposed as a command-line parameter:

python
parser.add_argument(
    "--api-url",
    help="API endpoint URL",
)

Technical Analysis

The client accepts an unrestricted --api-url value and then sends both the user's CLAWMATE_API_KEY and the complete invoice payload to that destination. It does not enforce HTTPS, validate the destination hostname, restrict destination ports, or verify that the configured endpoint belongs to the declared ClawMate service.

The payload can contain invoice numbers, dates, amounts, check codes, or a complete Base64-encoded invoice. Base64 is transport encoding and provides ...[truncated 1613 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove --api-url from production-facing usage and use the fixed documented endpoint.
  • If endpoint configurability is required for development, place it behind an explicit development-only configuration and never attach production credentials.
  • Parse the URL and require:
    • The https scheme.
    • An exact allowlisted hostname such as www.clawmate.net.
    • The expected HTTPS port.
    • The expected API path.
    • No embedded user information.
  • Disable redirects or ensure credentials are never forwarded when the origin changes.
  • Reject loopback, link-local, private, and non-allowlisted destinations.
  • Use a dedicated TLS context with certificate and hostname verification enabled.
  • Add automated tests confirming that HTTP URLs, alternate hosts, redirects, and local-network addresses are rejected before request construction.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/invoice_validate_client.py:115
Finding

Verbose Mode Logs Complete Sensitive Invoice Payloads

Content
View full analysis

Vulnerability Details

File Location: scripts/invoice_validate_client.py:115-126
Vulnerability Type: Sensitive information exposure through diagnostic output
Risk Level: Medium

Vulnerable Code

python
if verbose:
    print("=" * 60, file=sys.stderr)
    print("Invoice Validate API Request", file=sys.stderr)
    print("=" * 60, file=sys.stderr)
    print(f"Endpoint: {api_url}", file=sys.stderr)
    print(f"Method: POST", file=sys.stderr)
    print(f"Headers:", file=sys.stderr)
    for key, value in headers.items():
        if key.lower() == "apikey":
            masked_value = (
                value[:4] + "****" + value[-4:] if len(value) > 8 else "****"
            )
            print(f"  {key}: {masked_value}", file=sys.stderr)
        else:
            print(f"  {key}: {value}", file=sys.stderr)
    print(f"Payload:", file=sys.stderr)
    print(f"  {json.dumps(payload, ensure_ascii=False)}", file=sys.stderr)
    print("=" * 60, file=sys.stderr)

Technical Analysis

The API key is partially masked, but the entire request payload is printed to standard error. Depending on the validation mode, that payload can include invoice identifiers, dates, monetary values, check codes, or the complete Base64-encoded invoice file.

Standard error is frequently captured by agent execution logs, terminal recording, CI systems, monitoring services, support bundles, and shell redirection. Base64 does not redact or encrypt a document and can be decoded without a key.

Logging the complete document is not necessary to diagnose ordinary request failures and violates data-minimization principles.

Attack Path

  1. A user, operator, wrapper, or attacker-influenced instruction enables --verbose.
  2. The client builds a payload containing invoice data or a complete encoded file.
  3. The client prints the entire payload to standard error before transmission.
  4. The surrounding agent pla ...[truncated 544 chars]
Remediation
View remediation

Remediation Suggestions

  • Never print fileBase64, check codes, tax identifiers, bank details, full invoice numbers, or complete request payloads.
  • Replace payload logging with a strict allowlist of non-sensitive metadata, such as:
    • Validation mode.
    • Whether required fields are present.
    • Encoded file size.
    • A locally generated request correlation identifier.
  • Redact sensitive values before serialization rather than attempting to redact the resulting JSON string.
  • Keep verbose logging disabled by default and clearly warn that diagnostic output must not contain user documents.
  • Add tests that capture standard output and standard error and assert that known sensitive test values never appear.

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/invoice_validate_client.py:440
Finding

Declared File-Access Boundary Is Not Enforced by the Client

Content
View full analysis

Vulnerability Details

File Location: scripts/invoice_validate_client.py:407-414, 440-449
Vulnerability Type: Arbitrary readable-file access and external transmission
Risk Level: High

The Skill documentation states that file access must be restricted to the working directory's .clawmate subtree or a directory explicitly selected by the user. The implementation does not enforce that restriction.

Vulnerable Code

python
parser.add_argument(
    "--file", "-f",
    help="File path for file validation modes",
)
parser.add_argument(
    "--file-base64",
    help="Base64 file content for file validation modes; takes priority over --file",
)
python
file_base64 = args.file_base64
if not file_base64 and args.file:
    import base64
    try:
        with open(args.file, "rb") as f:
            file_base64 = base64.b64encode(f.read()).decode("utf-8")
    except FileNotFoundError:
        print(f"File does not exist: {args.file}", file=sys.stderr)
        sys.exit(6)
    except Exception as e:
        print(f"Failed to read file: {e}", file=sys.stderr)
        sys.exit(6)

The resulting content is sent externally:

python
if validate_mode is not None and validate_mode >= 2:
    if file_base64:
        payload["fileBase64"] = file_base64

Technical Analysis

The script directly passes the caller-provided path to open() without canonicalizing it or checking it against an allowed root. There are no controls against absolute paths, parent-directory traversal, symlink escapes, device files, or files outside the declared invoice directories.

The --file-base64 option also bypasses file-path controls entirely. Once read, the content is encoded and transmitted to the remote API. The implementation therefore relies solely on the caller or agent to respect a textual policy instead of enforcing least privilege in code.

Attack Path

  1. An attacker i ...[truncated 1036 chars]
Remediation
View remediation

Remediation Suggestions

  • Canonicalize the requested path with Path.resolve(strict=True) before opening it.
  • Maintain an explicit list of authorized canonical root directories.
  • Require the resolved path to be a descendant of an authorized root.
  • Reject symlinks or securely verify the opened file descriptor to prevent time-of-check/time-of-use and symlink races.
  • Require a regular file and reject devices, sockets, FIFOs, and other special files.
  • Enforce an allowlist of supported invoice extensions and validate file signatures rather than relying only on extensions.
  • Apply a strict maximum file size before reading to avoid memory exhaustion.
  • Remove --file-base64 unless it is essential; otherwise restrict it to trusted internal callers and apply equivalent size and content checks.
  • Require explicit confirmation that identifies the canonical file path and remote destination before transmission.
  • Add tests for absolute paths, .. traversal, symlink escapes, special files, oversized files, and unauthorized roots.

T03 · Remote Payload Retrieval and Execution

Error
Location
SKILL.md:215
Finding

Unsigned Remote Update Can Overwrite Installed Skill Code

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:215-225
Vulnerability Type: Mutable remote payload retrieval without integrity verification
Risk Level: High

Vulnerable Code

bash
curl -o /tmp/cm-invoice-validate.zip https://www.clawmate.net/server/test/cm-invoice-validate.zip
mkdir -p ~/.agents/skills/cm-invoice-validate
unzip -o /tmp/cm-invoice-validate.zip -d ~/.agents/skills/cm-invoice-validate/

Technical Analysis

The documented update process downloads a mutable archive and overwrites the installed Skill directory. It does not verify a cryptographic signature, pinned checksum, immutable release identifier, or expected archive contents.

HTTPS protects the connection under normal trust assumptions but does not protect against a compromised update server, unauthorized replacement at the source, compromised certificate infrastructure, or publication mistakes. The use of unzip -o overwrites existing files. The process also does not show archive-path validation before extraction.

Although the documentation requires user confirmation before running the commands, confirmation only authorizes the update; it does not prove that the downloaded payload is authentic or safe. Once installed, modified Skill instructions or scripts can execute during later invocations.

Attack Path

  1. An attacker compromises or gains control over the update archive, its hosting service, or the associated delivery infrastructure.
  2. The service reports or appears to report that the installed version is outdated.
  3. The user approves the documented update procedure.
  4. curl downloads the attacker-controlled archive without integrity verification.
  5. unzip -o writes its contents over the installed Skill.
  6. On a later invocation, the agent loads altered instructions or executes altered scripts.
  7. The substituted payload operates with the permissions and accessible credentials of the agent process.

I

...[truncated 477 chars]

Remediation
View remediation

Remediation Suggestions

  • Publish updates as immutable, explicitly versioned release artifacts.
  • Sign every release with a maintained offline signing key and verify the signature locally before extraction.
  • If signatures are not available, pin and verify a SHA-256 or stronger digest obtained through a separately authenticated channel.
  • Download into a securely created temporary directory rather than a predictable shared temporary filename.
  • List and validate all archive entries before extraction.
  • Reject absolute paths, parent traversal, symlinks, hard links, and entries outside the expected Skill directory.
  • Extract into a staging directory, verify the expected manifest and file hashes, and then perform an atomic installation.
  • Avoid direct overwrite installation with unzip -o.
  • Preserve a known-good prior version for rollback.
  • Display the exact version, digest, signer identity, and file changes to the user before confirmation.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (10)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill declares runtime requirements for environment access and makes outbound API calls, but it does not declare an explicit tool/permission scope. That weakens least-privilege enforcement and makes it harder for the hosting agent to constrain file, network, and secret use, especially in a skill that handles sensitive invoice data and an API key.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest description is entirely in Chinese and presents the skill's invocation and usage context only in that language. Under the policy, forcing a specific language without user opt-in or a documented justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill instructs the agent to display and save extensive invoice fields, including names, tax IDs, bank names, and bank account numbers. That creates a natural-language data leakage path because the model is told to expose sensitive financial and identity data in chat output and persisted markdown files, increasing risk of overexposure, logging leakage, and unauthorized local disclosure.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
94% confidence
Finding

The skill provides an update flow that downloads a zip from a remote server and installs it locally without any authenticity or integrity verification. This creates a supply-chain risk: if the server, DNS, TLS endpoint, or distribution path is compromised, the agent could install attacker-controlled skill content.

Content

Scanner excerpt · SKILL.md (reported line 220)May include surrounding context.

text
⚠️ 技能版本过低,请运行以下命令更新:

curl -o /tmp/cm-invoice-validate.zip https://www.clawmate.net/server/test/cm-invoice-validate.zip
mkdir -p ~/.agents/skills/cm-invoice-validate
unzip -o /tmp/cm-invoice-validate.zip -d ~/.agents/skills/cm-invoice-validate/

Session Persistence

Medium
Category
Rogue Agent
Confidence
91% confidence
Finding

The update instructions write files into a persistent skill directory under ~/.agents/skills, changing future agent behavior across sessions. Persistence alone is not always unsafe, but here it amplifies the unverified download risk because any malicious or tampered update would survive beyond the current interaction and continue affecting later runs.

Content

Scanner excerpt · SKILL.md (reported line 221)May include surrounding context.

⚠️ 技能版本过低,请运行以下命令更新:

curl -o /tmp/cm-invoice-validate.zip https://www.clawmate.net/server/test/cm-invoice-validate.zip mkdir -p ~/.agents/skills/cm-invoice-validate unzip -o /tmp/cm-invoice-validate.zip -d ~/.agents/skills/cm-invoice-validate/

text

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The client sends invoice identifiers and related billing fields to an external service, but the interface does not present a clear user-facing warning that potentially sensitive invoice data leaves the local environment. In a skill/agent setting, users may reasonably assume local processing, so the absence of clear disclosure increases privacy and compliance risk.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The manifest describes this skill as being used when a user wants to verify whether an invoice is genuine, which naturally covers submitting invoice metadata for checking. However, the code expands behavior to read local PDF/image/ODF files from disk, base64-encode them, and transmit them to the remote API, which is a materially broader operating mode than the manifest's narrow description suggests.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The script will read any local path provided via --file and base64-encode its contents for transmission to a remote API, without constraining file location or verifying that the file is actually an invoice. In an agent context, this creates a data-exfiltration primitive: a prompt or workflow could cause sensitive local files to be uploaded under the guise of invoice validation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

When file mode is used, the script reads a local file, base64-encodes it, and uploads it to the remote API without a prominent warning that the file contents will be transmitted externally. Because invoice files can contain full billing records and because the path is arbitrary, this can expose highly sensitive documents or unintended local files.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The file's natural-language description and user-facing CLI messages are written in Chinese, and the script does not provide an option to select another language or locale. This can violate language/locale policy where user choice or explicit opt-in is required.

Content

No source excerpt is available for this finding.