Back to skill

Security audit

Cn Qrcode Reader

Security checks for vulnerabilities and agentic risk

Overview

This is a simple QR/barcode reader that only processes user-specified image files, with some minor documentation and hardening issues.

Install this in a normal user environment or virtual environment, review dependency versions if reproducibility matters, and be careful when scanning untrusted QR codes because decoded text is printed directly to the terminal.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (2)

T09 · Insecure Skill Coding Practices

Note
Location
scripts/cn_qrcode_reader.py:38
Finding

Terminal Control-Sequence Injection Through Decoded Barcode Data

Content
View full analysis

Vulnerability Details

File Location: scripts/cn_qrcode_reader.py, lines 38-45
Vulnerability Type: Unsanitized terminal output
Risk Level: Low

Vulnerable Code:

python
for barcode in barcodes:
    data = barcode.data.decode('utf-8')
    barcode_type = barcode.type
    results.append({
        'type': barcode_type,
        'data': data,
        'rect': barcode.rect
    })
    
    if verbose:
        print(f"[{barcode_type}] {data}")
    else:
        print(data)

Technical Analysis

Barcode and QR-code contents are attacker-controlled data. The application decodes this data as UTF-8 and writes it directly to the user's terminal without escaping control characters.

A malicious barcode can contain ANSI escape sequences or other non-printable terminal control characters. When printed, a compatible terminal may interpret these characters rather than displaying them literally. This can alter colors, move the cursor, erase or conceal output, forge apparent command results, manipulate terminal titles, or invoke terminal-specific behavior.

The decoded content is treated only as data by Python and is not passed to a shell, so the reviewed code does not directly provide command execution. More severe effects would depend on vulnerabilities or unsafe features in the user's terminal emulator.

Attack Path

  1. An attacker creates a QR code containing ANSI escape sequences or other terminal control characters.
  2. The attacker convinces a user to scan the image with this skill.
  3. pyzbar returns the attacker-controlled barcode content.
  4. The application decodes the content and passes it directly to print().
  5. The user's terminal interprets embedded control sequences, allowing the displayed output or terminal state to be manipulated.

Impact Assessment

Exploitation requires a user to process an attacker-supplied image. The attacker may spoof or conceal terminal output a ...[truncated 293 chars]

Remediation
View remediation

Remediation Suggestions

  • Escape decoded values before displaying them in an interactive terminal.
  • Render control characters visibly, for example by using repr(data) or a dedicated escaping function.
  • Remove C0, C1, ANSI escape, and other non-printable control characters from display output while retaining the original value separately when required.
  • Consider offering a machine-readable output mode, such as JSON, with appropriate serialization.
  • Clearly distinguish trusted application messages from untrusted barcode content.
  • Add tests using payloads containing escape characters such as \x1b[2J, cursor movement sequences, carriage returns, backspaces, and terminal-title sequences.

T08 · Insecure Dependencies

Note
Location
SKILL.md:39
Finding

Unpinned Third-Party Dependency Installation Instructions

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 39-43; scripts/cn_qrcode_reader.py, lines 24-27
Vulnerability Type: Unpinned software dependencies
Risk Level: Low

Vulnerable Documentation:

markdown
- Python 3.x
- Pillow (pip install Pillow)
- pyzbar (pip install pyzbar)
  - macOS: `brew install zbar`
  - Ubuntu: `sudo apt-get install libzbar0`

Vulnerable Code:

python
if decode_barcode is None:
    print("错误:缺少依赖库")
    print("请安装:pip install Pillow pyzbar")
    print("macOS: brew install zbar")
    print("Ubuntu: sudo apt-get install libzbar0")
    return []

Technical Analysis

The project instructs users to install Pillow and pyzbar without version constraints or integrity hashes. Package names appear legitimate, and the reviewed files do not reference an unknown package index or suspicious download source. Nevertheless, unconstrained installation resolves to whatever releases are current at installation time.

This prevents reproducible dependency resolution and can expose users to compromised future releases, unexpected incompatible updates, or newly introduced vulnerabilities. The operating-system package commands are also unconstrained and depend on the state and trust configuration of the user's package repositories.

Attack Path

  1. A dependency distribution channel or future package release is compromised, vulnerable, or otherwise unsafe.
  2. A user follows the documented pip install Pillow pyzbar instruction.
  3. The package manager resolves and installs the current unconstrained releases.
  4. Package installation hooks or imported runtime code execute within the user's environment.
  5. Any resulting access is limited by the privileges of the user or environment performing installation and execution.

This is a supply-chain hardening issue rather than evidence that the currently named packages are malicious.

Impact Assessment

...[truncated 484 chars]

Remediation
View remediation

Remediation Suggestions

  • Add a reviewed dependency manifest with exact or appropriately bounded versions.
  • Use a lock file or hash-validated requirements file, such as requirements.txt entries generated with cryptographic hashes.
  • Test dependency updates before changing pinned versions.
  • Recommend installation in a dedicated virtual environment with ordinary user privileges.
  • Document supported Python and native zbar versions.
  • Use trusted package indexes and preserve standard package-manager signature verification.
  • Integrate dependency vulnerability and provenance scanning into the release process.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • 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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (4)

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill description states it supports both camera and file input, but the rest of the file only documents passing image paths/globs to a Python script. There is no documented camera-related argument, mode, or implementation evidence in this file, so the documentation appears to overstate behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The title and user-facing descriptions are entirely in Chinese, indicating a language-specific skill experience without any visible opt-in or alternative locale handling. Under the policy, forcing a specific language without user choice is a natural-language policy concern unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

md
print("错误:缺少依赖库")
        print("请安装:pip install Pillow pyzbar")
        print("macOS: brew install zbar")
        print("Ubuntu: sudo apt-get install libzbar0")
        return []
    
    try:

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/cn_qrcode_reader.py (reported line 27)May include surrounding context.

python
print("错误:缺少依赖库")
        print("请安装:pip install Pillow pyzbar")
        print("macOS: brew install zbar")
        print("Ubuntu: sudo apt-get install libzbar0")
        return []
    
    try: