Back to skill

Security audit

junit-test-generator

Security checks for vulnerabilities and agentic risk

Overview

This skill has a coherent JUnit test-generation purpose, but it generates project files and executable Java tests from JSON with insufficient containment and escaping.

Review this skill before installing. Use it only with trusted JSON test cases, inspect generated Java before compiling or running it, write output only to a controlled test directory, and run generated tests only against disposable test databases with restricted credentials.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/jtest_generator.py:174
Finding

Generated Java Source Injection Through Unescaped JSON Fields

Content
View full analysis
requestBody = new HashMap<>();"] for key, value in body.items(): if value is None: lines.append(f" requestBody.put(\"{key}\", null);") elif isinstance(value, str): lines.append(f" requestBody.put(\"{key}\", \"{value}\");") elif isinstance(value, bool): lines.append(f" requestBody.put(\"{key}\", {str(value).lower()});") elif isinstance(value, (int, float)): lines.append(f" requestBody.put(\"{key}\", {value});") elif isinstance(value, dict): import json dict_str = json.dumps(value, ensure_ascii=False).replace('"', '\\"') lines.append(f" requestBody.put(\"{key}\", \"{dict_str}\");") elif isinstance(value, list): import json list_str = json.dumps(value, ensure_ascii=False).replace('"', '\\"') lines.append(f" requestBody.put(\"{key}\", \"{list_str}\");") ``` Additional affected generation sinks include: ```python lines.append(f" .andExpect(jsonPath(\"{json_path}\").value(\"{value}\"))") ``` ```python f" logger.info(\"Executing test: {test_case.id} - {test_case.name}\");", ``` ```python lines.append(f" mockMvc.perform(post(\"{endpoint}\")") ``` ### Technical Analysis The generator interpolates JSON-controlled request keys, string values, expected response values, test identifiers, test names, and endpoint values directly into Java source code. It does not consistently encode these values as Java string literals. For example, a string value containing a double quote, Java statement terminator, and comment marker can close the intended string and inject a new Java statement. Escaping only quotation marks in selected fields is also insufficient because ...[truncated 2213 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/jtest_generator.py:35
Finding

Output Path Traversal Through the Test Suite Name

Content
View full analysis
str: chinese_pattern = re.compile(r'[\u4e00-\u9fff]+') text = chinese_pattern.sub('', text) words = re.split(r'[_\- ]', text) return ''.join(word.capitalize() for word in words if word) ``` The resulting name reaches a filesystem write in `scripts/run_generator.py`, lines 84-100: ```python class_name = generator._extract_class_name(test_suite.name) + ".java" package_name = generator._extract_package_from_endpoint(test_suite.interface_info.endpoint) output_dir = os.path.join(output_base, package_name.replace('.', '/')) os.makedirs(output_dir, exist_ok=True) output_path = os.path.join(output_dir, class_name) with open(output_path, 'w', encoding='utf-8') as f: f.write(java_code) ``` The standalone generator has a similar write at `scripts/jtest_generator.py`, lines 502-505: ```python class_name = generator._extract_class_name(test_suite.name) + ".java" output_path = f"{output_dir}/{class_name}" os.makedirs(output_dir, exist_ok=True) with open(output_path, 'w', encoding='utf-8') as f: f.write(java_code) ``` ### Technical Analysis The JSON-controlled `test_suite` field is converted into a class name, but `_to_pascal_case()` only removes Chinese characters and splits on underscores, hyphens, and spaces. It does not reject or remove: - Forward slashes - Backslashes - Parent-directory components such as `..` - Absolute-path syntax - Other invalid Java identifier characters The derived value is then joined directly with the requested output directory and opened in write mode. Neither entry point resolves the final path and verifies that it remains under the intended output directory. The forced `Test.java` suffix limits the exact filename an attacker can select, but it does not preve ...[truncated 1444 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/jtest_generator.py:284
Finding

Unrestricted Execution of JSON-Supplied Database Statements

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared description says the skill generates JUnit 5 test classes from JSON test case files. The supplied code chunk is solely a Python parser for JSON-formatted test suites. It defines dataclasses for suite/case structure, loads JSON from file or string, provides lookup/filter/summary helpers, and validates presence of fields. There is no code emission, template rendering, file generation for Java tests, JUnit annotations, or Spring Boot-specific logic. Reading a JSON file is consistent with the declared input type, but the primary purpose is materially different: parsing and validation rather than test generation.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill describes behaviors that imply file reads and file writes, but it declares no explicit tool scope or permissions. In an agent setting, missing scope boundaries can cause the skill to operate with broader-than-expected filesystem access, making unintended reads or writes harder to constrain or audit.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill advertises automatic execution of setup/teardown MySQL SQL and writing generated tests into the project without a prominent safety warning. Because the SQL originates from JSON test case content that may be untrusted or LLM-generated, this can lead to destructive database operations or unsafe code being written and later executed during mvn test.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill documentation and prompt content are written in Chinese and present the interaction as Chinese-only, but there is no opt-in or explanation that the skill is region- or locale-specific. Under the language/locale policy, skills should not impose a specific language unless the user is given a choice or the constraint is clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains natural-language strings that force a specific language/locale for usage instructions and runtime output. Under the policy, language constraints should offer user choice or be clearly justified; neither is present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The module title, description, and inline documentation are presented in Chinese only. Under the policy, forcing a specific language without user choice can be a natural-language policy violation when no opt-in or language selection is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The command-line usage, success messages, summary labels, and error messages are all emitted only in Chinese. This creates a fixed-language interaction policy with no user-selectable locale or documented justification.

Content

No source excerpt is available for this finding.