Php Sql Audit logo

Php Sql Audit

Community
0xShe
php-sql-audit

PHP Web 源码 SQL 注入漏洞审计工具。从源码中识别所有 SQL 执行点并分析注入风险,输出可利用性分级、PoC 与修复建议(禁止省略)。

Overview

Publisher0xShe
RepositoryPHP-Code-Audit-Skill
Skill namephp-sql-audit
Stars
406
Forks
42
Bundled files
Instructions only
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.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

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

Installation

Install the Php Sql 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.
    https://github.com/0xShe/PHP-Code-Audit-Skill/tree/main/php-sql-audit
  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/0xShe/PHP-Code-Audit-Skill.git /tmp/PHP-Code-Audit-Skill
mkdir -p .claude/skills
cp -r /tmp/PHP-Code-Audit-Skill/php-sql-audit .claude/skills/php-sql-audit
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Php Sql 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 Sql 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 Sql 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 SQL 注入审计(php-sql-audit)

分析 PHP 项目源码,识别 SQL 执行相关代码(PDO/mysqli/ORM),追踪用户输入到 SQL 构造点,验证是否存在 SQL 注入,并输出完整漏洞报告。

CRITICAL:禁止省略与禁止误报

  • 必须审计所有在路由参数中出现的字符串来源(GET/POST/Body/参数字段)进入 SQL 的路径
  • 必须使用“数据流追踪证据”判定可利用性;不得只靠关键字猜测
  • 禁止省略:不得出现任何省略占位符;必须输出完整的漏洞证据链与修复建议

分级与编号

  • 详见:shared/SEVERITY_RATING.md
  • 漏洞编号:{C/H/M/L}-SQL-{序号}

输入依赖

建议至少有(与 shared/IO_PATH_CONVENTION.md 一致;合并流水线时读总报告中等价章节即可):

  • routes_{timestamp}.md(独立落盘时常为 route_mapping/routes_{timestamp}.md)
  • params_{timestamp}.md(独立落盘时常为 route_mapping/params_{timestamp}.md) 可选但推荐:
  • route_tracer/ 输出,用于精准判定参数实际使用状态

SQL Sink 识别(必做)

  1. PDO / PDOStatement
    • 相对危险:$pdo->query($sql) / $pdo->exec($sql)(若 $sql 来自拼接/包含用户输入)
    • 形式检查:$pdo->prepare($sql) 只有在 $sql 中使用占位符且后续 bindParam/bindValue 或正确传参时更安全
    • ORM/DB 包装:DB::select(DB::raw({value}))、Doctrine createQuery 等
  2. mysqli / mysqli_stmt
    • mysqli_query($conn, $sql) 拼接危险
    • mysqli_prepare 只有 prepare + bind 正确时才可能安全
  3. 典型危险构造模式(必做)
    • SQL 字符串与变量拼接:., sprintf, vsprintf, implode/join + SQL 关键字
    • 动态排序:order by $x / ORDER BY ".$x."(常见高危)

需要触发 tracer 的条件(必做)

满足任一条时必须调用 php-route-tracer(或同等追踪证据):

  • 参数经过多层传递或 JSON 解码后取字段进入 SQL
  • SQL 构造点位于基类/工具类/父函数中
  • 存在分支条件(if/try/catch)导致 SQL 是否执行不确定

报告输出

输出到:

{output_path}/vuln_audit/
└── sql_{timestamp}.md

漏洞报告条目模板(强制)

markdown
### [{等级前缀}-SQL-{序号}] {风险标题}

| 项目 | 信息 |
|------|------|
| 严重等级 | {🔴/🟠/🟡/🔵} (CVSS {score}) |
| 可达性 (R) | {0-3} - {理由} |
| 影响范围 (I) | {0-3} - {理由} |
| 利用复杂度 (C) | {0-3} - {理由} |
| 可利用性 | ✅ 已确认 / ⚠️ 待验证 / ❌ 不可利用 / 🔍 环境依赖 |
| 位置 | {file}:{line} ({Function/Class}) |

#### 数据流链(Source → Sink)
(按路由逐行写出:请求参数读取 -> 变量赋值/拼接/转换 -> 分支 -> SQL 进入执行点。禁止省略)

#### 可利用前置条件
- 鉴权要求:{无需/需登录/需特定权限}
- 输入可控性:{完全可控/条件可控/不可控}
- 触发条件:{分支/异常/环境依赖}

#### 证据引用(强制:来自 php-route-tracer)
每条 SQL 疑似漏洞必须逐项引用 trace 输出中 `## 9) Sink Evidence Type Checklist` 的 **SQL 行**对应证据要点(允许状态为待验证,但证据引用必须存在):
1. `EVID_SQL_EXEC_POINT`:SQL 执行函数/语句位置(对应 trace 的 SQL 执行点证据)
2. `EVID_SQL_STRING_CONSTRUCTION`:SQL 字符串构造/拼接位置(对应 trace 的 SQL 拼接证据)
3. `EVID_SQL_USER_PARAM_TO_SQL_FRAGMENT`:用户可控参数到 SQL 片段的映射(对应 trace 的可控性矩阵字段证据)

#### tracer 证据缺失处理(强制)
- 若无法定位上述 1~3 任一关键证据要点:该漏洞状态只能标记为 `⚠️待验证`,不得直接给出 `✅已确认可利用`。

#### 验证 PoC(强制,可执行请求)
```http
{HTTP Method} {完整路径与查询/Body} HTTP/1.1
Host: {host}
{必要 Header/Session/JWT/Cookie}

{Payload}
建议修复
  • 给出安全写法要点(PDO prepare + bind 且保证 SQL 片段不拼接用户输入)
  • 给出代码搜索语句(rg/grep 风格)用于定位所有同类拼接点

## 输出完整性检查(强制)
- [ ] 至少输出:风险统计 + 每条漏洞完整条目
- [ ] 不出现任何省略占位符
- [ ] 每条漏洞都包含:数据流链、可利用前置条件、可执行 PoC、修复建议

Frequently asked questions

What does the Php Sql Audit AI skill do?

PHP Web 源码 SQL 注入漏洞审计工具。从源码中识别所有 SQL 执行点并分析注入风险,输出可利用性分级、PoC 与修复建议(禁止省略)。

Why use Php Sql Audit on TypingMind?

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

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/0xShe/PHP-Code-Audit-Skill/tree/main/php-sql-audit. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Php Sql 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 Sql Audit?

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

Is the Php Sql Audit AI skill free?

It is published on GitHub by 0xShe. 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 👇