Back to skill

Security audit

校招产品经理教练

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its resume-review purpose, but it has under-scoped handling of sensitive resume data and shipped legacy code that can fetch URLs or install packages at runtime.

Install only in a controlled environment. Use text input when possible; if using PDF/image OCR, assume the resume contents are sent to Tencent Cloud and verify TENCENTCLOUD_ENDPOINT is not overridden. Avoid invoking the legacy ocr_utils.py or llm_client.py helpers unless they are reviewed or removed, and preinstall pinned dependencies instead of allowing runtime pip installs.

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 (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/ocr_utils.py:63
Finding

Arbitrary URL Retrieval Enables Server-Side Request Forgery

Content
View full analysis

Vulnerability Details

File Location: scripts/ocr_utils.py, lines 63–72, 76–79, and 172–202
Vulnerability Type: Server-Side Request Forgery through unrestricted URL input
Risk Level: High

Vulnerable Code

python
def _download_image(url: str) -> str:
    """Download a network image to a temporary file and return its local path."""
    import urllib.request

    suffix = os.path.splitext(url.split("?")[0])[1] or ".jpg"
    if suffix.lower() not in (".jpg", ".jpeg", ".png", ".webp", ".bmp"):
        suffix = ".jpg"
    fd, tmp_path = tempfile.mkstemp(suffix=suffix)
    os.close(fd)
    urllib.request.urlretrieve(url, tmp_path)  # noqa: S310
    return tmp_path


def _detect_kind(path: str) -> str:
    """Determine the resource type from its extension."""
    lower = path.lower()
    if lower.startswith("http://") or lower.startswith("https://"):
        return "url"
python
def extract_resume_text(source: str, max_pdf_pages: int = 3) -> str:
    ensure_dependencies()
    secret_id, secret_key = validate_env()

    kind = _detect_kind(source)
    local_path = source

    if kind == "url":
        print(f"[INFO] Downloading network image: {source}")
        local_path = _download_image(source)
        kind = _detect_kind(local_path)

    if kind == "pdf":
        text = _ocr_pdf(local_path, secret_id, secret_key, max_pages=max_pdf_pages)
    elif kind == "image":
        text = _general_accurate_ocr(local_path, secret_id, secret_key)
    else:
        raise RuntimeError(f"Unsupported resume file type: {source}")

    if local_path != source and os.path.exists(local_path):
        try:
            os.remove(local_path)
        except OSError:
            pass

    if not text.strip():
        raise RuntimeError("OCR recognition result is empty.")
    return text.strip()

Technical Analysis

The legacy OCR utility accepts any HTTP or HT ...[truncated 2117 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove URL input support because the documented main workflow accepts local resume files and does not require arbitrary remote retrieval.
  • If remote input is necessary, require HTTPS and use a strict allowlist of approved domains.
  • Resolve the hostname before connecting and reject loopback, private, link-local, multicast, unspecified, and reserved IP ranges for both IPv4 and IPv6.
  • Repeat destination validation after every redirect and prevent HTTPS-to-HTTP downgrade.
  • Use explicit connection and read timeouts.
  • Stream responses while enforcing a strict byte limit rather than using unrestricted urlretrieve.
  • Validate the response MIME type and verify the actual image format before OCR processing.
  • Place temporary-file deletion in a finally block so exceptions cannot leave downloaded data on disk.
  • Apply outbound network restrictions at the process or container level to block metadata and private-network destinations.

T08 · Insecure Dependencies

Warning
Location
scripts/ocr_utils.py:26
Finding

Runtime Installation of Unpinned Third-Party Dependencies

Content
View full analysis

Vulnerability Details

File Location: scripts/ocr_utils.py, lines 26–58; scripts/llm_client.py, lines 28–40; scripts/requirements.txt, line 2
Vulnerability Type: Mutable dependency retrieval and execution at runtime
Risk Level: Medium

Vulnerable Code

python
def ensure_dependencies():
    """Ensure OCR dependencies are installed."""
    try:
        import tencentcloud  # noqa: F401
    except (ImportError, ModuleNotFoundError):
        print("[INFO] tencentcloud-sdk-python is not installed; installing...", file=sys.stderr)
        subprocess.check_call(
            [sys.executable, "-m", "pip", "install", "tencentcloud-sdk-python", "-q"],
            stdout=sys.stderr,
            stderr=sys.stderr,
        )

    try:
        import PIL  # noqa: F401
    except (ImportError, ModuleNotFoundError):
        print("[INFO] Pillow is not installed; installing...", file=sys.stderr)
        subprocess.check_call(
            [sys.executable, "-m", "pip", "install", "Pillow", "-q"],
            stdout=sys.stderr,
            stderr=sys.stderr,
        )

    try:
        import fitz  # noqa: F401
    except (ImportError, ModuleNotFoundError):
        print("[INFO] PyMuPDF is not installed; installing...", file=sys.stderr)
        subprocess.check_call(
            [sys.executable, "-m", "pip", "install", "PyMuPDF", "-q"],
            stdout=sys.stderr,
            stderr=sys.stderr,
        )

The same pattern appears in scripts/llm_client.py:

python
def ensure_dependencies():
    try:
        from tencentcloud.hunyuan.v20230901 import hunyuan_client, models  # noqa: F401
    except (ImportError, ModuleNotFoundError):
        subprocess.check_call(
            [
                sys.executable,
                "-m",
                "pip",
                "install",
                "tencentcloud-sdk-python-hunyuan",
                "-q",
...[truncated 2204 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove automatic pip installation from all runtime code.
  • Delete scripts/ocr_utils.py and scripts/llm_client.py if they are genuinely unused legacy components.
  • Install dependencies during a controlled build or deployment phase in an isolated environment.
  • Pin every direct and transitive dependency to an exact reviewed version.
  • Generate and enforce a hash-locked requirements file, such as by using pip-compile --generate-hashes.
  • Install only from an authenticated, approved package repository.
  • Disable dependency resolution from untrusted user or system pip configuration where feasible.
  • Run the Skill as an unprivileged account in a restricted environment with minimal filesystem and network access.
  • Add dependency vulnerability and integrity scanning to the release process.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/ocr_service.py:57
Finding

Environment-Controlled OCR Endpoint Can Redirect Sensitive Resume Data

Content
View full analysis

Vulnerability Details

File Location: scripts/ocr_service.py, lines 57–76, 81–90, and 107–116
Vulnerability Type: Unvalidated external-service endpoint override
Risk Level: High

Vulnerable Code

python
def _get_client():
    """Construct the OCR client."""
    try:
        from tencentcloud.common import credential
        from tencentcloud.common.profile.client_profile import ClientProfile
        from tencentcloud.common.profile.http_profile import HttpProfile
        from tencentcloud.ocr.v20181119 import ocr_client, models
    except ImportError:
        raise RuntimeError(
            "Missing tencentcloud-sdk-python dependency."
        )

    secret_id = os.getenv("TENCENTCLOUD_SECRET_ID")
    secret_key = os.getenv("TENCENTCLOUD_SECRET_KEY")
    if not secret_id or not secret_key:
        raise RuntimeError("Tencent Cloud credentials are not configured.")

    cred = credential.Credential(secret_id, secret_key)
    http_profile = HttpProfile()
    http_profile.endpoint = os.getenv(
        "TENCENTCLOUD_ENDPOINT",
        "ocr.tencentcloudapi.com",
    )
    client_profile = ClientProfile()
    client_profile.httpProfile = http_profile
    client = ocr_client.OcrClient(cred, "ap-guangzhou", client_profile)
    return client, models
python
def extract_resume_text(image_path: str, is_pdf: bool = False, pdf_page: int = 1) -> str:
    client, models = _get_client()
    req = models.GeneralAccurateOCRRequest()
    req.ImageBase64 = load_base64(image_path)
    if is_pdf:
        req.IsPdf = True
        req.PdfPageNumber = pdf_page
    try:
        resp = client.call_json("GeneralAccurateOCR", req._serialize())
python
def extract_resume_fields(image_path: str, pdf_page: int = 1) -> dict:
    client, models = _get_client()
    req = models.ExtractDocAgentRequest()
    req.ImageBase64 = load_base64(image_path)

Technic

...[truncated 1928 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove the endpoint override and hard-code the official Tencent Cloud OCR endpoint if no legitimate alternate destination is required.
  • If an override is operationally necessary, validate it against an exact allowlist of approved Tencent hostnames.
  • Reject IP literals, non-Tencent domains, user-information components, ports outside the expected service configuration, and malformed hostnames.
  • Ensure TLS certificate and hostname verification cannot be disabled.
  • Document precisely when resume data leaves the host and obtain explicit user consent before OCR upload.
  • Avoid inheriting sensitive service configuration from a broad, attacker-influenced environment.
  • Run OCR in an isolated process with a minimal environment and restricted outbound network access.
  • Use narrowly scoped Tencent credentials that permit only the required OCR operations.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/ocr_service.py:33
Finding

Base64 File Input Bypasses the Configured Size Limit

Content
View full analysis

Vulnerability Details

File Location: scripts/ocr_service.py, lines 33–53
Vulnerability Type: Improper input-size validation leading to resource exhaustion
Risk Level: Medium

Vulnerable Code

python
def load_base64(value: str) -> str:
    """Load Base64 file content from a path or direct Base64 string."""
    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
        if len(raw) > MAX_FILE_SIZE_BYTES:
            raise RuntimeError(
                f"File size exceeds "
                f"{MAX_FILE_SIZE_BYTES // (1024 * 1024)}MB limit"
            )
        return base64.b64encode(raw).decode("utf-8")
    try:
        decoded = base64.b64decode(value, validate=True)
        if len(decoded) > MAX_FILE_SIZE_BYTES:
            raise RuntimeError(
                f"File size exceeds "
                f"{MAX_FILE_SIZE_BYTES // (1024 * 1024)}MB limit"
            )
    except ValueError:
        raise RuntimeError(
            "Input is neither valid Base64 nor a valid file path"
        )
    return value

Technical Analysis

When value is a path to a file containing valid Base64 text, the function decodes the entire file only for validation and immediately returns raw_str. The return occurs before either the encoded file length or decoded payload length is compared with MAX_FILE_SIZE_BYTES.

The ordinary binary-file branch checks len(raw), and the direct Base64-string branch checks len(decoded). The valid-Base64-file branch therefore provides a deterministic bypass of the intended 10 MB limit. The implementation also reads the complete file into memory before applying any check.

Attack Path

  1. An a ...[truncated 994 chars]
Remediation
View remediation

Remediation Suggestions

  • Check the on-disk file size with os.path.getsize() before reading it.
  • Apply a conservative encoded-size limit before attempting Base64 decoding.
  • Decode the content once and verify the decoded byte length before every return path.
  • Avoid loading unbounded files entirely into memory; use bounded or streaming reads.
  • Enforce request-size limits again immediately before constructing the OCR request.
  • Add tests covering oversized binary files, oversized Base64 files, whitespace-heavy Base64, malformed Base64, and direct oversized Base64 strings.
  • Apply per-request time, memory, network, and OCR-quota limits at the service boundary.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (50)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/env_loader.py (reported line 7)May include surrounding context.

python
环境变量读取优先级(从高到低):
1. 系统环境变量(os.environ)
2. .env 文件 —— 从脚本所在目录逐级向上查找,找到的第一个生效

用法:
    from env_loader import validate_env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/env_loader.py (reported line 22)May include surrounding context.

python
环境变量读取优先级(从高到低):
1. 系统环境变量(os.environ)
2. .env 文件 —— 从脚本所在目录逐级向上查找,找到的第一个生效

用法:
    from env_loader import validate_env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/env_loader.py (reported line 39)May include surrounding context.

python
环境变量读取优先级(从高到低):
1. 系统环境变量(os.environ)
2. .env 文件 —— 从脚本所在目录逐级向上查找,找到的第一个生效

用法:
    from env_loader import validate_env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/env_loader.py (reported line 87)May include surrounding context.

python
环境变量读取优先级(从高到低):
1. 系统环境变量(os.environ)
2. .env 文件 —— 从脚本所在目录逐级向上查找,找到的第一个生效

用法:
    from env_loader import validate_env

Credential Access

High
Category
Privilege Escalation
Confidence
72% confidence
Finding

Automatically loading the first .env found while traversing up to five parent directories can cause the application to trust secrets from an unintended directory. In shared, multi-repo, or untrusted execution environments, an attacker who can place a crafted .env higher in the path may influence which credentials or settings are loaded.

Content

Scanner excerpt · scripts/env_loader.py (reported line 26)May include surrounding context.

python
try:
        current = os.path.dirname(os.path.abspath(__file__))
        for _ in range(5):
            env_path = os.path.join(current, ".env")
            if os.path.isfile(env_path):
                return env_path
            parent = os.path.dirname(current)

Credential Access

High
Category
Privilege Escalation
Confidence
75% confidence
Finding

Loading values from a discovered .env file into os.environ can let untrusted filesystem content control process configuration if the discovery path is not tightly constrained. Although existing environment variables are not overwritten, missing secrets or other settings may still be sourced from an attacker-controlled file in certain deployment contexts.

Content

Scanner excerpt · scripts/env_loader.py (reported line 60)May include surrounding context.

python
def _ensure_env_loaded() -> None:
    """将 .env 文件中的变量加载到 os.environ(不覆盖已有系统环境变量)。幂等。"""
    env_path = _find_env_file()
    if not env_path:
        return

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/rule_engine.py (reported line 593)May include surrounding context.

python
"""执行单条规则,未知规则类型返回 0 分。"""
    fn = RULE_REGISTRY.get(rule.get("type", ""))
    if fn is None:
        return RuleResult(0.0, ["未知规则类型,按 0 分处理"], f"规则 {rule.get('type')}")
    try:
        result = fn(rule, ctx)
    except Exception as exc:  # 规则异常不影响整体评分

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file contains user-facing skill documentation solely in Chinese, including the title, usage descriptions, and review conclusions. Under the policy rule for natural-language violations, forcing a specific language without user opt-in can be a locale policy issue when no alternative language option or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill is framed around a Chinese-language evaluation system for campus/intern internet product-manager recruiting and presents Chinese as the default operating language without explicit user opt-in. This is not a classic security flaw, but it can cause misleading evaluation, exclusion, or improper handling of non-Chinese resumes/JDs if users are not clearly told about the scope and language assumptions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly depends on external Tencent Cloud OCR services and requires cloud credentials, but the description does not clearly warn users that uploaded resumes and JDs may be transmitted to a third-party service. Because resumes and job descriptions commonly contain sensitive personal and employer information, this omission creates a meaningful privacy and consent risk rather than a purely cosmetic documentation issue.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The manifest says resume optimization uses automatic intent recognition and directly generates a new resume document, but it does not define clear activation boundaries, confirmation requirements, or trigger conditions. In a skill handling sensitive personal documents, ambiguous auto-trigger behavior can cause unintended modification flows, user confusion, or processing of content the user did not clearly consent to transform.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest declares OCR and document-extraction dependencies for processing resumes, which commonly contain highly sensitive personal data, but it does not disclose that content may be sent to external services. This creates a meaningful privacy and compliance risk because users may provide resumes expecting local-only handling while their personal information is processed by third-party providers.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The scene and note are written entirely in Chinese and define the skill specifically around a Chinese campus-recruiting interview context, which implies a fixed language/locale. Under the policy, locale-specific behavior should either be optional for the user or clearly justified as region-specific; this file does not provide that justification or opt-in mechanism.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The audience, note, category names, and all interview templates are written exclusively in Chinese, which effectively constrains the skill to a specific language. There is no indication that the user can opt into another language or that the file is intentionally limited to a Chinese-only regional use case.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JSON output embeds the verdict entirely in Chinese, indicating a fixed language choice in user-facing content. The file does not offer any language or locale opt-in, and no region-specific justification is documented, which matches the policy violation criteria for forced language/locale behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module docstring and later user-facing error output are written only in Chinese, indicating a fixed language choice for this skill component. Under the policy, forcing a specific language without user opt-in or a documented regional justification 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
95% confidence
Finding

When credentials are missing, the code prints operational guidance exclusively in Chinese. This is a user-facing language restriction with no opt-in or fallback, which violates the language/locale policy for general-purpose skills.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The top-level docstring is entirely in Chinese and describes the skill's behavior as a Chinese-language evaluation engine, with no indication that other languages are supported or that the user can opt into this locale. Under the policy, forcing a specific language without user choice is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This is a code file, so SQP-3 applies to natural-language strings embedded in the code. The module description and all generated report headings/content are hard-coded in Chinese, which imposes a specific language/locale without any visible user opt-in or documented region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This Python file is a code file, so SQP-3 applies to its natural-language content. The docstring and all generated interview question text are written exclusively in Chinese, with no indication that users can choose another language or that the locale restriction is justified, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Auto-installing dependencies expands the component's behavior beyond API access into environment mutation and subprocess execution. In a skill/agent setting this is more dangerous because importing or constructing the client can trigger package installation from the network without operator approval, increasing supply-chain exposure and violating least surprise.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The package installation happens automatically with no explicit consent, warning, or policy check. That can lead to unreviewed code being fetched and installed during normal use, which is risky in restricted or production environments and especially inappropriate for a helper client that users may not expect to alter the host.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
94% confidence
Finding

The code invokes pip via subprocess at runtime to install a package automatically. Although the command is not shell-injected and appears intended for convenience, it still executes an external package manager, modifies the environment, and trusts package resolution/network state at execution time, which creates supply-chain and unexpected code-execution risk in contexts that expect a simple API wrapper.

Content

Scanner excerpt · scripts/llm_client.py (reported line 35)May include surrounding context.

python
from tencentcloud.hunyuan.v20230901 import hunyuan_client, models  # noqa: F401
    except (ImportError, ModuleNotFoundError):
        print("[INFO] tencentcloud-sdk-python-hunyuan 未安装,正在安装...", file=sys.stderr)
        subprocess.check_call(
            [sys.executable, "-m", "pip", "install", "tencentcloud-sdk-python-hunyuan", "-q"],
            stdout=sys.stderr,
            stderr=sys.stderr,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The chat method transmits the full messages payload to Tencent Cloud's Hunyuan API over the network. The file describes the API call technically, but it does not clearly warn users that their conversation content will be sent to an external service, which is relevant to privacy and data handling.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The natural-language description, usage text, and user-facing CLI help throughout this file are exclusively in Chinese, indicating a fixed language/locale experience. The file does not offer an opt-in language choice or explain that the skill is intentionally limited to a Chinese-language audience or region-specific use case.

Content

No source excerpt is available for this finding.