Back to skill

Security audit

Python Code Tester

Security checks for vulnerabilities and agentic risk

Overview

This code-testing skill is not clearly malicious, but it needs Review because it can scan too broadly, run generated tests, install packages, and direct project code changes without clear consent boundaries.

Install only if you are comfortable running it in an isolated project environment. Review the package list before any pip install, run generated tests in a disposable virtual environment or container, and do not let it update real source files without reviewing a diff and confirming the exact target project path.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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 (2)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/main.py:18
Finding

Recursive Source Scan Escapes the Intended Project Boundary

Content
View full analysis
list: """搜索与关键词相关的代码""" results = [] py_files = list(project_root.glob("**/*.py")) py_files = [f for f in py_files if ".opencode" not in str(f) and "skill" not in f.name.lower()] priority_score = { "def ": 3, "class ": 3, "async def ": 3, "import ": 1, "from ": 1, } for py_file in py_files: try: content = py_file.read_text(encoding="utf-8") ``` ```python results = search_code(keywords, PROJECT_ROOT) ``` ### Technical Analysis `main.py` is located under `artifact/scripts/`. Evaluating `Path(__file__).parent.parent.parent` therefore selects the directory containing `artifact`, rather than the Skill directory or a project directory explicitly authorized by the user. The program then recursively enumerates every Python file beneath that broader directory and reads each matching file. The only exclusions are paths containing `.opencode` and filenames containing `skill`; these filters do not establish a security boundary and do not prevent access to sibling projects. Search results include matching source lines and may select the highest-priority match as the test target. Consequently, source code outside the intended project can be read, displayed, and incorporated into generated test artifacts. ### Attack Path 1. Place or identify a sibling project under the parent directory selected by `PROJECT_ROOT`. 2. Invoke the Skill with a requirement or keyword matching a function, class, import, or source line in that sibling project. 3. `glob("**/*.py")` recursively discovers the sibling file. 4. `read_text()` re ...[truncated 836 chars]
Remediation
View remediation
bool: try: path.resolve().relative_to(project_root) return True except ValueError: return False py_files = [ path for path in project_root.rglob("*.py") if is_within_project(path) ] ``` ]]>

T08 · Insecure Dependencies

Warning
Location
scripts/main.py:374
Finding

Automatic Installation of Unpinned Third-Party Dependencies

Content
View full analysis
=7.0.0 # 数据处理 numpy>=1.21.0 pandas>=1.3.0 ``` ### Technical Analysis The setup script installs dependencies automatically, and the Python program repeats installation when it interprets a test failure as a missing-module condition. The requirements specify only minimum versions, without exact pins or package hashes. As a result, each installation may resolve to different current or future releases, including transitive dependencies that were not reviewed during this audit. Python package installation can execute package build or installation hooks with the privileges of the invoking user. No typosquatted package name, malicious package, custom package index, or confirmed compromised dependency was found. The risk arises from automatic installation and unconstrained dependency resolution rather than from evidence that the currently named packages are malicious. ### Attack Path 1. A user runs `scripts/run.sh`, or a generated test fails with a missing-module error and triggers `install_requirements()`. 2. The program invokes `pip install` using the environment's configured package index. 3. Pip resolves any versions satisfying the broad minimum constraints, along with their tran ...[truncated 840 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (24)

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding

整体上,此代码与“搜索代码、生成测试用例、执行测试”这一描述基本一致,但存在两处关键偏差。第一,代码在测试失败且检测到缺少模块时,会调用 subprocess 执行 pip install -r requirements.txt,这属于会修改运行环境的能力,声明中未体现。第二,声明强调“执行测试并修复问题”,甚至代码注释也写有“尝试修复问题”,但实际 main 流程并未基于测试结果自动改写目标业务代码;analyze_and_fix 只生成文本建议,update_project_code 虽存在却未在主流程中调用,因此“修复”能力被明显高估。故应判定为描述与实际行为存在不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

从给出的代码片段看,run.sh 的功能是创建若干目录(log、release、references)、安装 requirements.txt 依赖,并输出后续使用 main.py 的命令示例。它本身不包含任何根据需求搜索代码、生成测试用例、运行测试或自动修复问题的实现。因此,代码实际行为与声明用途存在实质性不一致。虽然这可能是技能的安装脚本而非主体逻辑,但依据所提供代码片段进行评估,当前可见行为的主要目的属于初始化部署,不是声明中的测试执行能力。

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The instruction to update actual project files after attempted fixes creates a direct path from generated test results to live source-code modification, with no mandatory review, backup, or rollback safeguard. In this context, an agent could corrupt production code, introduce insecure fixes, or apply attacker-shaped changes derived from untrusted inputs or flawed tests.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The function can overwrite source files and create backups without an explicit confirmation barrier or transactional safety checks. In a code-testing skill operating on user projects, silent source modification can corrupt code, enable malicious tampering if upstream inputs are compromised, and make rollback difficult.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill directs code search, file creation/modification, network downloads, and test execution, but it does not declare any explicit tool scope or permissions boundaries. In practice this can let an agent use powerful file, shell, and network capabilities without transparent restriction, increasing the chance of unsafe code execution, data exfiltration, or unintended workspace modification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill instructs writing test artifacts, logs, release versions, and updating project code, but provides no safety warning or approval checkpoint before modifying repository contents. In a codebase context, this can overwrite files, introduce faulty changes, or persist attacker-influenced content generated from untrusted inputs.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill tells the agent to download external datasets from the network without any notice about privacy, provenance, licensing, or supply-chain risk. That can expose sensitive context through outbound requests and introduce malicious or untrusted data into the testing workflow.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill's testing scope does not justify silently expanding into dependency installation, especially from repository-controlled requirements. In context, this broadens the attack surface from test execution to package installation and supply-chain compromise, which is a significant security risk.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
90% confidence
Finding

The script automatically runs pip install -r on a local requirements file when tests fail due to missing modules. Installing dependencies from project-controlled requirements can execute arbitrary code through package installation hooks or pull malicious packages, so this is a code-execution and supply-chain risk.

Content

Scanner excerpt · scripts/main.py (reported line 379)May include surrounding context.

python
req_file = SCRIPTS_DIR / "requirements.txt"
    if req_file.exists():
        try:
            subprocess.run(["pip", "install", "-r", str(req_file)], check=True)
            return True
        except subprocess.CalledProcessError:
            return False

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
92% confidence
Finding

The skill generates a Python test file from user-controlled requirement text and inferred code metadata, writes it to disk, and then executes it with pytest via subprocess. This creates a direct path from untrusted input to code execution, which is dangerous in a testing skill because the generated file can contain attacker-influenced Python and pytest will also execute import-time code in the target module.

Content

Scanner excerpt · scripts/main.py (reported line 400)May include surrounding context.

python
}
    
    try:
        proc = subprocess.run(
            ["python", "-m", "pytest", str(test_file), "-v", "--tb=short"],
            capture_output=True,
            text=True,

Tainted flow: 'test_file' from pathlib.Path.read_text (line 554, file read) → subprocess.run (code execution)

Medium
Category
Data Flow
Confidence
95% confidence
Finding

This tainted flow is real: the tool writes a test file derived from user input and repository content, then executes that file with pytest. In this skill context, that means an attacker can potentially steer generated test code or target imports into arbitrary code execution, making the testing feature substantially more dangerous than a normal subprocess call.

Content

Scanner excerpt · scripts/main.py (reported line 400)May include surrounding context.

python
}
    
    try:
        proc = subprocess.run(
            ["python", "-m", "pytest", str(test_file), "-v", "--tb=short"],
            capture_output=True,
            text=True,

Tainted flow: 'log_file' from pathlib.Path.read_text (line 572, file read) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/main.py (reported line 448)May include surrounding context.

python
def save_log(result: dict, version: int):
    """保存测试日志"""
    log_file = LOG_DIR / f"test_log_v{version}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
    with open(log_file, "w", encoding="utf-8") as f:
        json.dump(result, f, ensure_ascii=False, indent=2)
    return log_file

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest says the skill will '执行测试并修复问题', and the module docstring repeats that it will '尝试修复问题'. In practice, failure handling only analyzes error text, prints fix suggestions, and writes test artifacts to a release directory; the only real code-modification routine (update_project_code) is never invoked from main, so the advertised repair behavior is not actually carried out.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

When tests fail due to missing modules, the script attempts dependency installation after only a status message, without informed consent or review of what will be installed. In a skill that operates on arbitrary codebases, that can trigger untrusted package installation and code execution unexpectedly.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring, CLI descriptions, and user-facing output are entirely in Chinese, which imposes a specific language on users without opt-in or alternative locale support. This is a natural-language policy issue because the skill does not offer any language selection or document a justified locale restriction.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The tool creates or overwrites a test file on disk as part of execution. While it prints the save path afterward, there is no advance disclosure in the CLI help, docstring, or prompt that running the tool will modify the filesystem by creating generated test artifacts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The file contains natural-language comments entirely in Chinese, which imposes a specific language context without indicating user choice or a documented region-specific reason. This can violate language/locale policy when the skill does not offer opt-in or alternatives.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
94% confidence
Finding

Using pytest>=7.0.0 leaves dependency resolution open to newer releases, reducing build reproducibility and making it hard to verify whether a vulnerable version is installed. In a testing skill that may execute code automatically, dependency drift can introduce unsafe or compromised versions into the environment.

Content

Scanner excerpt · scripts/requirements.txt (reported line 4)May include surrounding context.

text
# 代码功能测试 Skill 依赖

# 测试框架
pytest>=7.0.0

# 数据处理
numpy>=1.21.0

Unverifiable Dependency: pytest has 2 known advisory(ies) (CVE-2025-71176 (pytest has vulnerable tmpdir handling); CVE-2025-71176 (pytest has vulnerable tmpdir handling)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
88% confidence
Finding

Pytest has known advisories, and because the dependency is not pinned, it is impossible to tell from this manifest whether a safe or affected version will be installed. In a skill that executes tests, this uncertainty directly increases operational exposure if vulnerable pytest behavior is present.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

Using numpy>=1.21.0 permits installation of many possible versions, which weakens supply-chain control and prevents reproducible builds. Because this skill handles code testing and data processing, an unreviewed dependency update could affect both safety and execution integrity.

Content

Scanner excerpt · scripts/requirements.txt (reported line 7)May include surrounding context.

text
pytest>=7.0.0

# 数据处理
numpy>=1.21.0
pandas>=1.3.0

Unverifiable Dependency: numpy has 16 known advisory(ies) (CVE-2014-1859 (Numpy arbitrary file write via symlink attack); CVE-2021-41495 (NumPy NULL Pointer Dereference); CVE-2021-33430 (NumPy Buffer Overflow (Disputed)) +13 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
90% confidence
Finding

NumPy has multiple known advisories, and the unpinned requirement prevents verification that deployed instances avoid affected releases. This matters more in a code-testing skill because the package may process untrusted test data and runs within an execution-capable environment.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

Using pandas>=1.3.0 allows uncontrolled future versions, making it unclear what code will actually run at install time. This creates a supply-chain risk and complicates determination of whether deployed environments are exposed to known package flaws.

Content

Scanner excerpt · scripts/requirements.txt (reported line 8)May include surrounding context.

text
# 数据处理
numpy>=1.21.0
pandas>=1.3.0

Unverifiable Dependency: pandas has 1 known advisory(ies) (CVE-2020-13091 (** DISPUTED ** pandas through 1.0.3 can unserialize and execute commands from an)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
84% confidence
Finding

Pandas has at least one known advisory, and the absence of pinning means the manifest cannot prove whether the installed version is vulnerable or safe. While the cited risk may depend on unsafe deserialization usage, the package version uncertainty still represents a real supply-chain hygiene issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This shell script uses Chinese-only natural-language strings in comments and user-facing output, including setup messages and usage instructions. Because the file does not offer a language choice or explain that the skill is intentionally limited to Chinese users, it conflicts with the language/locale policy criteria.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.