T09 · Insecure Skill Coding Practices
- Location
rules/layout.md:93- Finding
Automatic Execution of an Untrusted Course-Local Python Script
- Content
View full analysis
Vulnerability Details
File Location:
rules/layout.md:93
Related Entry:SKILL.md:54
Vulnerability Type: Execution of untrusted local code across the course-content trust boundary
Risk Level: HighComplete vulnerable snippet:
text 课程根真有 `管理/catalog.py` 时,在课程根只跑这两条:`python3 管理/catalog.py refresh`、`python3 管理/catalog.py verify`。失败就把输出报告给用户;不为过检去改名、搬动或删除任何不是本次写出的文件。verify 全绿只说明路径与哈希对得上,不说明链接能跳。脚本不存在就什么都不跑。The corresponding condensed instruction in
SKILL.md:54states:text 课程根真有 `管理/catalog.py` 才跑、只跑 refresh 与 verify。Technical Analysis
The Skill processes course directories whose documents and files may originate from course-material authors, shared-folder participants, or archive providers. It otherwise treats course materials as input data and contains several safeguards against following instructions embedded in those materials.
However,
rules/layout.md:93instructs the agent to discover and execute a Python file based only on its path and existence. It does not require inspection, provenance validation, ownership checks, an integrity check, or explicit confirmation from the user.Restricting the command-line arguments to
refreshandverifydoes not make execution safe. Python runs module-level statements before or independently of argument handling. A malicious管理/catalog.pycan therefore perform arbitrary actions as soon as the interpreter loads it.The project history reinforces that this behavior is intentional but not malicious:
CHANGELOG.md:54states that the course-root script is run as a user-local configuration command and that its contents are not audited. This confirms the reachable trust-boundary violation, but there is no evidence that the Skill author supplied a malicious payload or intended exploitation.Attack Path
- An attacker who can contribute to a course archive or shared course directory creates or replaces
<course>/管理/catalog.py. - The file contains malicious top ...[truncated 1485 chars]
- An attacker who can contribute to a course archive or shared course directory creates or replaces
- Remediation
View remediation
Remediation Suggestions
- Remove automatic execution based solely on the presence of
<course>/管理/catalog.py. - Implement the required refresh and verification operations inside the trusted Skill using constrained file APIs rather than executing course-provided code.
- If compatibility requires the external script:
- Require explicit user approval immediately before execution.
- Display the exact canonical script path and explain that it is executable code from the course directory.
- Inspect the complete script before execution and reject dynamic imports, subprocess execution, network access, and writes outside the authorized study directory.
- Validate provenance or integrity using a user-configured allowlist or pinned cryptographic digest.
- Reject symlinks and verify that the canonical path remains within the intended course root.
- Execute it in a sandbox with no network access, a minimal environment, no unrelated credentials, and write access limited to the authorized course output directory.
- Treat
SPEC.md,AGENTS.md, course PDFs, archives, and all course-local scripts as untrusted input unless the user explicitly establishes their trust. - Prefer a declarative catalog format over executable Python for local course metadata and verification settings.
- Remove automatic execution based solely on the presence of
