# Security Auditing Code Review > Úsalo al auditar o revisar código de un plugin o tema WordPress existente, triar un informe de vulnerabilidad o endurecer código heredado, con una metodología sistemática. Fuente: https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/security-auditing-code-review Markdown: https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/security-auditing-code-review.md Repositorio: https://github.com/wpultimatesecurity/WordPress-Security-Skills Autor: wpultimatesecurity Licencia: MIT Actualizado: hace 2 meses Coste de contexto: 101 tok instalada, 3.8k tok al activarse, 14.4k tok con todos los archivos del bundle Bundle: 9 archivos, 56 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill security-auditing-code-review --agent claude-code # Cursor npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill security-auditing-code-review --agent cursor # Codex npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill security-auditing-code-review --agent codex # Gemini CLI npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill security-auditing-code-review --agent gemini # Windsurf npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill security-auditing-code-review --agent windsurf # Cline npx -y skills add wpultimatesecurity/WordPress-Security-Skills --skill security-auditing-code-review --agent cline ``` ## Qué hace - Aplica una metodología sistemática para auditar código WordPress: mapear fronteras de confianza, inventariar sinks sensibles y rastrear controles - Clasifica cada hallazgo como confirmed, needs_validation o rejected antes de asignar severidad - Genera informes de hallazgos con ubicación, flujo de datos, impacto, remediación concreta y verificación - Ejecuta un script heurístico de búsqueda de sinks de seguridad (scan-security-sinks.sh) con ripgrep - Re-verifica correcciones aplicadas y distingue comprobaciones ejecutadas de propuestas ## Cuándo usarla - Revisar un PR, plugin o tema en busca de defectos de seguridad - Auditar código heredado o de terceros antes de desplegarlo - Triar un informe de vulnerabilidad o comportamiento sospechoso - Producir un informe de hallazgos de seguridad con severidades y fixes ## Qué la activa - "Audita este plugin de WordPress en busca de vulnerabilidades de seguridad" - "Revisa este PR antes de publicarlo, busca problemas de seguridad" - "Tenemos un informe de una vulnerabilidad, ayúdame a triarla" - "Haz una revisión completa de seguridad de este tema de terceros" ## Antes de instalar - Para el script de inventario de sinks hacen falta Bash y ripgrep (rg); las pruebas en ejecución solo deben hacerse en un WordPress local desechable, nunca en un sitio en producción. - Necesita en el PATH: rg ## Archivos - SKILL.md — 15 KB - references/attack-classes.md — 7 KB - references/audit-checklist.md — 4 KB - references/full-audit-workflow.md — 7 KB - references/grep-patterns.md — 5 KB - references/report-template.md — 6 KB - references/resource-exhaustion.md — 4 KB - references/severity-anchors.md — 4 KB - scripts/scan-security-sinks.sh — 4 KB ## SKILL.md Reproducido tal cual desde wpultimatesecurity/WordPress-Security-Skills bajo MIT. Esta sección es el documento original y está en inglés. # Security auditing & code review ## When to use this skill Use this skill when the task is to **evaluate** code rather than write a feature: - Reviewing a PR/plugin/theme for security defects. - Auditing inherited or third-party code before deploying it. - Triaging a reported vulnerability or suspicious behavior. - Producing a security findings report with severities and fixes. This skill is the audit counterpart to the secure-coding skills. When you find an issue, fix it using the relevant skill (`nonces-csrf-protection`, `output-escaping`, `sql-injection-prevention`, etc.). ## Operating modes - **Guidance mode** — a focused question, one handler, a triage of a single report, or a methodology question. Answer inline with the relevant parts of this skill; do not produce the full report or claim coverage beyond what was examined. - **Full review mode** — an explicit audit, pre-release security review, third-party code assessment, or a requested findings report. Run every step below, follow the [full audit workflow](references/full-audit-workflow.md) (coverage ledger, hunting, independent validation), and use the full [report template](references/report-template.md). In either mode, run code only on a disposable local WordPress with dummy users and secrets; never probe a live or client site. A fact that source and the local stack cannot settle becomes `needs_validation`. If the request could mean either, ask one focused question before starting a full review. ## Core principles (and why they matter) 1. **Follow the data, not the file order.** Trace untrusted input from its entry point (`$_GET`/`$_POST`/`$_FILES`/REST) to where it is used (DB, output, filesystem). Bugs live on those paths. 2. **Map trust boundaries first.** Enumerate AJAX actions, REST routes, forms, shortcodes, cron jobs, and CLI commands. Decide which need authentication, authorization, CSRF protection, validation, and output escaping for their context. 3. **Trace controls, not proximity.** A nearby nonce, capability check, escaper, or `prepare()` call does not establish protection. Verify it governs the reachable operation; absence from the same line/file does not establish a vulnerability. 4. **Require a boundary and a result.** A confirmed finding names the lower-trust principal (anonymous visitor, subscriber, contributor, author, editor, shop manager), the input or action it controls, the control that should stop it, the boundary crossed, the affected user or resource, and the concrete result. If any part is missing, it is not confirmed. 5. **Separate certainty from priority.** Only confirmed findings receive severity, rated from demonstrated impact and reachability with the [severity anchors](references/severity-anchors.md). A blocked hypothesis is `needs_validation`, not a low-severity finding. 6. **Report with a concrete fix.** Each finding = location, what's wrong, why it matters, and the corrected code. A finding without a fix is half-done. 7. **Don't trust comments or names.** Verify what the code does, not what it claims. ## Step-by-step implementation 1. **Record review context before inventory/scanning:** target, immutable revision (commit/tag resolved to commit/checksum), reviewer, date, scope, exclusions, methods/tool versions, active-testing authorization, and limitations. Keep unavailable values explicitly Unknown; never infer them. Use the full [report template](references/report-template.md) throughout the review. 2. **Inventory entry points:** grep for `wp_ajax_`, `register_rest_route`, `admin_post_`, `add_shortcode`, `$_GET`/`$_POST`/`$_REQUEST`/`$_FILES`, form handlers. In full review mode, record them as coverage units (entry point × boundary × attack class) so the report states what was covered, blocked, deferred, or out of scope. 3. **Check applicable controls on each path:** transport-appropriate authentication and CSRF protection, resource-level authorization, shape/type validation, sanitization, output escaping, and safe query construction. 4. **Inventory sinks**, including safely guarded ones: database calls, output, filesystem operations, uploads, code execution, deserialization, redirects, and outbound requests. Follow the input and controls before labeling any hit. Then hunt the classes a sink sweep misses: business logic, feature abuse, second-order paths, and the "obvious things" in [attack classes](references/attack-classes.md). 5. **Classify before rating:** give every candidate one verdict. - `confirmed` — complete reachable trace, boundary, and result; severity from the [severity anchors](references/severity-anchors.md). - `needs_validation` — a source-grounded hypothesis blocked by one exact missing fact (host/WAF config, a filter added elsewhere, a role customization). Record the blocker and a safe validation plan; assign **no** severity. Scanner hits and incomplete traces go here. - `rejected` — disproved by a control that governs the path; record the control so the candidate is not re-reported. Keep defense-in-depth advice under Hardening recommendations, outside all verdicts. 6. **Report:** evidence/data flow, exploit prerequisites, impact, concrete remediation, verification, and references. Redact secrets/PII. Do not invent CVSS/CWE values, remediation hours, response promises, or an overall secure score. 7. **Re-verify** fixes across in-scope paths; distinguish executed checks from proposed checks. Record residual limitations and refuse blanket release sign-off or security certification for incomplete scope. After recording context, use the read-only [sink inventory helper](scripts/scan-security-sinks.sh) if Bash and ripgrep (`rg`) are available. From this skill directory: ```bash bash scripts/scan-security-sinks.sh /path/to/plugin-or-theme ``` This is a **heuristic text search, not a security audit or vulnerability detector**. It includes safe calls, comments, and strings; it does not prove missing controls. No hits is not proof of safety. It searches PHP/PHTML/INC files using ripgrep ignore rules, skipping hidden/binary files and symlinks. Dynamic/multiline calls and other file types require separate review. Source lines can contain secrets; keep the output local and redact before sharing. `--help` explains scope and exit codes (0: completed, with or without hits; 2: usage/search error). See [`references/grep-patterns.md`](references/grep-patterns.md) for additional searches and [`references/audit-checklist.md`](references/audit-checklist.md) for the full review pass. ### Supporting references | Reference | Load when | | --- | --- | | [WordPress security audit checklist](references/audit-checklist.md) | Performing the full manual audit pass across entry points, controls, and sinks. | | [Audit grep patterns](references/grep-patterns.md) | Expanding the entry-point and sink inventory with additional heuristic searches. | | [WordPress security review report template](references/report-template.md) | Recording review context before inventory and reporting evidence, classification, verification, and limitations. | | [WordPress attack classes](references/attack-classes.md) | Hunting access-control, business-logic, feature-abuse, second-order, wildcard, and obvious-exposure classes beyond the sink sweep. | | [Full audit workflow](references/full-audit-workflow.md) | Running full review mode: execution safety, coverage ledger, hunting waves, independent validation, profiles, budget, and re-audits. | | [Resource exhaustion](references/resource-exhaustion.md) | Reviewing public or low-role paths that do expensive work, store data, schedule jobs, or spend paid API quota. | | [Severity anchors](references/severity-anchors.md) | Assigning severity to a confirmed finding or checking that a rating matches demonstrated impact. | ## Common AI mistakes / anti-patterns ### Mistake 1 — Reviewing for style, missing the security sink ```php // Reviewer comment: "rename $q to $query for clarity" ← misses the actual bug: $rows = $wpdb->get_results( "SELECT * FROM t WHERE id = " . $_GET['id'] ); // SQL injection ``` Flag the **injection** first. Cosmetic notes never outrank a Critical finding. ### Mistake 2 — Assuming a nonce implies authorization (or vice versa) ```php // A nonce check is present, so the reviewer marks it "secure" — check_admin_referer( 'act' ); delete_user( absint( $_POST['id'] ) ); // ❌ still missing current_user_can() ``` Verify **both** controls independently on every state-changing path. ### Mistake 3 — Trusting `sanitize_*` as if it were escaping (or the reverse) ```php // Input was sanitized on save, so output is assumed safe — but context differs: echo ''; // ❌ needs esc_url on output ``` Sanitize-on-input and escape-on-output are separate; check both ends. ### Mistake 4 — Marking everything Critical (or burying real issues) Inflated severity destroys signal. Rate by impact × reachability: an unauthenticated RCE is Critical; a self-XSS reachable only by an admin editing their own profile is Low/Info. Apply the [severity anchors](references/severity-anchors.md): overall severity never exceeds the demonstrated impact. ### Mistake 5 — Reporting the problem without the fix ```text ❌ "Line 42 is vulnerable to XSS." ✅ "Line 42: $name echoed unescaped into HTML (stored XSS, High). Fix: echo esc_html( $name );" ``` ### Mistake 6 — Reporting a principal's own authority as a vulnerability ```php // Reviewer: "Stored XSS — post content is saved without wp_kses_post()." // But only users with unfiltered_html (administrators/editors on single site) reach it: if ( current_user_can( 'unfiltered_html' ) ) { update_post_meta( $post_id, '_custom_html', wp_unslash( $_POST['custom_html'] ) ); } ``` Raw HTML from a principal WordPress already trusts with `unfiltered_html` crosses no boundary. Report it only if a lower-trust principal (a contributor, or a multisite site admin without `unfiltered_html`) can reach the same write, or if the result affects someone the writer could not already affect. ### Mistake 7 — Guessing the deployment ```text ❌ "Exploitable: the site has no WAF." ❌ "Not exploitable: hosts block PHP in uploads." ✅ needs_validation — blocker: whether uploads/ executes .phtml on the target server. Validation plan: owner confirms the web-server handler for uploads/, or reproduce on a disposable local stack with the recorded server config. ``` Host rules, WAF/CDN behavior, `wp-config.php` constants such as `DISALLOW_FILE_EDIT`, and role customizations are real controls. If the decision depends on one that is not in the reviewed source, do not assume it present or absent; record `needs_validation` with the exact missing fact. ### Mistake 8 — Checklist deviations presented as findings ```text ❌ "[Medium] Plugin directory lacks index.php silence file." ❌ "[Low] needs_validation: possible SSRF if the host allows internal requests." ✅ Hardening: add index.php (no reachable disclosure demonstrated). ✅ needs_validation (no severity): an editor-set webhook URL reaches wp_remote_get(); blocker: whether internal hosts are reachable from the target server. ``` A missing best practice with no affected principal or resource is a hardening note, not a finding. A `needs_validation` item never carries severity. ## Correct code examples Use the full [report template](references/report-template.md) for the review. Keep this compact skeleton for each **confirmed** finding: ```text [SEVERITY] Category — title Location: Exact file:line at the reviewed revision. Evidence/data flow: Reachable source, governing controls, and sensitive sink. Exploit prerequisites: Required identity, nonce access, object restrictions, configuration. Impact: Demonstrated consequences and evidence-based severity rationale. Remediation: Concrete corrected code/configuration with fail-closed controls. Verification: Executed checks and results; proposed checks explicitly unexecuted. References: Relevant official API/security sources. ``` ## Checklist - [ ] Review context records scope, immutable revision, reviewer/date, methods/versions, testing authorization, exclusions, and limitations; unavailable values remain Unknown. - [ ] All in-scope entry points inventoried; no claim extends beyond reviewed paths. - [ ] Full reviews report coverage (covered, blocked, deferred, out of scope); partial or `quick` runs say so. - [ ] Runtime checks ran only on a disposable local WordPress with dummy data. - [ ] State-changing paths checked independently for applicable CSRF and authorization controls. - [ ] Each output checked for context-correct escaping. - [ ] Each custom query checked for `$wpdb->prepare()`. - [ ] File/path operations checked for allowlisting and traversal. - [ ] Dangerous sink hits traced before classifying them as vulnerabilities. - [ ] Each confirmed finding names the lower-trust principal, input, bypassed control, crossed boundary, affected resource, and concrete result. - [ ] Every candidate has one verdict: `confirmed`, `needs_validation` (exact blocker and validation plan), or `rejected` (the governing control recorded). - [ ] Only confirmed findings carry severity, rated with the severity anchors and never above demonstrated impact; `needs_validation` items and hardening stay outside totals. - [ ] Each finding records location, evidence/data flow, exploit prerequisites, impact, concrete remediation, verification, and references. - [ ] Executed checks and results distinguished from proposed checks and unverified fixes. - [ ] Secrets/PII redacted; residual scope limitations explicit; no blanket sign-off or certification. ## Official references - [Plugin Security — Plugin Handbook](https://developer.wordpress.org/plugins/security/) - [Data Validation](https://developer.wordpress.org/apis/security/data-validation/) - [Escaping Data](https://developer.wordpress.org/apis/security/escaping/) - [WPCS — WordPress Coding Standards (security sniffs)](https://github.com/WordPress/WordPress-Coding-Standards) - [OWASP Web Security Testing Guide](https://owasp.org/www-project-web-security-testing-guide/) - [OWASP Top Ten](https://owasp.org/www-project-top-ten/) ## Dónde encaja - Categoría: [Seguridad](https://skillsagentes.com/categorias/seguridad.md) — Auditorías, revisión de dependencias, manejo de secretos y modelado de amenazas. - Creador: [wpultimatesecurity](https://skillsagentes.com/creators/wpultimatesecurity.md) — 27 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Authentication Session Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/authentication-session-security.md): Úsalo cuando el código inicia o cierra sesión, gestiona cookies o tokens de sesión, limita intentos de login o construye un formulario de login propio en WordPress. - [Dependency Supply Chain Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/dependency-supply-chain-security.md): Úsalo cuando un plugin o tema empaquete una librería de terceros, cargue un asset desde un CDN, ejecute código remoto, use Composer o prepare el zip distribuible. - [Secure Plugin Development](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/secure-plugin-development.md): Úsalo al iniciar un plugin o tema de WordPress, al añadir hooks o funciones que manejan peticiones, opciones o salida; establece la línea base segura por defecto. - [Gutenberg Block Editor Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/gutenberg-block-editor-security.md): Úsalo al construir bloques dinámicos o funciones del editor de bloques: render_callback, ServerSideRender, datos REST o register_rest_field, para evitar XSS almacenado y control de acceso roto. - [Multisite Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/multisite-security.md): Úsalo al escribir código para WordPress multisite: switch_to_blog, páginas de red, get_sites o capacidades que difieren entre sitio y red. Evita fugas de datos entre sitios y escaladas de privilegios de red. ## Skills relacionadas - [Ai Llm Integration Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/ai-llm-integration-security.md): Úsalo al construir o revisar funciones de plugin o tema de WordPress que llaman a un LLM: chatbots, generación de contenido, RAG, agentes con herramientas, Abilities API o exposición MCP. - [Ajax Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/ajax-security.md): Úsalo al registrar o manejar AJAX en WordPress vía admin-ajax.php: verifica el nonce, comprueba permisos, sanitiza cada campo y responde con wp_send_json_*, evitando CSRF e inyecciones. - [Authentication Session Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/authentication-session-security.md): Úsalo cuando el código inicia o cierra sesión, gestiona cookies o tokens de sesión, limita intentos de login o construye un formulario de login propio en WordPress. - [Capability Permission Checks](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/capability-permission-checks.md): Protege operaciones privilegiadas en WordPress con current_user_can() usando la capability correcta (no el rol), checks por objeto y nonce, evitando escalada de privilegios y control de acceso roto. - [Cron Background Job Security](https://skillsagentes.com/skills/wpultimatesecurity/wordpress-security-skills/cron-background-job-security.md): Úsalo al programar eventos cron con wp_schedule_event / wp_schedule_single_event o al escribir el callback. Revalida la autorización contra el contexto guardado, no con current_user_can, y mantiene los secretos fuera de las URLs de cron. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)