Java Injection Audit logo

Java Injection Audit

OrganizationPopular
wgpsec
java-injection-audit

Java 源码注入类漏洞审计。当在 Java 白盒审计中需要检测注入类漏洞时触发。 覆盖 6 种注入: SQL 注入(JDBC/MyBatis/Hibernate/JPA)、命令注入(Runtime.exec/ProcessBuilder)、 SSRF(HttpURLConnection/OkHttp/RestTemplate)、LDAP 注入、SpEL/OGNL 表达式注入、NoSQL 注入(MongoDB)。 需要 java-audit-pipeline 提供的数据流证据(EVID_*)作为审计输入。

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namejava-injection-audit
Stars
1.7K
Forks
242
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the Java Injection Audit AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/code-audit/java/java-injection-audit .claude/skills/java-injection-audit
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Java Injection Audit in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Java Injection Audit on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Java Injection Audit is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Java 注入类漏洞源码审计

本 skill 聚焦源码层面判断"注入是否成立",核心是验证 Source→Sink 路径上的过滤是否充分。构造 payload、绕 WAF 等运行时利用技术属于对应黑盒 exploit skill 范畴。

深入参考


6 种注入速查表

类型典型 Sink危险模式严重度
SQL 注入Statement.execute, session.createQuery, MyBatis ${}, JPA nativeQuery字符串拼接进 SQLCritical-High
命令注入Runtime.exec, ProcessBuilder.start, commons-exec用户输入拼入命令串或经 sh -c 包装Critical
SSRFHttpURLConnection, OkHttpClient, RestTemplate, WebClient用户可控 URL 发起服务端请求High-Medium
SpEL/OGNL 注入ExpressionParser.parseExpression, ValueStack.findValue, @Value用户输入进入表达式解析上下文Critical
LDAP 注入DirContext.search, LdapTemplate.search用户输入拼入过滤器字符串High-Medium
NoSQL 注入MongoCollection.find, @Query, $where字符串拼接进查询或操作符注入High

通用审计流程(4 步)

Step 1 -- 确认 EVID 证据点: 从 java-audit-pipeline Phase 3 产出的 EVID_* 证据中,筛选注入类条目(EVID_SQL_、EVID_CMD_、EVID_SSRF_、EVID_EXPR_、EVID_LDAP_、EVID_NOSQL_)。没有 EVID 证据的 Sink 只能标"待验证"。

Step 2 -- 判断过滤有效性: 追踪 Source→Sink 路径上每一步过滤/转义操作,评估其对当前注入类型是否有效。常见陷阱: PreparedStatement 但 SQL 片段仍由拼接构造、MyBatis ${} 被误用为 #{}escapeshellarg 等 PHP 思维迁移到 Java 不适用。

Step 3 -- 评估绕过可能性: 过滤存在但不充分时,分析具体绕过路径(编码差异、类型混淆、二次处理等)。能给出绕过思路则标"已确认",否则标"待验证"并记录已知过滤方式。

Step 4 -- 确定严重度: 使用 java-audit-pipeline 的三维度评分公式 Score = R*0.40 + I*0.35 + C*0.25。注入类漏洞 Impact 通常较高(命令/表达式注入 I=3, SQL 注入 I=2-3),但需结合可达性和利用复杂度综合判断。

SQL 注入审计要点

  • JDBC PreparedStatement vs Statement: PreparedStatement + ? 占位符是安全的,Statement.execute(sql) 拼接即危险;注意 PreparedStatement 中仍可能存在拼接片段
  • MyBatis #{} vs ${}: #{} 参数绑定安全,${} 直接拼接危险;ORDER BY 场景常被迫用 ${},需白名单校验
  • Hibernate HQL 拼接: session.createQuery("from User where name='" + input + "'") 虽然是 HQL 仍可注入
  • JPA @Query nativeQuery: @Query(value="...", nativeQuery=true) 中 SpEL #{#param} 或字符串拼接均危险
  • 动态排序 ORDER BY: 标识符无法参数化,白名单是唯一安全方案;Spring Data 的 Sort 对象是安全的

命令注入审计要点

  • Runtime.exec(String) vs exec(String[]): 单字符串形式按空白拆分为程序和参数,不会自动经 shell 解释;数组形式更明确,但两者都需注意 -flag 参数注入
  • ProcessBuilder: 参数列表形式类似数组 exec,但通过 sh -c "cmd" 包装则退化为 shell 解释
  • 反射调用: 通过反射调用 Runtime.getRuntime()ProcessBuilder 可绕过静态扫描
  • commons-exec CommandLine: CommandLine.parse(userInput) 危险,addArgument(input, false) 安全

SSRF 审计要点

  • HttpURLConnection: new URL(userInput).openConnection() — 最基础的 SSRF 入口
  • OkHttp / Apache HttpClient / RestTemplate / WebClient: 均需检查 URL 参数是否用户可控
  • 协议限制: 检查是否限制 http/httpsfile:// 读文件、jar:// SSRF、netdoc:// 信息泄露)
  • DNS Rebinding: 先解析校验再发起请求存在 TOCTOU 竞争
  • 重定向跟随: HttpURLConnection 默认跟随同协议重定向,需 setInstanceFollowRedirects(false)

SpEL/OGNL 表达式注入审计要点

  • SpEL: new SpelExpressionParser().parseExpression(userInput).getValue() — 直接 RCE
  • @Value / @PreAuthorize: 注解中引用用户可控配置值时可触发 SpEL 解析
  • Thymeleaf SSTI: __${expr}__ 预处理语法触发 SpEL 执行
  • OGNL (Struts2): ActionContext / ValueStack 注入,历史漏洞众多
  • 安全模式: SimpleEvaluationContext 限制 SpEL 功能(禁用类型引用和构造器)

LDAP 注入审计要点

  • 过滤器拼接: "(uid=" + username + ")" — 注入 *)(uid=*))(|(uid=* 可修改查询逻辑
  • 安全模式: 手动转义 ( ) * \ \0 或使用 Spring LDAP 的 LdapQueryBuilder / LdapEncoder
  • DN 注入: 与过滤器注入不同,需转义 , + " \ < > ; 等 DN 特殊字符

NoSQL 注入审计要点

  • MongoDB Java Driver: BasicDBObject / Document 构造时如果拼接 JSON 字符串则可注入操作符
  • Spring Data MongoDB: @Query("{'name': ?0}") 参数化安全;字符串拼接构造查询危险
  • $where / $regex: $where 接受 JavaScript 表达式,用户可控时等价于代码执行
  • Criteria API: Criteria.where("name").is(input) 是安全的参数化查询方式

检测清单

  • 所有注入类 EVID_* 证据点已逐一审查
  • SQL 拼接点均已验证是否使用参数化/预编译,MyBatis ${} 已全部标记
  • 命令执行入口的每个参数来源和构造方式已检查
  • SSRF Sink 的 URL 来源、协议限制、重定向策略已确认
  • SpEL/OGNL 解析入口的表达式来源已追踪
  • LDAP 过滤器和 DN 的转义处理已确认
  • NoSQL 查询参数的构造方式已检查
  • 过滤不充分的点已给出具体绕过思路或标"待验证"
  • 严重度评分使用了统一公式,与 pipeline 一致

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Java Injection Audit AI skill do?

Java 源码注入类漏洞审计。当在 Java 白盒审计中需要检测注入类漏洞时触发。 覆盖 6 种注入: SQL 注入(JDBC/MyBatis/Hibernate/JPA)、命令注入(Runtime.exec/ProcessBuilder)、 SSRF(HttpURLConnection/OkHttp/RestTemplate)、LDAP 注入、SpEL/OGNL 表达式注入、NoSQL 注入(MongoDB)。 需要 java-audit-pipeline 提供的数据流证据(EVID_*)作为审计输入。

Why use Java Injection Audit on TypingMind?

Because you install it once and use it with any model. Java Injection Audit is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Java Injection Audit in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/code-audit/java/java-injection-audit. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Java Injection Audit?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Java Injection Audit?

As many as you like. As long as a model supports skills, you can use Java Injection Audit with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Java Injection Audit AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇