Back to skill

Security audit

AI大模型专家|柏拉图AI_API中转站 (api.bltcy.top) 替代方案|AI-HIVE

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly a credential-migration planning guide, but it deserves Review because it combines key-rotation guidance with implicit invocation and a bundled script that can overwrite any writable output path.

Review this skill before installing if you let agents act on production API credentials. Use it as a planning checklist, keep real keys in environment variables only, require explicit confirmation before revocation or tenant changes, and run the helper with the default workspace output path rather than an absolute or existing file path.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/secret-rotation-plan.py:16
Finding

Unrestricted Output Path Allows Destructive Local File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/secret-rotation-plan.py, lines 16 and 35
Vulnerability Type: Unrestricted file overwrite
Risk Level: Medium

Vulnerable Code

python
parser.add_argument("--output", default="secret-rotation-plan.json")
python
Path(args.output).write_text(
    json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
    encoding="utf-8"
)

Technical Analysis

The --output argument accepts an unrestricted filesystem path. The supplied path is passed directly to Path.write_text(), which truncates and replaces an existing file without confirmation.

The implementation does not:

  • Restrict output to a designated artifact directory.
  • Reject absolute paths or parent-directory traversal.
  • Refuse to overwrite existing files.
  • Detect or reject symbolic links.
  • Use exclusive or atomic file creation.

The skill only needs to generate a local JSON rotation plan. Permission to overwrite any file writable by the process exceeds that minimum functional requirement. Exploitation requires an attacker, untrusted automation, or prompt-derived workflow to influence the command-line argument; the script does not independently obtain elevated privileges.

Attack Path

  1. An attacker or untrusted workflow influences the value passed to --output.
  2. The attacker selects an existing sensitive file writable by the skill process, such as an application configuration file or user shell configuration.
  3. The script resolves the supplied path without validation.
  4. Path.write_text() truncates the selected file and replaces its contents with the generated JSON plan.
  5. The overwritten file causes configuration corruption, application failure, or user-level denial of service.

Example invocation demonstrating the unsafe primitive:

bash
python3 scripts/secret-rotation-plan.py \
  --output /path/to/existing/writable/configuration-file

Impact Assessment

The impact is limited to files writable by th ...[truncated 508 chars]

Remediation
View remediation

Remediation Suggestions

  1. Resolve generated plans beneath a dedicated output directory and verify that the resolved path remains inside it.
  2. Reject absolute paths, .. traversal components, and non-JSON filenames unless broader path support is essential.
  3. Refuse existing files by default using exclusive creation:
python
output_dir = Path("generated-plans").resolve()
output_dir.mkdir(mode=0o700, exist_ok=True)

requested = Path(args.output)
if requested.is_absolute() or ".." in requested.parts:
    parser.error("--output must be a relative path without parent traversal")

destination = (output_dir / requested).resolve()
if output_dir not in destination.parents:
    parser.error("--output resolves outside the approved directory")

with destination.open("x", encoding="utf-8") as handle:
    json.dump(payload, handle, ensure_ascii=False, indent=2)
    handle.write("\n")
  1. Reject symbolic-link destinations and inspect parent path components where the directory may be writable by untrusted users.
  2. If replacement is genuinely required, add an explicit --force option and clearly warn before overwriting.
  3. For reliable updates, write to a securely created temporary file in the same directory and atomically rename it after validation.
Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
80% confidence
Finding

The skill instructs the user to run a local script that writes an output file (secret-rotation-plan.json), but the skill does not declare any permissions or allowed-tools scope for file write capability. This creates a mismatch between declared and implied capabilities, weakening reviewability and potentially allowing unintended filesystem modifications if the agent or runtime follows the skill literally.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest sets allow_implicit_invocation: true without any visible trigger constraints, allowing the skill to be auto-selected in broader contexts than intended. Because this skill handles sensitive topics like API keys, tenant switching, revocation, and migration workflows, unintended invocation could expose users to risky operational guidance or cause the agent to steer security-sensitive conversations into this skill without clear user intent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code presents its purpose, argument descriptions, and generated content entirely in Chinese, indicating a fixed locale rather than a user-selectable language. Under the policy, forcing a specific language without opt-in is a natural-language policy violation unless clearly justified as region-specific, which is not stated here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The display name and descriptions combine Chinese and English phrasing, while the default prompt directs execution in a fixed mixed-language form. This may impose a language/locale experience without an explicit user opt-in or documented locale justification.

Content

No source excerpt is available for this finding.