Back to skill

Security audit

jar冲突检测器

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent dependency-conflict scanner, but it automatically runs Maven or Gradle project build logic, including repository-provided Gradle wrappers, without clear isolation or informed opt-in.

Install only if you intend to run dependency analysis on projects you trust, or if you can run it in a disposable sandbox/container with no secrets, limited filesystem access, and controlled network access. Avoid pointing it at untrusted Maven or Gradle repositories unless live build execution is disabled or isolated, and treat generated HTML reports as untrusted content.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/detect_conflicts.py:198
Finding
Untrusted Maven and Gradle Projects Can Execute Arbitrary Build Logic During Scanning<![CDATA[ ## Vulnerability Details **File Location**: `scripts/detect_conflicts.py:198-204` and `scripts/detect_conflicts.py:247-257` **Vulnerability Type**: Execution of untrusted project build logic **Risk Level**: High ### Vulnerable Code ```python result = subprocess.run( [mvn_cmd, "dependency:tree", "-DoutputType=text", "--batch-mode", "-q"], cwd=project_dir, capture_output=True, text=True, timeout=300 ) ``` ```python gradle_cmd = "gradlew.bat" if os.name == "nt" else "./gradlew" gradle_path = project_dir / gradle_cmd if not gradle_path.exists(): gradle_cmd = "gradle" try: result = subprocess.run( [str(gradle_path) if gradle_path.exists() else gradle_cmd, "dependencies", "--configuration", "compileClasspath"], cwd=project_dir, capture_output=True, text=True, timeout=300 ) ``` ### Technical Analysis The scanner executes Maven or Gradle inside the project being audited. Although arguments are passed as an array and therefore do not introduce conventional shell command injection, the build system itself is an executable-code boundary. A Maven project can execute attacker-controlled logic through build extensions, plugins, lifecycle behavior, and configuration loaded from the repository or environment. A Gradle project is especially dangerous because Gradle build scripts are executable programs. In addition, the scanner directly executes the repository-provided `gradlew` or `gradlew.bat` wrapper without validating its content or provenance. The requested tasks, such as `dependency:tree` and `dependencies`, do not guarantee safety. Build initialization and configuration happen before or while those tasks run, allowing malicious project code to execute even if the requested task appears read-only. The five-minute timeout only limits execution duration. It does not restrict filesystem access, subprocess creation, credential access, or network communication. ### Attack Path ...[truncated 1443 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Make static parsing the default for repositories that have not been explicitly trusted. 2. Require explicit, informed user confirmation before executing any project build command. 3. Clearly warn that Maven and Gradle build evaluation can execute arbitrary repository-controlled code. 4. Never execute a repository-provided Gradle wrapper without verification. Validate the wrapper scripts and wrapper JAR against an approved checksum or use a trusted, externally installed Gradle distribution. 5. Run live dependency resolution in a disposable sandbox or container with: - A read-only project mount where feasible. - No access to host credentials, SSH agents, cloud metadata, or sensitive environment variables. - A temporary isolated home directory. - Network access disabled unless dependency resolution explicitly requires it. - Strict CPU, memory, process, and execution-time limits. - A non-privileged operating-system identity. 6. Prevent the sandbox from accessing host Maven and Gradle credential files such as `~/.m2/settings.xml` and Gradle user-home secrets. 7. Document that live build analysis must not be used directly on untrusted repositories outside an isolation boundary. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/detect_conflicts.py:532
Finding
Unescaped Project Metadata Allows Stored HTML Injection in Generated Reports<![CDATA[ ## Vulnerability Details **File Location**: `scripts/detect_conflicts.py:532-539` and `scripts/detect_conflicts.py:571` **Vulnerability Type**: Stored HTML injection **Risk Level**: Medium ### Vulnerable Code ```python conflict_rows += f""" <tr> <td><span style="background:{badge_color};color:white;padding:2px 8px;border-radius:4px;font-size:12px">{c.severity}</span></td> <td><code>{c.artifact_key}</code></td> <td>{type_label}</td> <td><small>{', '.join(c.versions[:4])}</small></td> <td><small>{', '.join(c.modules[:3])}</small></td> <td><small>{c.suggestion}</small></td> </tr>""" ``` ```python <p>Spring Boot microservice project · {result.project_dir} · {result.scan_time}</p> ``` ### Technical Analysis The HTML report generator interpolates dynamic values directly into HTML without context-appropriate escaping. Relevant values include: - `c.artifact_key` - Dependency versions in `c.versions` - Module names in `c.modules` - `c.suggestion` - `result.project_dir` Artifact identifiers, versions, and module names may originate from project-controlled POM files or build-tool output. A malicious repository can therefore place HTML markup into values that eventually reach a generated conflict row. The attacker can ensure that such data is included in the report by defining multiple versions of an artifact or constructing metadata that triggers a known incompatibility rule. Because the values are inserted as raw markup, injected tags and event handlers can alter the report or execute script in environments that permit active content in local HTML files. The report also lacks a Content Security Policy that could reduce the effect of successful injection. ### Attack Path 1. An attacker creates a project containing crafted dependency or module metadata with an HTML payload. 2. The attacker defines conflicting versions or an incompatible dependency combination so the ...[truncated 1181 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Escape every dynamic value before inserting it into HTML: ```python from html import escape artifact = escape(c.artifact_key, quote=True) versions = escape(", ".join(c.versions[:4]), quote=True) modules = escape(", ".join(c.modules[:3]), quote=True) suggestion = escape(c.suggestion, quote=True) project_dir = escape(result.project_dir, quote=True) ``` 2. Use only the escaped values in the generated markup. 3. Prefer a templating system with automatic HTML escaping if report generation becomes more complex. 4. Add a restrictive Content Security Policy, for example: ```html <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src 'none'; script-src 'none'; connect-src 'none'"> ``` 5. Avoid adding inline event handlers or dynamically generated script content to the report. 6. Add regression tests containing characters and payloads such as `<`, `>`, `&`, `"`, `'`, `<img onerror=...>`, and `</td>` in dependency and module metadata. 7. Treat build-tool output and repository metadata as untrusted even when the project is local. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (11)

Hidden Instructions

High
Category
Prompt Injection
Content
**解决方案:**
```xml
<!-- 在父 POM 的 dependencyManagement 中统一版本 -->
<dependencyManagement>
  <dependencies>
    <dependency>
Confidence
70% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Context-Inappropriate Capability

High
Confidence
100% confidence
Finding
The skill explicitly runs project-provided Gradle tooling for analysis, which lets a malicious repository execute arbitrary build logic during what should be a read-only scan. In this skill context, the danger is elevated because users will point it at untrusted source trees and expect dependency inspection, not code execution.

Lp3

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding
The skill instructs running a local Python script and dependency-inspection shell commands, and it also generates report files, but it does not declare any explicit tool scope such as allowed-tools or permissions. That omission weakens least-privilege boundaries and can lead to unintended shell execution or file creation in the user's environment without clear policy constraints.

Vague Triggers

Medium
Confidence
91% confidence
Finding
The trigger description includes broad phrases like any request involving Maven/Gradle dependency resolution issues in a Java/Spring Boot project, which can cause the skill to activate in situations where the user did not intend local project scanning or shell-based analysis. Over-broad triggering increases the chance of unnecessary command execution and file generation, especially when combined with undeclared tool scope.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
This file contains extensive user-facing natural language in Chinese, including incompatibility descriptions, suggestions, CLI help, console output, and HTML metadata, while providing no option to select another language. That can violate the policy against forcing a specific language or locale without user opt-in.

Context-Inappropriate Capability

Medium
Confidence
87% confidence
Finding
Running Maven for dependency resolution introduces executable build behavior and side effects that are broader than parsing manifests. Although less risky than invoking a project-local Gradle wrapper, it still processes untrusted project configuration and can perform network access or trigger unsafe plugin-related behavior in an analyst environment.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
"""Run mvn dependency:tree and capture output."""
    mvn_cmd = "mvn"
    try:
        result = subprocess.run(
            [mvn_cmd, "dependency:tree", "-DoutputType=text", "--batch-mode", "-q"],
            cwd=project_dir,
            capture_output=True,
Confidence
93% confidence
Finding
This subprocess invocation executes Maven against an untrusted repository. While the command is fixed and not shell-injected, Maven dependency resolution can trigger plugin behavior, read project configuration, and perform network/file access, so analyzing a hostile project can cause unintended code execution or other side effects beyond passive inspection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
gradle_cmd = "gradle"

    try:
        result = subprocess.run(
            [str(gradle_path) if gradle_path.exists() else gradle_cmd,
             "dependencies", "--configuration", "compileClasspath"],
            cwd=project_dir,
Confidence
99% confidence
Finding
This subprocess call may execute ./gradlew from the target project, which is code supplied by the scanned repository. Running a project-provided wrapper is effectively arbitrary code execution in the analyst's environment and exceeds the narrow purpose of dependency conflict detection.

Natural-Language Policy Violations

Low
Confidence
77% confidence
Finding
The skill is presented primarily in Chinese for headings and user-facing guidance, while some operational text is in English, but it never states that the response language should follow user preference. This can violate language-choice policy if the skill implicitly defaults to a language without opt-in or explicit flexibility.

Missing User Warnings

Low
Confidence
91% confidence
Finding
The skill directs the agent to run local inspection commands and create report files but does not explicitly warn the user that shell commands will be executed against their project and that artifacts will be written to disk. This can surprise users, create unwanted files, and expose project metadata through generated reports if execution occurs without informed consent.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
This markdown file uses Chinese from the title onward and does not indicate that the language choice is optional or region-specific. Under the natural-language policy rule, forcing a specific language without user opt-in can be a locale policy violation.

Static analysis

No suspicious patterns detected.