Back to skill

Security audit

Code Factory

Security checks for vulnerabilities and agentic risk

Overview

This is a real project-generation skill, but it needs Review because its unsafe templating and rollback behavior can run injected code or delete existing project folders.

Use this only in an isolated workspace with no sensitive environment variables. Do not point it at an existing project directory, and review generated Python and generated SKILL.md files before running tests or installing the generated skill.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
layers/asset_generator.py:243
Finding

Arbitrary Python Code Execution Through Unsafely Generated Source Code

Content
View full analysis
2000: raise ValueError(f"description 不能超过 2000 个字符") # 危险字符过滤(防止 shell 注入等) dangerous_chars = [";", "|", "$(", "`", "&&", "||", ">", "<", "&"] for char in dangerous_chars: if char in self.description: raise ValueError( f"description 包含危险字符: '{char}',可能存在注入风险" ) ``` `layers/asset_generator.py:243-250`: ```python def _generate_main_py(self, project_name: str, description: str) -> str: """生成主程序模板""" return f'''""" {project_name} — {description} """ import sys ``` `layers/verifier.py:217-229`: ```python env = os.environ.copy() existing_path = env.get("PYTHONPATH", "") env["PYTHONPATH"] = f"{target_dir}{os.pathsep}{existing_path}" if existing_path else str(target_dir) result = subprocess.run( [sys.executable, "-m", "pytest", str(test_dir), "-v", "--tb=short"], capture_output=True, text=True, cwd=isolated_cwd, timeout=60, env=env, ) ``` ### Technical Analysis The request validator attempts to prevent shell injection by rejecting a small list of shell metacharacters. That validation is not appropriate for data that is later interpolated directly into Python source code. The `description` value is inserted without escaping into a triple-quoted module docstring. Newlines, quotation marks, backslashes, and triple-quote sequences are not rejected or encoded. An attacker can therefore terminate the generated docstring, insert Python statements, and optionally reopen a string so the resulti ...[truncated 2100 chars]
Remediation
View remediation

T01 · Skill Instruction Hijacking

Error
Location
templates/skill_template.py:6
Finding

Generated SKILL.md Frontmatter and Instruction Injection

Content
View full analysis
str: return f"""--- name: {project_name} description: "{description}" allowed-tools: - read - write - edit - exec --- # {project_name} {description} ## 使用方法 直接运行 `python src/main.py` 或 `bash run.sh`。 ## 项目结构 见 ASSET_MANIFEST.md 获取完整资源地图。 """ ``` ### Technical Analysis The generated Skill document places the unescaped `description` in two security-sensitive contexts: 1. Inside a quoted YAML frontmatter value. 2. Directly in the Markdown instruction body. Because multiline input and quotation marks are accepted, an attacker can terminate the YAML value and introduce additional frontmatter keys or restructure the document. The same input is then repeated as unrestricted Markdown content, where it can present attacker-controlled directives as if they were part of the generated Skill. The generated file already declares the powerful `exec`, `write`, and `edit` tools. If another Agent later loads this generated Skill and treats its body as trusted instructions, injected content can alter that Agent's behavior or task goals. This is a generated-artifact vulnerability rather than evidence that the audited package itself contains a preinstalled malicious instruction. Exploitation depends on the generated `SKILL.md` subsequently being loaded by an Agent or Skill framework. ### Attack Path 1. An attacker supplies a multiline project description containing a closing quote and additional YAML or Markdown instructions. 2. Input validation accepts the content because quotation marks, colons, and newlines are not prohibited. 3. `generate_skill_md()` inserts the content directly into YAML frontmatter and the document body. 4. The generator writes the attacker-influenced `SKILL.md` into the ...[truncated 960 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
layers/orchestrator.py:299
Finding

Saga Compensation Recursively Deletes Pre-existing Project Directories

Content
View full analysis
None: if not target_dir.exists(): return created = tracker.get_created_files() for rel_path in created: file_path = target_dir / rel_path try: if file_path.is_file(): file_path.unlink() elif file_path.is_dir(): shutil.rmtree(file_path, ignore_errors=True) except OSError: pass if cleanup_subdirs: for subdir in ("src", "tests", "docs"): p = target_dir / subdir if p.exis ...[truncated 2668 chars]
Remediation
View remediation
Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (151)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description promises substantial functionality for scaffolding a full project and validating it by running tests. However, the supplied code chunk is merely a minimal init.py file with comments describing a data contract layer. It does not show any logic related to file generation, project scaffolding, test execution, or delivery control. This is a material mismatch in primary purpose and implemented capabilities.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description presents a broad end-to-end project scaffolding capability with validation through test execution. The supplied code chunk is much narrower: it implements data structures for asset manifest entries and formatting/export functions for ASSET_MANIFEST.md and manifest.json. This is related to one small part of the declared functionality (asset manifest support), but it does not perform the primary claimed behavior of generating a complete project structure or verifying it by running tests. Therefore the description does not accurately represent the actual behavior of this code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

There is a clear mismatch between the declared purpose and the actual code behavior. The description claims an end-to-end project scaffolding capability with file generation and test execution. However, this code chunk is limited to validating user input via dataclasses and schema checks. While input validation could be a supporting component of a project generator, this chunk by itself does not implement the declared primary functionality and instead serves a different, narrower purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents an active end-to-end project generator and verifier. However, the supplied code chunk is purely a data contract module defining StepStatus, StepResult, RetryOutput, and ProjectResult, plus helper methods for marking statuses and summarizing results. This is a supporting component for a larger system, not the described generator itself. Therefore the actual behavior is materially narrower and different from the declared primary purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

声明描述的是一个能够自动生成完整项目结构并运行测试验证后交付的技能。但提供的代码片段没有执行任何文件生成、项目搭建、测试运行、依赖处理或交付动作。它只是一个数据结构与状态管理层:保存各阶段输出、记录重试、提供线程安全读取、快照和重置。这不是对声明能力的实现细节,而是与声明的主要用途存在明显偏差。因此该描述不能准确代表此代码实际行为。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

Yes, this is a mismatch. The declared purpose promises substantial functionality: generating a full project structure and validating it by running tests before delivery. The supplied code chunk contains only comments in an init.py file and no executable logic related to generation, manifest creation, or testing. This is not merely an incomplete supporting detail; based on the supplied chunk alone, the actual behavior does not represent the declared primary purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

该代码确实与“生成项目结构/资产文件”这一大方向相关,且会生成 README、requirements、测试文件和 ASSET_MANIFEST,因此部分符合声明。但声明中的关键承诺“运行测试验证后才交付”在代码中完全没有体现:没有调用测试框架、没有执行 shell 命令、没有验证结果或交付门控逻辑。相反,代码主要职责是基于 spec 生成并暂存文件、做幂等性检查、记录副作用和输出清单。此外,它还生成多项声明未提及的文件(如 SKILL.md、environment.toml、run.sh、manifest.json 及源码模板),这些属于能力范围扩展。综合来看,描述与实际行为存在实质性不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description claims end-to-end automatic generation of a full project structure and test execution/validation before delivery. The supplied code only assembles a final response object containing the absolute project path, a preview of an existing README, a summary extracted from an existing ASSET_MANIFEST.md, a compact summary of an existing manifest.json, and a test summary derived from context.verification_report. It performs file reading and formatting, but no project generation, no requirements/test/manifest creation, and no test execution. This is a materially different primary purpose, so it should be flagged as a mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The code’s actual function is a preflight validation layer, not a project scaffolding or test-running implementation. It checks runtime prerequisites and filesystem conditions, which could be a supporting step for the declared workflow, but the supplied chunk by itself does not perform the main declared capabilities. Because the declared purpose emphasizes automatic generation of a full project structure and running tests before delivery, while this code only validates environment readiness, this is a material description-to-behavior mismatch for the supplied code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

声明强调的是“自动生成完整项目结构并测试验证后交付”,而该代码块的核心职责并不是生成完整项目,也不是最终交付控制,而是验证失败后的重试与修复编排。它会分析错误、选择修复策略、重新生成部分资产、再次验证,并在多次失败后写入 .learnings/ 诊断文件。这说明其主要用途是失败恢复与诊断记录,不是所声明的完整项目脚手架生成器。因此描述与实际代码行为存在实质性不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description promises end-to-end project scaffolding with concrete artifacts (README, requirements, tests, ASSET_MANIFEST) and test execution/verification before handoff. The supplied code only derives an internal SpecResult containing file specifications, dependencies, and acceptance criteria. It defines a standardized file structure, including some of the declared artifacts, but it does not create those files, populate their contents, execute any tests, or validate outputs. Its documented and actual role is an internal 'Spec derivation engine,' which is materially different from the declared delivery-oriented generator/validator behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description promises a concrete end-to-end capability: generating a full project scaffold and validating it by running tests before handoff. The actual code shown is merely an init.py docstring describing architectural intent for step handlers split from an orchestrator. There is no implementation of file generation, manifest creation, test execution, or verification logic. This is a material mismatch in primary purpose and capabilities, not just an incomplete supporting detail.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The declared description promises end-to-end generation of a complete project structure (README, requirements, tests, ASSET_MANIFEST) plus test execution/verification before delivery. However, this code chunk is narrowly scoped to Step 3 asset generation: it creates a transaction manager, calls AssetGenerator.generate(...), commits or rolls back, and returns generated files. There is no evidence here of generating the full set of project files or executing tests. While this may be a supporting component within a larger pipeline, the supplied chunk's actual behavior is materially narrower than the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description promises end-to-end project scaffolding and validation behavior. The actual code chunk is a small infrastructure component: an abstract base handler interface for workflow steps. It contains no logic for creating files, assembling project structure, generating manifests, or executing tests. This is a materially different primary purpose, so the description does not accurately represent the code.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description centers on code/project scaffolding generation plus test execution and validation before delivery. The supplied code chunk does neither generation nor test running. Its sole purpose is to run environment prechecks using a PreflightRunner, aggregate issues, and raise an error if prerequisites are not met. While preflight checks could be a supporting part of a larger system, this specific chunk's behavior is materially different from the declared primary purpose, so this is a description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The declared description presents the skill as an end-to-end project scaffolding tool that generates multiple artifacts and verifies them before delivery. This code chunk, however, is a narrow pipeline component focused on intelligent retry behavior after verification. It inspects context.verification_report and either returns a no-retry result or delegates to RetryController.retry with verifier, asset generator, tracker, and guard. While retrying failed verification may support the broader declared workflow, the actual behavior here is materially different from the declared primary purpose and omits the claimed generation functionality in this chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared description promises end-to-end project scaffolding and test validation before delivery. However, the supplied code chunk only performs environment snapshot assembly and validation. It neither creates files nor generates project structure, nor does it run tests. This is a materially different primary purpose rather than a mere supporting detail, so the description does not accurately represent the actual behavior of this code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The declared description promises full project scaffolding generation plus test execution/verification before delivery. However, this code chunk only performs specification derivation and validation for an intermediate pipeline step. There is no file generation, no manifest creation, no test execution, and no delivery logic. This is a materially different primary purpose rather than a mere supporting implementation detail, so it should be flagged as a mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

声明描述的是一个能自动生成完整项目结构、运行测试并在验证后交付的技能。但提供的代码块仅是 pipeline 的注册与元数据管理层:它定义 StepDefinition、各步骤的 commit 回调、STEP_REGISTRY,以及依赖合法性和循环依赖检查。代码没有生成 README、requirements、测试文件或 ASSET_MANIFEST,也没有执行测试、验证或最终交付,只是为这些步骤声明了名称和输出类型。这属于主功能显著不一致,而非单纯的底层支持实现细节。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明的核心用途是“自动生成完整项目结构”,重点在于生成 README、requirements、测试文件和 ASSET_MANIFEST,并在交付前完成测试验证。而实际代码并不生成任何项目文件或结构,也不负责交付流程;它仅执行验证工作。虽然“运行测试验证”与声明的后半部分部分一致,但这只是声明中的附属环节,而代码的主要职责是验证,包括依赖分析、HARD-GATE 检查和 pytest 执行。由于缺失了声明中的核心生成能力,且实际主功能明显转为验证审查,因此属于实质性描述不符。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description says this skill auto-generates a full project scaffold including README, requirements, tests, and ASSET_MANIFEST, and validates by running tests before delivery. The supplied code does none of that. Instead, it implements a failure-pattern learner that reads JSON records from a learnings directory, builds failure reports, detects repeated failures for project/step combinations, and generates recommendations. This is a materially different primary purpose and introduces undeclared behavior around historical failure analysis, while lacking the core declared behaviors of project generation and test execution.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

There is a clear mismatch between the declared description and the actual code. The description promises end-to-end project scaffolding and validation behavior, but the supplied code chunk is merely a placeholder/package file for middleware concerns and contains no logic for generating files, assembling a project structure, or executing tests. Its primary purpose appears to be organizing middleware infrastructure, which is materially different from the declared project-generation functionality.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个端到端项目生成与测试后交付的技能,而代码片段实际只是 middlewares/anti_corruption.py,一个用于步骤间输入输出校验的辅助组件。它定义了多个 validate_* 方法,检查字段存在性、类型、非空约束,以及少量安全检查(如 generated_files 路径穿越检测),并通过 ValidationResult 返回结果。虽然这些校验步骤名称与项目生成流水线相关,但代码本身不生成文件、不写 README、不创建 requirements/test/manifest、不运行测试,也不执行交付。因此其实际主用途与声明的核心能力存在明显不一致,应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

声明描述的是一个面向项目脚手架生成与测试验证的能力:创建 README、requirements、测试文件、ASSET_MANIFEST,并在交付前执行测试。而实际代码仅是 middlewares/circuit_breaker.py,提供执行保护机制,包括全局计时器、步骤超时、熔断状态机、失败计数和线程包装执行。它既没有创建任何项目文件结构,也没有运行测试、验证产物或交付项目。因此代码的主要目的与声明用途明显不符,属于实质性描述-行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The declared description is about automatic project scaffolding and verification of generated artifacts via tests. The supplied code instead implements execution-guard middleware for a processing pipeline: protected step execution, timeout/circuit-breaker behavior, structured failure reporting, and contract validation between steps. These are materially different purposes. There is no visible functionality for creating project files, assembling a project structure, generating manifests, or executing tests as part of delivery. Therefore the description does not accurately represent the code's actual behavior.

Content

No source excerpt is available for this finding.