Back to skill

Security audit

portrait-compare

Security checks for vulnerabilities and agentic risk

Overview

The skill does what it claims, but it processes sensitive face data with broad triggers, weak consent/privacy guidance, persisted outputs, and unverified model loading.

Install only if you are comfortable processing sensitive face images locally and can ensure the people in the photos are authorized for comparison. Prefer explicit user confirmation before each comparison, avoid relying on results as definitive identity proof, delete generated /tmp output images when no longer needed, and use pinned, checksum-verified ONNX models from a trusted location rather than /tmp or the current directory.

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/face_compare.py:24
Finding

Automatic Loading of Unverified ONNX Models from Mutable Locations

Content
View full analysis

Vulnerability Details

File Location: scripts/face_compare.py, lines 24–36 and 395–403
Vulnerability Type: Untrusted model loading from shared and working directories
Risk Level: Medium

Vulnerable Code

python
YUNET_MODEL_PATHS = [
    os.environ.get("YUNET_MODEL", ""),
    "/tmp/face_detection_yunet_2023mar.onnx",
    "./face_detection_yunet_2023mar.onnx",
    os.path.join(os.path.dirname(__file__), "face_detection_yunet_2023mar.onnx"),
]

SFACE_MODEL_PATHS = [
    os.environ.get("SFACE_MODEL", ""),
    "/tmp/face_recognition_sface_2021dec.onnx",
    "./face_recognition_sface_2021dec.onnx",
    os.path.join(os.path.dirname(__file__), "face_recognition_sface_2021dec.onnx"),
]
python
yunet = yunet_path or find_model_file(YUNET_MODEL_PATHS)
sface = sface_path or find_model_file(SFACE_MODEL_PATHS)

comparator = None
if yunet and sface:
    try:
        comparator = FaceCompareYuNetSFace(yunet, sface)
        print(f"✓ 使用方案A:YuNet + SFace(高精度模式)")
    except Exception as e:

Technical Analysis

The application automatically searches for and loads ONNX models from /tmp, the current working directory, environment-controlled paths, and the script directory. The find_model_file() validation only establishes that a candidate is a file; it does not verify its cryptographic hash, trusted ownership, permissions, canonical path, or provenance.

/tmp is normally shared and writable by multiple local users. The current working directory may also be controlled by the caller or another process. Consequently, a local attacker can pre-position files with the expected model names and cause OpenCV to parse them when the user does not supply explicit trusted model paths.

Although ONNX models are data rather than Python source code, a substituted model can manipulate facial recognition results. A malformed model also reaches OpenCV's native model parser, increasing exposure t ...[truncated 1434 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove shared /tmp and implicit current-working-directory locations from the automatic model search path.
  2. Store models in a dedicated application directory that is not writable by untrusted users.
  3. Pin approved SHA-256 hashes for both ONNX files and verify each model before passing it to OpenCV.
  4. Resolve each path with realpath and enforce that it remains inside an approved model directory.
  5. Reject symbolic links, non-regular files, files with unexpected ownership, and files writable by group or other users.
  6. Where environment variables or command-line paths remain supported, treat them as explicit trust decisions but still apply hash and file-security validation.
  7. Open files in a race-resistant manner where possible and avoid separate check-then-use operations on shared directories.
  8. Keep OpenCV current with security patches and return a hard failure rather than silently accepting an unverified high-accuracy model.

T08 · Insecure Dependencies

Note
Location
SKILL.md:58
Finding

ONNX Download Instructions Use Mutable Sources Without Integrity Verification

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 58–59
Vulnerability Type: Unpinned third-party model dependency
Risk Level: Low

Vulnerable Code

text
https://github.com/opencv/opencv_zoo/raw/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx
https://github.com/opencv/opencv_zoo/raw/main/models/face_recognition_sface/face_recognition_sface_2021dec.onnx

Technical Analysis

The documentation directs users to retrieve executable-runtime model artifacts from the mutable main branch of a third-party repository. It does not identify an immutable commit, release artifact, expected file size, or cryptographic checksum.

HTTPS protects the transport connection but does not ensure that the downloaded content remains identical to the version originally reviewed. If upstream content is replaced, the repository is compromised, or the referenced branch changes, users may receive unaudited model files that the script subsequently loads through OpenCV.

Attack Path

  1. The files referenced by the mutable main branch are changed or replaced, whether through legitimate upstream changes or compromise.
  2. A user follows the documented URLs and downloads the current files.
  3. Because no checksum or signature is provided, the user cannot automatically distinguish the changed artifacts from the reviewed versions.
  4. The files are placed in a model search location such as /tmp or the working directory.
  5. The script loads the changed models, allowing altered recognition behavior or malformed content to reach OpenCV's native parser.

Impact Assessment

The primary impact is supply-chain loss of integrity. A substituted model may manipulate comparison outcomes, cause processing failures, or trigger excessive resource consumption. If a malicious artifact can exploit a vulnerability in the installed OpenCV model parser, it would be processed with the privileges of the user running the ...[truncated 271 chars]

Remediation
View remediation

Remediation Suggestions

  1. Replace main-branch URLs with URLs pinned to a reviewed immutable commit or versioned release.
  2. Publish the expected SHA-256 checksum for each ONNX model.
  3. Add a mandatory checksum-verification step to the installation instructions and runtime loader.
  4. Prefer signed release artifacts when OpenCV provides them, and document signature verification.
  5. Record model versions, source commits, hashes, and review dates in a dependency manifest.
  6. Fail closed when a model does not match the approved hash rather than silently loading it or falling back without a clear integrity warning.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (6)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

This skill performs biometric face comparison on uploaded images but the description does not warn that the operation is privacy-sensitive or that face data may be used to infer identity similarity. Because biometric data is highly sensitive, lack of upfront notice and consent language increases the risk of unauthorized, unexpected, or non-compliant processing.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
81% confidence
Finding

The skill instructs use of shell/Python execution and access to uploaded files, but it does not declare an explicit tool/permission scope. That mismatch can allow broader-than-necessary runtime capabilities, weakening containment and making accidental or unsafe file/environment access harder to govern or audit.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger text is extremely broad and includes common phrasing like '帮我看看这两张照片是不是同一个人', plus '必须使用此 skill', which increases the chance of automatic invocation even when the user did not intend biometric processing. In a biometric context, unintended activation is risky because it may process sensitive face data without sufficiently explicit user consent or contextual checks.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file contains user-facing natural language exclusively in Chinese, and there is no indication that the skill is region-specific or that users can opt into this locale. Under the policy criteria, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This file includes its primary description, CLI help text, status messages, and result labels exclusively in Chinese. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is clearly justified, which is not present here.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

This skill processes biometric face images and can generate a persisted comparison image containing facial data and inferred identity similarity, but it provides no explicit privacy warning, consent guidance, retention notice, or safeguards around output handling. In the context of a face-comparison skill used for identity verification, this increases the risk of unauthorized biometric processing, accidental disclosure, and non-compliant storage of sensitive personal data.

Content

No source excerpt is available for this finding.