Back to skill

Security audit

校验XML数电票

Security checks for vulnerabilities and agentic risk

Overview

This is a local Chinese e-invoice XML format-checking skill, but its sample validator is shallow and should not be treated as proof of invoice authenticity or compliance.

Install only if you need a lightweight local format triage helper for Chinese e-invoice XML. Do not rely on it for tax compliance, fraud detection, or authenticity decisions unless it is strengthened with full schema validation and real digital-signature verification.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:114
Finding

Mandatory invoice and taxpayer identifiers are treated as optional

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 114–129
Vulnerability Type: Improper input validation
Risk Level: High

python
invoice_num = root.find('.//InvoiceNumber')
if invoice_num is not None and invoice_num.text:
    result["invoice_number"] = invoice_num.text.strip()

seller_id = root.find('.//SellerIdNum')
if seller_id is not None and seller_id.text:
    result["seller_id"] = seller_id.text.strip()

buyer_id = root.find('.//BuyerIdNum')
if buyer_id is not None and buyer_id.text:
    result["buyer_id"] = buyer_id.text.strip()

Technical Analysis

The documented validation requirements identify InvoiceNumber, SellerIdNum, and BuyerIdNum as mandatory fields. The implementation, however, only processes these elements when they exist and contain text. It does not append an error when any of them is absent or empty.

Consequently, an XML document can omit all three identifiers and still reach a successful result if the few other checked fields are present. The conditional validation of InvoiceNumber also means its 20-digit format is enforced only when a value has already been supplied.

Attack Path

  1. An attacker creates an XML document with an EInvoice root.
  2. The attacker supplies a valid-looking 20-digit EIid, an EInvoiceTag, a non-empty SignatureValue, and a TaxBureauName.
  3. The attacker omits InvoiceNumber, SellerIdNum, and BuyerIdNum, or leaves them empty.
  4. The relevant conditional blocks are skipped without recording validation errors.
  5. The validator can return a successful result for an incomplete or fabricated invoice.

Impact Assessment

This issue does not grant operating-system privileges or code execution. Its impact is limited to the validator's trust boundary and systems that rely on its output. Incomplete or fabricated invoices may be classified as valid, potentially weakening accounting, compliance, ingestion, or fraud-detection workflows.

Remediation
View remediation

Remediation Suggestions

  • Add explicit errors for every missing or empty mandatory field.
  • Validate InvoiceNumber as exactly 20 digits regardless of whether the element is absent, empty, or malformed.
  • Define and enforce appropriate formats for seller and buyer taxpayer identifiers.
  • Reject duplicate mandatory elements rather than silently accepting the first match.
  • Add negative tests covering absent, empty, malformed, and duplicate fields.
  • Derive the final result from a complete mandatory-field checklist rather than from the absence of errors generated by partial checks.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:103
Finding

Descendant-wide element searches permit invoice structure validation bypass

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 103–137
Vulnerability Type: Improper XML structure validation
Risk Level: High

python
eiid = root.find('.//EIid')
einvoice_tag = root.find('.//EInvoiceTag')
invoice_num = root.find('.//InvoiceNumber')
seller_id = root.find('.//SellerIdNum')
buyer_id = root.find('.//BuyerIdNum')
signature = root.find('.//SignatureValue')
tax_bureau = root.find('.//TaxBureauName')

Technical Analysis

The validator uses descendant-wide .// searches for all significant elements. These searches locate an element with the requested name anywhere below the root, without verifying its documented parent section.

As a result, the implementation does not require EIid to be under Header, seller and buyer identifiers to be under their respective information sections, InvoiceNumber and TaxBureauName to be under TaxSupervisionInfo, or SignatureValue to be under TaxBureauSignature.

The validator also does not enforce the existence, ordering, cardinality, or content of several documented sections, including EInvoiceData, BasicInformation, IssuItemInformation, and SellerAuthentication. The ns variable declared at line 100 is not used, so namespace-aware documents are also not handled as intended.

Attack Path

  1. An attacker creates an XML document whose root is named EInvoice.
  2. Instead of constructing the required invoice hierarchy, the attacker places required-looking leaf elements beneath arbitrary or unrelated nodes.
  3. Descendant-wide searches locate those elements regardless of their parents.
  4. The attacker supplies values that satisfy the limited lexical checks.
  5. The malformed document passes validation even though it does not conform to the documented invoice structure.

Impact Assessment

No system permissions are obtained. The affected scope is structural validation and any downstream process that trusts the positive result. Arbitrary XML can be made to resemble ...[truncated 150 chars]

Remediation
View remediation

Remediation Suggestions

  • Replace descendant-wide searches with exact, namespace-aware paths for every required element.
  • Verify that each element appears under its required parent and with the expected cardinality.
  • Reject duplicate or misplaced security-sensitive elements.
  • Validate the complete required hierarchy, including header, invoice data, basic information, line items, authentication, supervision information, and signature sections.
  • Use an authoritative, locally stored XSD when available and perform schema validation before semantic checks.
  • Handle XML namespaces explicitly by extracting the namespace URI from the root and using it in every lookup.
  • Add adversarial tests containing misplaced elements, duplicate elements, missing sections, unexpected namespaces, and structurally invalid documents.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:131
Finding

Non-empty signature text is accepted without cryptographic verification

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 131–144
Vulnerability Type: Missing cryptographic signature verification
Risk Level: High

python
signature = root.find('.//SignatureValue')
if signature is None or not signature.text:

The final decision is based on whether the accumulated error list is empty:

python
if len(result["errors"]) == 0:
    result["has_required_fields"] = True
    return True, message, result

Technical Analysis

The implementation treats the presence of non-empty SignatureValue text as sufficient evidence that the XML contains an acceptable digital signature. It does not decode or validate the signature, verify a digest, determine which content was signed, inspect the signing certificate, validate a certificate chain, or establish trust in the issuing tax authority.

An arbitrary string therefore satisfies the signature check. The positive result can be misinterpreted as establishing invoice validity even though the implementation only checks superficial element presence.

Attack Path

  1. An attacker creates or modifies an invoice XML document.
  2. The attacker inserts any non-empty string into a SignatureValue element.
  3. The presence check succeeds because no cryptographic verification is performed.
  4. The attacker satisfies the remaining superficial checks.
  5. The validator returns a successful result despite the signature being forged, malformed, or unrelated to the document content.

Impact Assessment

The vulnerability does not provide local code execution or elevated system privileges. It permits attackers to cross the application's invoice-authenticity trust boundary. Forged or modified invoices may receive a positive validation result, which could mislead users or downstream systems into accepting untrusted financial records.

Remediation
View remediation

Remediation Suggestions

  • Verify the XML digital signature with a maintained XML Signature implementation.
  • Canonicalize the signed content according to the applicable invoice specification.
  • Validate every referenced digest and ensure references bind the signature to the expected invoice document and required elements.
  • Validate the signing certificate chain, validity period, revocation status, key usage, and issuer against an explicitly configured tax-authority trust store.
  • Reject unsupported, deprecated, or weak signature and digest algorithms.
  • Protect against XML signature wrapping by resolving signed elements through unique, schema-validated identifiers and requiring expected reference targets.
  • If cryptographic verification is outside the intended scope, rename the result to indicate structural plausibility and explicitly state that authenticity and integrity have not been verified.
Vulnerability Patterns
  • 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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest description and the entire skill content are written only in Chinese, with no indication that users may choose another language or that Chinese-only output is required. The policy explicitly flags language or locale constraints when they are imposed without user opt-in or a documented justification.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill states that several sections are mandatory, but the code only validates a much smaller subset and does not enforce the presence of all listed required structures. An attacker or malformed input could therefore omit important sections while still appearing partially valid, which weakens business validation and may let non-compliant or spoofed invoice XML pass screening.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documentation promises validation of additional required fields and the XML declaration, but the sample code does not actually enforce those checks. This can cause users or downstream agents to trust a file as a compliant e-invoice when important structural or integrity-related requirements were never verified, leading to false assurance and incorrect processing decisions.

Content

No source excerpt is available for this finding.