Php Serialization Audit logo

Php Serialization Audit

OrganizationPopular
wgpsec
php-serialization-audit

PHP 源码序列化与模板类漏洞审计。当在 PHP 白盒审计中需要检测反序列化、XML 解析或模板注入漏洞时触发。 覆盖 3 类风险: PHP 反序列化(unserialize/phar 反序列化/POP 链构造)、 XXE(XML 外部实体注入/libxml 配置)、SSTI(模板注入/Twig/Blade/Smarty 引擎)。 需要 php-audit-pipeline 提供的数据流证据。

Overview

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

Use it in TypingMind

Enable Php Serialization 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 Serialization 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 Serialization 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 聚焦源码层面判断"反序列化/XXE/SSTI 是否成立",核心是验证 Source→Sink 路径上的数据可控性和安全配置。构造 payload、链条利用等运行时技术属于对应黑盒 exploit skill 范畴。

深入参考


3 类漏洞速查表

类型典型 Sink利用条件严重度
反序列化unserialize, phar:// 触发函数用户可控序列化数据 + 可用 Gadget 类Critical
XXEDOMDocument::loadXML, simplexml_load_string, XMLReader::xml外部实体未禁用 + 用户可控 XML 输入High-Critical
SSTITwig::render, Smarty::display, Blade {!! !!}, eval用户输入直接进入模板渲染上下文Critical

反序列化审计要点

  • unserialize() 入口: 搜索所有 unserialize 调用,追踪参数来源(Cookie、Session、缓存、数据库、HTTP 请求体),判断用户是否可控
  • Phar 反序列化: file_exists/is_dir/fopen/filesize/copy 等 40+ 文件系统函数在处理 phar:// 协议时自动触发反序列化,检查路径参数是否用户可控
  • POP 链搜索: 从 __destruct/__wakeup/__toString 入口出发,沿链式方法调用追踪到危险 Sink(文件写入/命令执行/SQL 操作)。重点关注 Composer 依赖中的 Gadget 类
  • allowed_classes 限制: unserialize($data, ['allowed_classes' => [...]]) 是否生效?空数组 []false 才完全安全,true(默认)不做任何限制

XXE 审计要点

  • libxml_disable_entity_loader: 在 PHP < 8.0 中需显式调用 libxml_disable_entity_loader(true) 禁用外部实体。PHP 8.0+ 该函数已废弃且默认禁用,但 LIBXML_NOENT 标志仍可重新启用
  • DOMDocument 风险: loadXML($input, LIBXML_NOENT) 是最大风险点,该标志会展开外部实体。即使不传 LIBXML_NOENT,PHP < 8.0 默认仍可能加载实体
  • SimpleXML/XMLReader: simplexml_load_string 默认安全(PHP 8.0+),但 LIBXML_NOENT 标志使其危险;XMLReader::xml 同理
  • 盲 XXE vs 带外: 解析结果是否回显到页面?无回显时检查是否可利用带外通道(HTTP/FTP/DNS)

SSTI 审计要点

  • Twig: 普通 {{ user_input }} 变量输出通常只是渲染变量并受自动转义保护;SSTI 重点检查用户输入是否进入模板源码解析流程,如 createTemplate($userInput)、动态拼接模板字符串,或沙箱模式 sandbox 策略过于宽松(允许危险 filter/function)
  • Smarty: {php} 标签(Smarty 3.1+ 已废弃但可能未禁用)、{if} 表达式中注入 PHP 函数调用({if system('id')}{/if}
  • Blade: {!! $var !!} 输出未转义内容,若 $var 用户可控则存在 XSS 或更严重风险;@php 指令如果可注入则直接 RCE
  • 自定义模板引擎: 搜索 eval/preg_replace(/e) + 字符串替换模式,自研模板引擎常见的致命组合

检测清单

  • 所有 unserialize 调用点已逐一审查参数来源
  • Phar 协议触发函数的路径参数可控性已检查
  • POP 链入口魔术方法已列举,链路可达性已追踪
  • allowed_classes 配置已验证,默认值 true 已标记
  • XML 解析器的 LIBXML_NOENT 标志使用情况已确认
  • libxml_disable_entity_loader 调用状态已检查(PHP < 8.0)
  • Twig/Smarty/Blade 模板中用户输入的渲染方式已审查
  • 自定义模板引擎的 eval 调用已排查
  • 严重度评分使用了统一公式,与 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 Serialization Audit AI skill do?

PHP 源码序列化与模板类漏洞审计。当在 PHP 白盒审计中需要检测反序列化、XML 解析或模板注入漏洞时触发。 覆盖 3 类风险: PHP 反序列化(unserialize/phar 反序列化/POP 链构造)、 XXE(XML 外部实体注入/libxml 配置)、SSTI(模板注入/Twig/Blade/Smarty 引擎)。 需要 php-audit-pipeline 提供的数据流证据。

Why use Php Serialization Audit on TypingMind?

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

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

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