Back to skill

Security audit

invoice-auto-forward

Security checks for vulnerabilities and agentic risk

Overview

ClawScan marks this invoice-forwarding skill suspicious because scanners report email-controlled links that can reach internal services and oversized archives that can exhaust resources.

Consider the suspicious verdict and reported link-fetching, archive resource-exhaustion, and authorization-code exposure risks before installing. Skillspector's analysis was partial because some local references could not be resolved, so the evidence is incomplete.

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/invoice_forward.py
Finding

Email-controlled links bypass network destination restrictions

Content
View full analysis

Impact

A sender can induce HTTP GET requests to internal services through a hostname resolving to a private address or a public URL redirecting to a private address. This enables blind internal endpoint access and can trigger actions on endpoints that act on GET requests. Response-format rejection does not prevent the request because it occurs afterward. Credential theft or remote code execution is not established.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/invoice_forward.py
Finding

Unbounded OFD archive expansion permits email-triggered resource exhaustion

Content
View full analysis

Impact

A compact archive can expand into XML large enough to exhaust process memory or substantially delay processing, terminating or blocking invoice scanning and forwarding. The link download byte limit constrains compressed network bytes, not decompressed archive size.

Vulnerability Patterns
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (6)

Tainted flow: 'req' from open (line 548, file read) → urllib.request.urlopen (network output)

High
Category
Data Flow
Confidence
99% confidence
Finding

Although the scanner's file-read provenance is inaccurate, this request exposes a real SSRF vulnerability: email-controlled URLs can use hostnames resolving to private addresses, and automatic redirects are not revalidated. The optional domain check also accepts unrelated domains through unrestricted endswith matching, while response-format checks occur only after the request and cannot prevent internal requests or their side effects; default-enabled unattended fetching increases exposure.

Content

Scanner excerpt · scripts/invoice_forward.py (reported line 549)May include surrounding context.

python
return b"", "", ""
    try:
        req = urllib.request.Request(url, headers={"User-Agent": ua})
        with urllib.request.urlopen(req, timeout=timeout) as r:
            ctype = (r.headers.get("Content-Type") or "").lower()
            disp = r.headers.get("Content-Disposition") or ""
            data = r.read(max_bytes + 1)

The supposedly hidden authorization-code prompt displays the existing code in plaintext.

High
Category
Excessive Agency
Confidence
99% confidence
Finding

When setup reuses an existing authorization code, _prompt interpolates that code into the default-value suffix and passes it as the getpass prompt. Getpass hides newly typed input, not the prompt itself, so the stored credential is exposed on screen and potentially in terminal recordings or support transcripts, risking mailbox access and unauthorized sending.

Content

No source excerpt is available for this finding.

Skill declares no tool scope ('permissions' or 'allowed-tools') but code capabilities were detected: env, file_write, network, shell.

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Tainted flow: 'p' from open (line 695, file read) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/invoice_forward.py (reported line 698)May include surrounding context.

python
p = os.path.expanduser(path)
    try:
        os.makedirs(os.path.dirname(p), exist_ok=True)
        with open(p, "w", encoding="utf-8") as fp:
            json.dump(state, fp, ensure_ascii=False, indent=2)
    except OSError as e:
        # 状态写失败必须响亮失败——静默吞掉会导致下次运行重复转发

Tainted flow: 'report' from open (line 833, file read) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/invoice_forward.py (reported line 836)May include surrounding context.

python
report = os.path.join(os.path.dirname(os.path.expanduser(cfg["state_file"])),
                              f"报告_{now:%Y%m%d}.md")
        try:
            with open(report, "w", encoding="utf-8") as fp:
                fp.write(f"# 发票转发报告 {now:%Y-%m-%d %H:%M}\n\n- 范围:近 {days} 天;候选 {len(cand)} 封\n- {summary}\n")
                fp.write("\n".join("- ✅ " + s for s in sent))
                fp.write("\n".join("\n- ⚠️ 无发票: %s(%s)" % (s, reason) for s, reason in no_invoice))

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/invoice_forward.py (reported line 915)May include surrounding context.

python
import subprocess
        print("  … 正在自动安装 pdfplumber pymupdf(pip,当前 Python 环境)")
        try:
            r = subprocess.run([sys.executable, "-m", "pip", "install", "pdfplumber", "pymupdf"],
                               capture_output=True, text=True, timeout=600)
        except Exception as e:
            raise RuntimeError("自动安装执行异常(pip 不可用或超时):%s" % e)