Php Injection Audit logo

Php Injection Audit

OrganizationPopular
wgpsec
php-injection-audit

PHP 源码注入类漏洞审计。当在 PHP 白盒审计中需要检测注入类漏洞时触发。 覆盖 6 种注入: SQL 注入(PDO/MySQLi/ORM)、NoSQL 注入(MongoDB)、 命令注入(system/exec/passthru)、LDAP 注入、表达式注入(eval/preg_replace /e)、SSRF。 需要 php-audit-pipeline 提供的数据流证据(EVID_*)作为审计输入。

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namephp-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 Php 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/php/php-injection-audit .claude/skills/php-injection-audit
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Php 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 Php 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 Php 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.

PHP 注入类漏洞源码审计

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

深入参考


6 种注入速查表

类型典型 Sink危险模式严重度
SQL 注入PDO::query, mysqli_query, DB::raw, whereRaw字符串拼接进 SQLCritical-High
命令注入exec, system, shell_exec, passthru, proc_open, 反引号用户输入拼入命令串Critical
SSRFcurl_exec, file_get_contents, SoapClient用户可控 URL 发起服务端请求High-Medium
表达式注入eval, assert, preg_replace(/e), create_function用户输入进入代码执行上下文Critical
NoSQL 注入MongoDB find(), $where, 操作符 $ne/$gt/$regex数组/对象参数绕过等值比较High
LDAP 注入ldap_search, ldap_list, ldap_bind用户输入拼入过滤器字符串High-Medium

通用审计流程(4 步)

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

Step 2 -- 判断过滤有效性: 追踪 Source→Sink 路径上的每一步过滤/转义操作,评估其是否对当前注入类型有效。常见陷阱: addslashes 对 GBK 宽字节无效、intval 对数组参数无效、escapeshellarg 在特定 locale 下可绕过。

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

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

SQL 注入审计要点

  • PDO 预编译: 确认 prepare() + execute() 的占位符绑定完整。PDO::query($sql)PDO::exec($sql) 是直接执行,拼接即危险
  • ORM 陷阱: whereRaw/havingRaw/orderByRaw/selectRaw 中的变量拼接不受 ORM 参数化保护
  • 动态 ORDER BY / LIMIT: 这两个子句无法使用参数化绑定,intval() 或白名单是唯一安全方案
  • sprintf %s 拼接: sprintf("SELECT * FROM t WHERE id='%s'", $input) 本质仍是拼接
  • 二次注入: 数据入库时转义、出库时未转义再拼入新查询,追踪需跨越存储边界

命令注入审计要点

  • escapeshellarg 有效性: 单独使用通常有效,但与 escapeshellcmd 同时使用反而会引入绕过(引号配对被破坏)
  • 多参数拼接: exec("convert " . escapeshellarg($src) . " " . $dest) — 如果 $dest 未转义则仍可注入
  • 反引号: 容易被忽视的命令执行方式,全局搜索反引号中的变量引用
  • proc_open 数组模式: proc_open([$cmd, $arg1, $arg2], ...) 避免了 shell 解析,是安全的命令执行方式

SSRF 审计要点

  • 协议限制: 检查是否限制了 http/https 以外的协议(gopher:// 可打内网服务,file:// 可读本地文件)
  • IP 黑名单绕过: 十进制 2130706433、八进制 0177.0.0.1、IPv6 [::1]、DNS Rebinding 都能绕过简单的 IP 检查
  • 重定向跟随: curl 默认不跟随但 CURLOPT_FOLLOWLOCATION=true 时,可通过 302 跳转绕过 URL 白名单
  • DNS 解析时序: 先解析检查再发起请求的模式存在 TOCTOU 竞争(DNS Rebinding 利用点)

表达式注入审计要点

  • eval/assert: 任何用户可控数据进入 eval() 都是 Critical。assert() 在 PHP < 8.0 可执行字符串
  • preg_replace /e: PHP 7.0 已移除,但遗留系统中仍可能存在。替代方案 preg_replace_callback 是安全的
  • create_function: 本质是 eval,PHP 8.0 已移除但老项目常见
  • 可控回调: array_map/usort/call_user_func 的回调参数如果用户可控,等价于代码执行

NoSQL / LDAP 审计要点(简要)

  • MongoDB 操作符注入: PHP 数组参数 $_GET['user'][$ne]=1 可绕过等值匹配,检查是否对输入做了类型强制转换
  • $where 注入: MongoDB 的 $where 接受 JavaScript 表达式,用户可控时等价于代码执行
  • LDAP 过滤器拼接: (&(uid=$input)(pass=$pass)) 中注入 *)(uid=*))(|(uid=* 可修改查询逻辑
  • ldap_escape 缺失: PHP 5.6+ 提供 ldap_escape() 但很多项目未使用,检查 (, ), *, \, NUL 是否被转义

检测清单

  • 所有注入类 EVID_* 证据点已逐一审查
  • SQL 拼接点均已验证是否使用参数化/预编译
  • ORM Raw 方法中的变量拼接已全部标记
  • 命令执行函数的每个参数段都已检查转义
  • SSRF Sink 的 URL 来源和协议限制已确认
  • eval/assert/preg_replace /e 的参数可控性已追踪
  • NoSQL 查询参数的类型强制已检查
  • LDAP 过滤器的转义处理已确认
  • 过滤不充分的点已给出具体绕过思路或标"待验证"
  • 严重度评分使用了统一公式,与 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 Php Injection Audit AI skill do?

PHP 源码注入类漏洞审计。当在 PHP 白盒审计中需要检测注入类漏洞时触发。 覆盖 6 种注入: SQL 注入(PDO/MySQLi/ORM)、NoSQL 注入(MongoDB)、 命令注入(system/exec/passthru)、LDAP 注入、表达式注入(eval/preg_replace /e)、SSRF。 需要 php-audit-pipeline 提供的数据流证据(EVID_*)作为审计输入。

Why use Php Injection Audit on TypingMind?

Because you install it once and use it with any model. Php 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 Php Injection Audit in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/code-audit/php/php-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 Php 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 Php Injection Audit?

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

Is the Php 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 👇