Back to skill

Security audit

Java Security Audit - AI驱动的Java代码审计

Security checks for vulnerabilities and agentic risk

Overview

This is a legitimate Java security-audit skill, with some reliability and privacy caveats but no evidence of malicious behavior.

Install only if you intend to let the agent read the target Java/Kotlin repository and write audit outputs. Treat the generated coverage numbers and final reports as advisory, because the included coverage scripts can miscount files; verify important findings and coverage manually, and avoid sending proprietary code to an external vector store unless you explicitly approve that data flow.

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

Warning
Location
scripts/coverage-check.sh:61
Finding
Coverage Gate Can Falsely Certify Unreviewed Files## Vulnerability Details **File Location**: `scripts/coverage-check.sh:61-80` **Vulnerability Type**: Inexact file identity validation **Risk Level**: Medium ```bash REVIEWED_FILES=$(grep -oE "[a-zA-Z0-9_/-]+\.java" "$REVIEWED_FILE" | sort -u) REVIEWED_COUNT=$(echo "$REVIEWED_FILES" | grep -v "^$" | wc -l) MISSED_FILES="" MISSED_COUNT=0 while IFS= read -r actual_file; do if [[ -z "$actual_file" ]]; then continue fi filename=$(basename "$actual_file") if ! echo "$REVIEWED_FILES" | grep -q "$filename"; then MISSED_FILES="$MISSED_FILES$actual_file\n" ((MISSED_COUNT++)) fi done <<< "$ACTUAL_FILES" ``` ### Technical Analysis The coverage gate extracts reviewed paths but reduces every actual project file to its basename before testing membership. It then passes that basename to `grep -q` as an unanchored regular expression. This creates several integrity problems: - If different modules contain files with the same basename, reviewing one file can cause every same-named file to be treated as reviewed. - A basename may match a longer reviewed path or filename because the comparison is not anchored. - Regex metacharacters in filenames are not escaped. In particular, the period before `java` is interpreted as a wildcard during the membership check. - The manifest extraction expression excludes some valid path characters, which can further distort file identities. This violates the Skill's declared requirement to compare the review manifest against the exact file list and to prevent progression until coverage reaches 100%. ### Attack Path 1. A target repository contains security-relevant files with duplicate basenames in separate modules, such as `module-a/src/UserService.java` and `module-b/src/UserService.java`. 2. Only one occurrence is included in the reviewed-file manifest. 3. The script processes each actual file but converts its path to `Use ...[truncated 795 chars]
Remediation
## Remediation Suggestions - Compare canonical project-relative paths rather than basenames. - Use fixed-string, exact-line comparison instead of regular-expression matching, such as `grep -Fqx`. - Prefer generating two sorted files of normalized relative paths and comparing them with `comm`. - Use NUL-delimited traversal and storage where possible to support spaces, newlines, and other valid filename characters. - Reject reviewed-manifest paths that resolve outside the target project. - Add regression tests for duplicate basenames, regex metacharacters, spaces, nested modules, and prefix or suffix collisions. - Require the exact set difference between actual and reviewed relative paths to be empty before reporting 100% coverage.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/java_audit.py:333
Finding
Python Coverage Parser Discards Reviewed Filenames## Vulnerability Details **File Location**: `scripts/java_audit.py:333-349` **Vulnerability Type**: Incorrect regular-expression result handling **Risk Level**: Low ```python actual_files = set() for root, dirs, files in os.walk(project_path): dirs[:] = [d for d in dirs if d not in [ 'target', 'node_modules', '.git', 'build', 'out', '.gradle', 'test', 'tests' ]] for file in files: if file.endswith(('.java', '.kt')): actual_files.add(file) actual_count = len(actual_files) reviewed_files = set() if os.path.exists(reviewed_file): content = get_file_content(reviewed_file) reviewed_files = set( re.findall(r'[a-zA-Z0-9_/-]+\.(java|kt)', content) ) reviewed_count = len(reviewed_files) missed_files = actual_files - reviewed_files missed_count = len(missed_files) ``` ### Technical Analysis The regular expression supplied to `re.findall()` contains a capturing group, `(java|kt)`. When a pattern contains a capturing group, Python returns the captured group values rather than the complete matches. As a result, `reviewed_files` contains values such as `"java"` and `"kt"` instead of the reviewed filenames. The subsequent set subtraction compares actual basenames against these extension strings, causing legitimate reviewed files to be classified as missing. The implementation also stores actual files only by basename. Even after correcting the regular expression, duplicate basenames in separate directories would collapse into one set entry and prevent an accurate file-level coverage calculation. ### Attack Path 1. A user supplies a valid review manifest containing Java or Kotlin file paths. 2. `re.findall()` parses each entry but returns only the captured extension. 3. The resulting set contains `"java"` and/or `"kt"` rather than file identities. 4. Set subtraction fails to recognize the reviewed files. 5. The coverage gate reports ...[truncated 585 chars]
Remediation
## Remediation Suggestions - Replace the capturing group with a noncapturing group: ```python re.findall(r'[a-zA-Z0-9_./-]+\.(?:java|kt)', content) ``` - Normalize every extracted path relative to the audited project root. - Store complete relative paths in `actual_files` rather than basenames: ```python actual_files.add(os.path.relpath( os.path.join(root, file), project_path )) ``` - Parse a structured manifest format instead of extracting paths from unrestricted Markdown where practical. - Reject absolute paths and traversal components after normalization. - Add automated tests covering Java and Kotlin files, duplicate basenames, nested modules, malformed manifests, and filenames containing spaces or punctuation.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (50)

Credential Access

High
Category
Privilege Escalation
Content
*.pot

# Environments
.env
.venv
env/
venv/
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Hidden Instructions

High
Category
Prompt Injection
Content
# Java Audit Skill

<div align="center">
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
# Java Audit Skill

<div align="center">
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
描述强调的是AI驱动的Java/Kotlin安全审计与漏洞挖掘能力,但代码本身并不进行源码语义分析、污点分析、规则检测、漏洞识别或审计报告生成。它只是通过 find/grep/python3 统计实际 Java 文件与“已审阅文件清单”的差异,计算覆盖率并输出门禁报告。这可以算作安全审计流程中的配套质量控制脚本,但其主目的与声明的核心能力明显不同,且能力范围远窄于所宣称的Java/Kotlin安全审计技能。

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
声明描述的核心能力是‘Java代码安全审计/漏洞挖掘’,而实际代码只是一个辅助性的预处理脚本:基于注解和文件名规则对 Java 文件进行优先级分类,并计算 EALOC 与 Agent 预算。这可以作为审计流程中的支持步骤,但并不能代表所声明的主要技能能力。尤其是脚本没有检测任何漏洞模式、数据流、危险 API、认证授权问题、注入类风险等安全审计内容,也没有处理 Kotlin 文件。由于实际主要用途与声明的主要用途存在明显差异,应判定为描述与行为不匹配。

Ae1

High
Category
analysis-evasion
Content
**详细判断方法见**: [references/vulnerability-conditions.md](references/vulnerability-conditions.md) 第 16-20 节
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
**详细判断方法见**: [references/vulnerability-conditions.md](references/vulnerability-conditions.md) 第 16-20 节
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
**详细判断方法见**: [references/vulnerability-conditions.md](references/vulnerability-conditions.md) 第 16-20 节
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Credential Access

High
Category
Privilege Escalation
Content
1. **XXE 风险成因**:EasyExcel/POI 在底层解析 Excel(特别是 .xlsx 格式)时,会用到 XML 解析器。代码中没有配置禁用 XML 外部实体的选项,MultipartFile file 来自用户输入,没有进行充分的安全校验。

2. **文件本质**:.xlsx 文件本质上是 ZIP 压缩的 XML 文件集合。如果攻击者构造恶意的 Excel 文件,在 XML 中定义外部实体,可能导致:
   - 读取本地文件(如 `/etc/passwd`)
   - 发起 SSRF 请求
   - 拒绝服务攻击
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
1. **XXE 风险成因**:EasyExcel/POI 在底层解析 Excel(特别是 .xlsx 格式)时,会用到 XML 解析器。代码中没有配置禁用 XML 外部实体的选项,MultipartFile file 来自用户输入,没有进行充分的安全校验。

2. **文件本质**:.xlsx 文件本质上是 ZIP 压缩的 XML 文件集合。如果攻击者构造恶意的 Excel 文件,在 XML 中定义外部实体,可能导致:
   - 读取本地文件(如 `/etc/passwd`)
   - 发起 SSRF 请求
   - 拒绝服务攻击
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
1. **XXE 风险成因**:EasyExcel/POI 在底层解析 Excel(特别是 .xlsx 格式)时,会用到 XML 解析器。代码中没有配置禁用 XML 外部实体的选项,MultipartFile file 来自用户输入,没有进行充分的安全校验。

2. **文件本质**:.xlsx 文件本质上是 ZIP 压缩的 XML 文件集合。如果攻击者构造恶意的 Excel 文件,在 XML 中定义外部实体,可能导致:
   - 读取本地文件(如 `/etc/passwd`)
   - 发起 SSRF 请求
   - 拒绝服务攻击
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
1. **XXE 风险成因**:EasyExcel/POI 在底层解析 Excel(特别是 .xlsx 格式)时,会用到 XML 解析器。代码中没有配置禁用 XML 外部实体的选项,MultipartFile file 来自用户输入,没有进行充分的安全校验。

2. **文件本质**:.xlsx 文件本质上是 ZIP 压缩的 XML 文件集合。如果攻击者构造恶意的 Excel 文件,在 XML 中定义外部实体,可能导致:
   - 读取本地文件(如 `/etc/passwd`)
   - 发起 SSRF 请求
   - 拒绝服务攻击
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
1. **XXE 风险成因**:EasyExcel/POI 在底层解析 Excel(特别是 .xlsx 格式)时,会用到 XML 解析器。代码中没有配置禁用 XML 外部实体的选项,MultipartFile file 来自用户输入,没有进行充分的安全校验。

2. **文件本质**:.xlsx 文件本质上是 ZIP 压缩的 XML 文件集合。如果攻击者构造恶意的 Excel 文件,在 XML 中定义外部实体,可能导致:
   - 读取本地文件(如 `/etc/passwd`)
   - 发起 SSRF 请求
   - 拒绝服务攻击
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Cloud Metadata Access

High
Category
Server-Side Request Forgery
Content
**SSRF 测试 Payload**:
```
http://127.0.0.1:8080/admin
http://169.254.169.254/latest/meta-data/
file:///etc/passwd
dict://127.0.0.1:6379/info
gopher://127.0.0.1:6379/_*1%0d%0a...
Confidence
90% confidence
Finding
Code accesses a cloud instance metadata endpoint (e.g. 169.254.169.254). A single request can return temporary IAM credentials, making this a high-value SSRF target for credential theft.

Intent-Code Divergence

High
Confidence
99% confidence
Finding
The regex `r'[a-zA-Z0-9_/-]+\.(java|kt)'` uses a capturing group, so `re.findall()` returns only the captured extension values (`java` or `kt`) rather than full filenames. As a result, coverage checking is fundamentally broken and can falsely report massive review gaps or otherwise invalidate the audit gate, which is dangerous in a security-audit skill because it undermines assurance and can cause incorrect go/no-go decisions.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This markdown file uses Chinese as the default instructional language and does not indicate that contributors may choose another language or that the language restriction is required for a region-specific purpose. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The Chinese invocation example uses very broad natural-language trigger wording for a high-impact security auditing skill. In systems that auto-route or activate skills based on conversational phrases, generic wording can cause unintended invocation on unrelated user requests, potentially exposing repository contents or launching unnecessary audit workflows.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The English example 'Help me audit this Java project: /path/to/project' is generic everyday language and can match ordinary assistance requests. In agent environments that infer skill activation from examples or trigger phrases, this increases the chance of accidental activation and unintended access to local paths or source trees.

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill instructs the agent to read and write many files (for example metrics.json, tier-classification.md, findings-raw.md, findings-verified.md, and audit-report.md) but does not declare any explicit tool scope or permission boundaries. In an agent environment, undocumented file I/O capability increases the chance of over-broad filesystem access, unintended modification of repository contents, or misuse of the skill in contexts where only read-only analysis was expected.

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
技能说明整体以中文呈现,并在描述中直接规定输出与流程说明,未看到提供语言/locale 选择或用户 opt-in 的说明。根据规则,若技能强制特定语言而不给用户选择,属于自然语言层面的语言/locale 策略问题。

Vague Triggers

Medium
Confidence
95% confidence
Finding
Broad trigger keywords such as generic security-audit phrases can cause the skill to activate in unintended conversations. In a high-privilege agent setting, accidental invocation may lead to unnecessary repository scanning, file creation, or redirection of the agent into a complex workflow the user did not intend.

Natural-Language Policy Violations

Medium
Confidence
87% confidence
Finding
This markdown file is written entirely in Chinese and does not indicate that the language is optional, user-selectable, or required for a specific region or compliance context. Under the policy rule for natural-language violations, forcing a specific language without user opt-in can be a locale-policy issue.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
This markdown template is written as a mandatory standard ("每个漏洞报告必须包含…") entirely in Chinese, which effectively imposes a specific language on report generation. The file does not provide any user opt-in, alternative locale, or justification that the template is intended only for a Chinese-language or region-specific environment.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The entire checklist, usage guidance, risk definitions, and examples are written in Chinese, with no statement that the skill is China-specific or that users may choose another language. For a generally named Java web security audit checklist, this creates a natural-language locale restriction without user opt-in.

Unsafe Defaults

Medium
Category
Tool Misuse
Content
- commons-io ≥ 2.x → 可利用
  ≥ 1.2.83 → 检查 safeMode:
    - safeMode = true → 安全
    - safeMode = false → 风险
```

### Fastjson 危险版本速查
Confidence
80% confidence
Finding
Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.

Static analysis

No suspicious patterns detected.