xerj-security-audit
できること
コードベースをインデックス化し、危険な関数呼び出しをすべて確認して、検索が網羅的だったことを示す記録を残します。簡単なスキャンではなく、説明可能な監査が必要な開発者とセキュリティ審査担当者向けです。
使う場面
- ✓網羅性の記録を残しながら、PHPアプリやプラグインのセキュリティレビューをしたいとき。
- ✓コードベース内のすべての危険な呼び出しを一覧にしたいとき。
- ✓後で照会できる台帳に所見を記録したいとき。
スキルのリンク
https://github.com/xerj-org/xerj/blob/main/docs/case-studies/wordpress-security-audit/skill/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このPHPプラグインのセキュリティレビューをしてください。危険な関数呼び出しを見落としていないことを示してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルはコードを一度インデックス化し、既知の危険な関数を対応付け、構文木のスキャンで各呼び出し箇所を見つけます。その結果を単純なテキスト検索と照合して、見落としがないことを確認し、所見を検索可能な台帳に記録します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
XERJ whitebox security audit
Run a security review where XERJ is the agent's second brain: index the code
once, then interrogate it — never load whole files. The deliverable is a
defensible coverage claim, not a vibe. Scripts referenced below live in
docs/case-studies/wordpress-security-audit/sink-census/ (copy them alongside
this skill to reuse in another repo).
When to use
- "Security-review this codebase / WordPress plugin / PHP app with coverage."
- "Find the dangerous calls / sinks and prove we didn't miss any."
- "Run the sink census / audit ledger."
Prerequisites (state them, then set up)
- XERJ running, ES-compatible, on
http://127.0.0.1:9200(xerj --insecure --data-dir ./data). pip install tree-sitter tree-sitter-php(+ the grammar for the target language).- The target source tree on disk.
The loop (do these in order; report honestly at each step)
1. Map the dangerous functions (knowledge)
Use php_dangerous_functions.json — 275 PHP built-ins/constructs across 28
categories (command/code exec, unserialize, include loaders, file r/w/delete,
SSRF, SQL drivers, XXE, callables, variable-injection, reflection, weak crypto/
random, type-juggling, …), each with vuln class + the taint-relevant argument.
For another framework/language, extend this map — it is data, not code.
2. Census every call site (AST)
python3 sink_census.py <src> parses every file with tree-sitter and records
2b. Census the dangerous PATTERNS (the class a sink list misses)
python3 pattern_census.py <src> AST-detects the non-function vulns — loose ==
/ magic-hash, non-strict in_array, strcmp-with-array (?login[]=), @
suppression, variable-variables, unsafe setcookie, switch-on-request,
Host-header trust, ORDER-BY injection — into wppatterns. Semantic classes a
census can't decide (SQL truncation, charset SQLi, second-order, phar, TOCTOU,
upload-exec, is_numeric bypass, regex-anchor, session-fixation, wrong-context
XSS) are catalogued in php_dangerous_patterns.json with detection guidance and
swept by reasoning. FULL REFERENCE: PHP-SECURITY-GUIDE.md — every function AND
pattern mapped to attack + detection + safe recipe.
every call site of a catalogued function (calls, methods, constructs like
echo/include/backtick, new ReflectionFunction). tree-sitter captures real
calls regardless of formatting/namespacing — grep cannot.
3. PROVE coverage (the guarantee — do not skip)
The census reconciles every grep occurrence against the AST, using AST string/comment/inline-HTML node ranges as the oracle. A clean run prints:
UNEXPLAINED: 0 => coverage PROVEN (0 gaps)
If UNEXPLAINED > 0, EVERY residual must be resolved (it is either a real call the extractor missed — fix the catalog/node-handling — or a proven non-call). Never report coverage while residuals are unexplained.
4. Index + triage (XERJ wpsinks)
The census bulk-indexes one doc per call site (file,line,fn,class,arg). Query
the risk profile; the rare high-value classes are the must-review set (in WP core:
RCE-command 11, deserialization 13, SQL 200, SSRF 107). You can now guarantee
you've seen every one.
5. AI-enrich into a ledger (enrich_pipeline.py)
For each high-risk site: read the arg + enclosing code, decide reachable
(request/cache/trusted/literal), guarded (which defense), severity, and a
verdict; write it back to wpsinks. This is the embedding-pipeline analogue,
but the enrichment is reasoned security judgement, and it accretes across runs.
Enrich 100% of the rare classes; queue the long tail.
5b. Trace any sink through the API (trace_sink.py <file> <line>)
Joins wpsinks -> wpaudit -> wpauthz -> reverse callers with NO local file
access: the sink + verdict, the enclosing function's sources/sinks/sanitizer, its
authz guards, and who calls it + whether they read a request source. The verdict
flags a SOURCE->SINK candidate when a source and an unsanitized sink coexist in a
function. (Reverse callers scan _source calls arrays because of the
array-term engine bug, and restrict common method names like load/query to
the same file to avoid class collision.)
6. Reason about the real bugs (the parts a census can't see)
Sink coverage ≠ total coverage. Also sweep, using the other detectors in the case
study: object-scoped authorization / IDOR (wp_authz_graph.py,
wp_checkuse_idor.py), validator completeness (wp_ssrf_ranges.py — an
incomplete
よくある質問
網羅性の主張とは何ですか?
構文スキャンで見つかった各危険な呼び出しを単純なテキスト検索と照合するため、審査に抜けがないことを示せます。
どの言語に対応していますか?
PHPが主な例です。他の言語には、それぞれの文法と関数の対応表が必要です。
サービスを起動しておく必要がありますか?
はい。ローカルの検索ノードを起動し、tree-sitterの解析パッケージをインストールしておく必要があります。
詳細
作者による元の説明
Coverage-guaranteed whitebox security audit of a codebase using XERJ + tree-sitter AST. Use when the user wants to security-review PHP (or other-language) code with a provable "we enumerated every dangerous call" guarantee, or asks to run the WordPress-style sink census / audit. Drives an index-once, query-read-reason loop; proves zero gaps against grep; enriches findings into a queryable ledger.
repo: xerj-org/xerj
人気
- GitHubのスター
- 19k
- ランキング
- #10503
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
xerj
19kエージェントが、フォルダーのインデックス化、データ検索、エージェントメモリの設定を行う前に、最新のXERJのドキュメントと仕様を確認できるよう支援します。
xerj-knowledge
19kエージェントが、ローカルのドキュメント、メモ、PDF、表計算、メールを検索し、各回答の出典であるファイルとページを示せるよう支援します。
xerj-code
19kエージェントが、参考になるコードを複製してインデックス化し、正確な実装を先に読むことで、不慣れなAPIを推測しないよう支援します。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。