Back to skill

Security audit

TencentCloud MLIDPassport OCR

Security checks for vulnerabilities and agentic risk

Overview

This skill is a straightforward Tencent Cloud passport OCR wrapper, but users should treat submitted passport images and returned fields as highly sensitive personal data.

Install only if you intend to send passport images or passport image URLs to Tencent Cloud for OCR. Use a restricted Tencent Cloud key, avoid enabling cropped face-image return unless needed, process only documents you are authorized to handle, and consider pinning the SDK dependency in your own environment.

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:70
Finding
Image size validation occurs after an unbounded file read<![CDATA[ ## Vulnerability Details **File Location**: `scripts/main.py:70-84` **Vulnerability Type**: Unbounded memory allocation and denial of service **Risk Level**: Medium ### Vulnerable Code ```python if os.path.isfile(value): with open(value, "rb") as f: raw = f.read() # If the file itself contains Base64 text, return it directly. try: raw_str = raw.decode("utf-8").strip() base64.b64decode(raw_str, validate=True) return raw_str except (UnicodeDecodeError, ValueError): pass # Otherwise, encode the binary file as Base64. if len(raw) > MAX_IMAGE_SIZE_BYTES: print(f"Error: Image exceeds the {MAX_IMAGE_SIZE_BYTES // (1024 * 1024)} MB limit", file=sys.stderr) sys.exit(1) encoded = base64.b64encode(raw).decode("utf-8") ``` The comments and error message above are translated into English for presentation; the executable behavior matches the audited source. ### Technical Analysis The code calls `f.read()` without a size argument, loading the complete user-selected file into memory before checking whether it exceeds `MAX_IMAGE_SIZE_BYTES`. The nominal 10 MB restriction therefore does not protect the process from memory exhaustion. The Base64-text branch also returns immediately after validating the encoding syntax. It does not enforce the decoded-size limit before returning, so an oversized Base64 document can bypass the intended input-size validation. This is an insecure resource-handling issue rather than evidence of covert exfiltration. The Base64 conversion itself is necessary for the declared Tencent Cloud OCR API and is not malicious. ### Attack Path 1. An attacker creates or identifies a file substantially larger than available process memory. 2. The attacker causes the Skill to be invoked with that path through `--image-base64`. 3. `os.path.isfile()` accepts the path. 4. `f.read()` attempts to load the entire file before the size check is reached. 5. The Python proc ...[truncated 899 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Check regular-file size with `os.stat()` before opening or reading it. 2. Reject files larger than the accepted encoded-input threshold. 3. Use a bounded read such as `f.read(MAX_IMAGE_SIZE_BYTES + 1)` and reject input when the additional byte is present. This protects against file-size changes between the metadata check and read operation. 4. For Base64 text, estimate and then verify decoded size before returning it. 5. Decode Base64 incrementally or with strict input limits to avoid simultaneously retaining large encoded and decoded copies. 6. Consider rejecting non-regular files to avoid blocking or unbounded reads from devices, pipes, and special files. 7. Catch `OSError`, `MemoryError`, and decoding errors and return a controlled failure. Example hardening pattern: ```python file_size = os.path.getsize(value) if file_size > MAX_ENCODED_INPUT_SIZE: raise ValueError("Input file is too large") with open(value, "rb") as file: raw = file.read(MAX_ENCODED_INPUT_SIZE + 1) if len(raw) > MAX_ENCODED_INPUT_SIZE: raise ValueError("Input file is too large") try: raw_str = raw.decode("ascii").strip() decoded = base64.b64decode(raw_str, validate=True) if len(decoded) > MAX_IMAGE_SIZE_BYTES: raise ValueError("Decoded image is too large") return raw_str except (UnicodeDecodeError, ValueError): pass ``` ]]>

T08 · Insecure Dependencies

Note
Location
SKILL.md:35
Finding
Tencent Cloud SDK installation instruction does not pin a reviewed version<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:35` **Vulnerability Type**: Unpinned third-party dependency **Risk Level**: Low ### Vulnerable Code ```bash pip install tencentcloud-sdk-python ``` ### Technical Analysis The documentation directs users to install the Tencent Cloud SDK without specifying a reviewed version or cryptographic hash. Although the package name is consistent with the declared vendor SDK and no typosquatting was identified, an unconstrained installation retrieves whichever release the package index currently resolves. Consequently, the code installed at deployment time can differ from the code reviewed during the Skill audit. This weakens reproducibility and creates supply-chain exposure if a future package release, maintainer account, package index, or dependency is compromised. The audited project does not automatically execute `pip`, fetch a remote payload itself, or include an intentionally malicious dependency. The risk arises from the documented installation procedure. ### Attack Path 1. A user follows the documented installation command. 2. `pip` resolves the latest available SDK and its transitive dependencies from the configured package index. 3. A compromised or malicious future release is selected because no version or hash constraint exists. 4. The package executes during installation or is imported when `scripts/main.py` runs. 5. Malicious package code executes with the privileges of the user running the installation or OCR Skill. This path depends on compromise of the package distribution chain, a malicious release, or an unsafe package-index configuration; no such compromise was observed in the audited files. ### Impact Assessment A compromised dependency could execute arbitrary Python code with the invoking user's privileges. Depending on those privileges, it could access Tencent Cloud credentials present in the environment, passport images supplied for OCR, local files readable by the user, and ...[truncated 181 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Add a dependency manifest that pins an explicitly reviewed Tencent Cloud SDK version. 2. Generate and verify cryptographic hashes for the package and all transitive dependencies, for example through a hash-locked requirements file. 3. Install only from an approved HTTPS package index. 4. Review release notes and security advisories before updating the pinned version. 5. Perform dependency updates through a controlled process that reruns static analysis and functional tests. 6. Prefer an isolated virtual environment with only the permissions needed for the OCR operation. A hardened installation workflow should resemble: ```bash python -m pip install --require-hashes -r requirements.lock ``` The lock file should contain exact versions and trusted hashes generated from reviewed artifacts. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Missing User Warnings

High
Confidence
97% confidence
Finding
The skill handles passport images and extracts identity attributes such as passport number, name, birth date, nationality, and MRZ data, but it does not warn users that this is highly sensitive personal data or that it will be sent to a third-party cloud OCR provider. Without a clear warning and consent flow, users may unknowingly expose regulated identity information, creating significant privacy, compliance, and misuse risks.

Lp3

Medium
Category
MCP Least Privilege
Confidence
85% confidence
Finding
The skill relies on environment-based secrets (`TENCENTCLOUD_SECRET_ID` and `TENCENTCLOUD_SECRET_KEY`) but does not declare any explicit tool scope or permissions boundary. In an agent setting, missing scope declarations can cause the skill to be invoked with broader-than-necessary ambient authority, increasing the chance of unintended secret access or unsafe composition with other capabilities.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger conditions include broad catch-all language like '涉及护照OCR识别的任何场景' and '涉及多国多地区护照识别的场景,' which makes the skill activate in ambiguous situations. Because this skill processes highly sensitive identity documents, overbroad activation can cause unnecessary collection, transmission, or extraction of passport data when a narrower or safer response would suffice.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
This skill transmits highly sensitive passport images and extracted identity data to Tencent Cloud OCR, but the code provides no explicit user-facing warning, consent check, or privacy notice at the point of transmission. Because passports contain government ID numbers, nationality, birth date, and potentially cropped face images, sending them to a third-party remote service without clear disclosure materially increases privacy, compliance, and data-handling risk.

Static analysis

No suspicious patterns detected.