Back to skill

Security audit

bearing search skill

Security checks for vulnerabilities and agentic risk

Overview

The bearing lookup skill is mostly on-topic, but its search script looks for model data outside the reviewed skill package, so results can depend on unreviewed local JSON files.

Review this before installing if you expect a self-contained skill: the script should be fixed to read a packaged skill-local data directory and the missing model/brand databases should be included or documented. Also expect Chinese-only output and more limited behavior than the description suggests.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/search_model.py:16
Finding

Out-of-Scope Model Data Access Due to Incorrect Path Resolution

Content
View full analysis

Vulnerability Details

File Location: scripts/search_model.py, lines 16–36
Vulnerability Type: Improper filesystem scope and path resolution
Risk Level: Medium

Vulnerable Code

python
def get_data_dir():
    """获取数据目录路径"""
    # 如果在 skill 目录中运行,向上找到项目根目录
    script_dir = Path(__file__).resolve().parent
    skill_dir = script_dir.parent
    project_dir = skill_dir.parent.parent.parent
    return project_dir / "data"


def load_all_models():
    """加载所有型号数据"""
    data_dir = get_data_dir()
    models_dir = data_dir / "models"

    all_models = []
    if models_dir.exists():
        for json_file in models_dir.glob("*.json"):
            try:
                with open(json_file, 'r', encoding='utf-8') as f:
                    data = json.load(f)
                    if 'models' in data:
                        all_models.extend(data['models'])

Technical Analysis

The script intends to locate the bearing database relative to the Skill directory. However, it traverses three parent directories above skill_dir:

python
project_dir = skill_dir.parent.parent.parent

In the audited deployment layout, the script is stored at:

text
/tmp/.../artifact/scripts/search_model.py

Therefore, skill_dir resolves to /tmp/.../artifact, while traversing three additional parents resolves project_dir to the filesystem root, /. The resulting data directory is consequently:

text
/data/models

This contradicts the Skill documentation, which describes a Skill-local data/models/ directory. The script then enumerates and opens every *.json file in the external /data/models directory using the privileges of the running agent process.

No path-containment check verifies that the resolved database remains inside the Skill package. No schema or type validation is applied before external model fields are consumed and displayed. As a result, model se ...[truncated 1602 chars]

Remediation
View remediation

Remediation Suggestions

Resolve the database directly beneath the Skill root rather than traversing above it:

python
def get_data_dir():
    skill_dir = Path(__file__).resolve().parent.parent
    data_dir = (skill_dir / "data").resolve()

    if not data_dir.is_relative_to(skill_dir):
        raise RuntimeError("Data directory is outside the Skill root")

    return data_dir

Additional hardening measures should include:

  1. Package the documented data/models/ directory with the Skill.
  2. Resolve and validate every model file before opening it, ensuring it remains beneath the expected models directory.
  3. Reject symlinked model files if symlinks are not explicitly required.
  4. Validate each JSON document against a strict schema, including required keys and expected value types.
  5. Place limits on file size, record count, string length, and nesting depth to reduce resource-exhaustion risk.
  6. Sanitize or escape non-printable terminal control characters before displaying external string values.
  7. Fail closed with an explicit configuration error when the packaged database directory is missing rather than silently consulting an unintended external location.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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
Findings (6)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

代码的核心功能与声明的一部分相符:它确实会解析型号字符串(如分离后缀、推断内径)并在本地 models JSON 数据中搜索轴承型号,输出尺寸、载荷、转速和品牌对照等信息。但声明描述的是一个更完整的“轴承型号和品牌搜索与解析工具”,明确包含四类能力,其中第(2)品牌及其产品线搜索、第(4)选型建议和应用场景匹配在代码中没有体现。代码也没有任何品牌库检索、产品线枚举、规则化推荐或场景匹配逻辑。因此描述对能力范围有明显夸大,属于描述与实际行为不完全一致的情况。未发现额外危险或越权行为;不匹配主要在于声明功能多于实际实现。

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The description says the skill triggers whenever the user asks about bearing models, brands, specifications, or selection questions, but it does not define specific trigger phrases, scope limits, or exclusion conditions. This can overlap with general technical or purchasing conversations about bearings and may cause unintended invocation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file is entirely written in Chinese and provides no indication that language selection is optional or that the content is intended only for a Chinese-speaking or region-specific audience. Under the policy rule, forcing a specific language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This markdown file presents all instructional content in a single language and does not mention any language selection, translation option, or intended locale scope. Under the policy rule for language or locale constraints, forcing a specific language without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language strings that present usage instructions exclusively in Chinese, and additional user-facing output throughout the script also uses only Chinese. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified.

Content

No source excerpt is available for this finding.