xerj-security-audit
Qué hace
Revisa una base de código en busca de problemas de seguridad, indexándola y comprobando cada llamada a función peligrosa, con un registro que demuestra que la búsqueda fue completa. Es para desarrolladores y revisores de seguridad que quieren una auditoría defendible y no un escaneo rápido.
Cuándo usarla
- ✓Cuando quieres revisar la seguridad de una app o un plugin de PHP con un registro de cobertura completa.
- ✓Cuando necesitas listar cada llamada peligrosa de una base de código.
- ✓Cuando quieres que los hallazgos se registren en un libro de contabilidad que puedas consultar después.
Link de la skill
https://github.com/xerj-org/xerj/blob/main/docs/case-studies/wordpress-security-audit/skill/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Revisa la seguridad de este plugin de PHP y demuestra que no se nos ha escapado ninguna llamada a función peligrosa.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La skill indexa el código una vez, traza las funciones peligrosas conocidas y localiza cada punto de llamada con un análisis del árbol de sintaxis. Contrasta el resultado con una búsqueda de texto sencilla para demostrar que no se omitió nada, y después registra los hallazgos en un libro consultable.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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
Preguntas frecuentes
¿Qué significa la afirmación de cobertura?
Cada llamada peligrosa encontrada por el análisis de sintaxis se contrasta con una búsqueda de texto sencilla, así que la revisión no muestra huecos.
¿Qué lenguajes admite?
PHP es el ejemplo principal, y otros lenguajes necesitan su propia gramática y su propio mapa de funciones.
¿Necesita un servicio en ejecución?
Sí. Necesita un nodo de búsqueda local en marcha y los paquetes de análisis tree-sitter instalados.
Detalles
Descripción original del autor
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
Popularidad
- Estrellas en GitHub
- 19 mil
- Posición en el ranking
- #10503
- Licencia
- Apache-2.0
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
xerj
19 milAyuda a tu agente a encontrar la documentación y los contratos actuales de XERJ antes de indexar carpetas, buscar datos o configurar la memoria del agente.
xerj-knowledge
19 milAyuda a tu agente a buscar en tus documentos, notas, PDF, hojas de cálculo y correos locales, y a citar el archivo y la página de donde sale cada respuesta.
xerj-code
19 milAyuda a tu agente a dejar de adivinar al usar una API desconocida, clonando código de referencia, indexándolo y leyendo primero la implementación exacta.
Skills parecidas
reverse-engineer-anything
422 milAyuda a tu agente a revisar apps y paquetes ya publicados para explicar sus funciones, comparar versiones o guiar una reconstrucción, usando la herramienta REA.
1password
394 milAyuda a tu agente a instalar la CLI de 1Password, iniciar sesión y leer o inyectar secretos sin imprimir sus valores en el chat.
healthcheck
394 milAyuda a tu agente a auditar el ordenador o servidor que ejecuta OpenClaw en busca de riesgos de seguridad, como SSH, cortafuegos, actualizaciones y copias de seguridad, y después sugerir arreglos seguros.