Back to skill

Security audit

TencentCloud IDCard OCR

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but it processes highly sensitive ID-card data through Tencent Cloud and can upload any readable local file supplied as an image path.

Review before installing. Use this only for ID-card images you are authorized to process, assume submitted images and OCR results may be handled by Tencent Cloud, keep Tencent credentials in a protected secret store, and avoid passing arbitrary local paths because non-image files could be uploaded. Prefer running it in a restricted environment until file-type validation and explicit consent warnings are added.

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

Warning
Location
scripts/main.py:66
Finding
Arbitrary Local File Contents Can Be Transmitted to the OCR Service<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:66-81`, with transmission at `scripts/main.py:213-243` **Vulnerability Type**: Insufficient file-type validation leading to unintended sensitive-data disclosure **Risk Level**: Medium ### Vulnerable Code ```python if os.path.isfile(value): with open(value, "rb") as f: raw = f.read() try: raw_str = raw.decode("utf-8").strip() base64.b64decode(raw_str, validate=True) return raw_str except (UnicodeDecodeError, ValueError): pass encoded = base64.b64encode(raw).decode("utf-8") if len(raw) > MAX_IMAGE_SIZE_BYTES: sys.exit(1) return encoded ``` The resulting content is assigned to the OCR request and sent to Tencent Cloud: ```python elif args.image_base64: req.ImageBase64 = load_image_base64(args.image_base64) try: resp = client.IDCardOCR(req) except TencentCloudSDKException as e: sys.exit(1) ``` ### Technical Analysis The `--image-base64` argument accepts either a Base64 value or any path for which `os.path.isfile()` returns true. When a path is supplied, the script reads the complete file. If the content is not already valid Base64 text, it Base64-encodes the raw bytes and submits them through the Tencent Cloud OCR SDK. Base64 encoding is a normal and documented transport mechanism for the OCR API, so the encoding operation is not inherently covert or malicious. However, the implementation does not verify that the selected file is actually an image. It does not check a trusted MIME type, image signature, supported format, or successful decoding through an image parser. Consequently, any readable file smaller than the 10 MB limit can be placed into the outbound OCR request. This exceeds the minimum file access needed for the declared ID-card image recognition functionality. ### Attack Path 1. An attacker gains influence over the arguments used to invoke the Skill, such as by supplying an untrusted path ...[truncated 1323 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Verify the content as an image before assigning it to `req.ImageBase64`. 2. Decode the file through a trusted image-processing library and reject content that cannot be parsed as a supported image format. 3. Allow only the image formats supported by the OCR API, such as JPEG or PNG, and verify both the detected format and file signature. 4. Apply the size limit before Base64 encoding and before retaining the entire file in memory. 5. Do not rely solely on filename extensions or caller-provided MIME types. 6. Where feasible, restrict local input to an explicitly approved directory and resolve paths with `realpath` before validating that boundary. 7. Clearly warn users that supplied ID-card images are transmitted to Tencent Cloud and may contain highly sensitive personal information. 8. Add automated tests confirming that text files, credential files, symbolic-link escapes, malformed images, and unsupported formats are rejected. ]]>

T08 · Insecure Dependencies

Note
Location
SKILL.md:30
Finding
Third-Party SDK Installation Is Unpinned and Lacks Integrity Verification<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:30`; related runtime dependency handling at `scripts/main.py:184-194` **Vulnerability Type**: Unpinned third-party dependency and non-reproducible installation **Risk Level**: Low ### Vulnerable Installation Command ```bash pip install tencentcloud-sdk-python ``` The script imports and executes the installed SDK at runtime: ```python from tencentcloud.common import credential from tencentcloud.common.exception.tencent_cloud_sdk_exception import ( TencentCloudSDKException, ) from tencentcloud.common.profile.client_profile import ClientProfile from tencentcloud.common.profile.http_profile import HttpProfile from tencentcloud.ocr.v20181119 import models, ocr_client ``` ### Technical Analysis The installation instructions request the latest available version of `tencentcloud-sdk-python` without a fixed version, lock file, package hash, or other integrity control. The package name is consistent with the declared Tencent Cloud integration, and the audit found no evidence that it is a typosquatted or intentionally malicious dependency. Nevertheless, installing an unconstrained package makes the environment non-reproducible and automatically trusts future releases returned by the configured package index. A compromised registry account, package-index substitution, malicious mirror, or unexpectedly incompatible future release could introduce code that is not represented in the audited project. Because Python imports execute module initialization code, a compromised installed SDK could execute locally when `scripts/main.py` imports it. ### Attack Path 1. A user follows the documented command to install the SDK. 2. The configured Python package index or mirror supplies a compromised, substituted, or unexpectedly changed release. 3. The package is installed without a version constraint or hash verification. 4. The user invokes the OCR Skill. 5. Python imports the installed SDK and executes its mod ...[truncated 840 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin the SDK to a specific audited version in a dependency file. 2. Generate and commit a lock file appropriate for the project’s package-management workflow. 3. Record cryptographic hashes and install with hash enforcement, for example: ```bash pip install --require-hashes -r requirements.txt ``` 4. Use an approved package index over TLS and avoid untrusted mirrors. 5. Periodically review and deliberately update the pinned version after security and compatibility testing. 6. Run dependency vulnerability scanning in continuous integration. 7. Install and execute the Skill in a least-privileged virtual environment or container with restricted filesystem and network access. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (9)

Missing User Warnings

High
Confidence
98% confidence
Finding
This skill handles Chinese resident ID card images and extracts fields such as name, address, and ID number, which are highly sensitive personal data, yet the documentation does not clearly warn users that both the image and recognition results may be sent to a cloud provider. In this context, missing disclosure undermines informed consent and can lead to serious privacy, regulatory, and data-handling violations.

Lp3

Medium
Category
MCP Least Privilege
Confidence
85% confidence
Finding
The skill declares use of environment-based credentials but does not define any explicit tool scope or permission boundary. That makes the skill's operational capabilities less transparent to the host agent and increases the risk of over-broad access or unintended execution paths involving sensitive secrets.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The trigger conditions are broad enough to match 'any scenario involving ID card OCR recognition,' which can cause the skill to be invoked automatically in situations the user did not clearly intend. Because the skill processes highly sensitive identity documents and may transmit them to a third-party cloud API, accidental invocation materially increases privacy and compliance risk.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The documentation instructs operators to use Tencent Cloud secret environment variables but provides no guidance on secure storage, rotation, least privilege, or avoiding disclosure. In agent environments, this omission can contribute to accidental credential leakage, misuse of cloud APIs, or unsafe operational practices around secret management.

Natural-Language Policy Violations

Medium
Confidence
87% confidence
Finding
User-facing strings, help text, errors, and output annotations are consistently in Chinese, and warning descriptions are explicitly converted to Chinese-only labels. The file does not offer a language option or explain that the skill is intentionally limited to Chinese-speaking users or a China-specific compliance context.

Context-Inappropriate Capability

Medium
Confidence
93% confidence
Finding
The --image-base64 parameter accepts an arbitrary local filesystem path and reads the file contents, then either forwards them as-is if they are valid Base64 text or encodes the raw bytes and sends them to the remote OCR API. In an agent/skill setting, this broadens the capability from OCRing supplied image data to local file exfiltration, including accidental transmission of sensitive host files unrelated to the user's image.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script sends highly sensitive personal data—ID card images and extracted identity fields—to a remote cloud OCR service, but it provides no explicit runtime notice, consent check, or data-handling warning. In a skill context, users or orchestrating agents may not realize that local images or image URLs containing identity documents are transmitted off-host to a third party, increasing privacy and compliance risk.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Content
common_fields = ["AdvancedInfo", "RequestId"]

    for field in front_fields + back_fields + common_fields:
        val = getattr(resp, field, None)
        if val:
            output[field] = val
Confidence
50% confidence
Finding
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Intent-Code Divergence

Low
Confidence
96% confidence
Finding
The help text states the client identifier is '统一固定为 Skills', implying it is fixed. In reality, the parser accepts any --user-agent string and the code passes it through to client_profile.request_client, so the documentation contradicts actual behavior.

Static analysis

No suspicious patterns detected.