# Run a Security Audit on a WordPress Plugin

Yes. The agent maps every entry point in the plugin, checks capability, nonce, input and output handling at each, and returns a private report with file and line.

[Run this on Rush](https://cloud.getrush.ai/run/security-audit/wordpress-plugin/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The audit starts with an inventory, because a plugin's attack surface is the list of ways a request can reach its code. In a plugin like WordPress/two-factor, the agent finds REST routes under the `two-factor/1.0` namespace that each provider registers in its own `register_rest_routes()`, login-form handlers that read `$_REQUEST` and `$_POST` before any user is signed in, the profile form save guarded by `check_admin_referer( 'user_two_factor_options', ... )`, a settings screen that requires `manage_options`, and a WP-CLI command class with `status`, `enable`, `disable`, `unlock` and backup-code subcommands. Each becomes a row in a table: the hook or route, the function that handles it, the capability check, the nonce, and what it reads from the request.

Then the tools run, as a baseline and not as the audit. The plugin's own `composer lint` runs PHPCS with the WordPress and VIP security sniffs and `composer lint-phpstan` runs PHPStan at the level in `phpstan.dist.neon`; neither needs a WordPress install. A maintained plugin passes both, which means the findings worth a person's time are the ones a linter was told to skip. So the agent reads each `phpcs:ignore` comment in the non-test source, 41 of them here, and each exclusion in `phpcs.xml.dist`, and decides line by line whether the reason still holds. A suppressed nonce warning on a line that only reads a redirect target passed through `esc_url_raw` and later `wp_safe_redirect` is fine; the same suppression on a line that changes state would be a finding.

For a plugin that handles credentials the agent follows each secret from creation to comparison. Here backup codes are stored through `wp_hash_password` and checked with `wp_check_password`. The emailed token is stored as `wp_hash( $token )`, compared with `hash_equals`, and expires after a lifetime that defaults to 15 minutes and that a filter can change. The login nonce key comes from `random_bytes( 32 )`. The TOTP key is written to user meta under `_two_factor_totp_key` with `update_user_meta`, and a code is compared with `hash_equals` and refused if its time step is not later than the last successful one. The report records how each value is stored, what someone with read access to the user meta table would obtain, and whether any comparison can leak through timing.

The last pass covers what configuration can undo. Filters are part of a plugin's surface: the code comments on `two_factor_revalidate_time` say a falsy return removes revalidation altogether, and `two_factor_providers` lets other code register a provider class by file path. The `Two_Factor_Dummy` provider is removed unless `WP_DEBUG` is on, so the report asks where debug mode could be enabled in production. The agent also checks rate limiting on failed codes, what `uninstall()` deletes and what it leaves, and that no query is built by hand; this plugin's non-test source never touches `$wpdb`. No WordPress site runs in the sandbox, so every finding is marked as confirmed by reading or as needing a running site to confirm, and nothing is claimed as exploited.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Audit this WordPress plugin for security problems and write the result to security-audit.md. Change no code, open no issue and no pull request, and post nothing publicly: read SECURITY.md first and follow its reporting route in your recommendations. Read the main plugin file, composer.json, phpcs.xml.dist, phpstan.dist.neon and any AGENTS.md or contributor notes. Install php and composer if your sandbox lacks them, run composer install, then run the project's PHPCS and PHPStan scripts and record the results as a baseline. Build a table of every entry point: REST routes with their permission_callback, AJAX actions, admin-post and form handlers, login hooks, shortcodes, WP-CLI commands and cron callbacks. For each give the handler, the capability check and whether it checks the specific object being changed, the nonce, and every request value it reads with how it is unslashed, sanitized and validated. Read every phpcs:ignore and ruleset exclusion in non-test code and judge whether its reason holds. Follow each secret or token from generation to storage to comparison: source of randomness, hashing, constant-time comparison, expiry, reuse and rate limiting. Check output escaping, redirects, file and remote requests, direct database queries, uninstall cleanup, and every filter that can weaken a check. Do not start a WordPress site. Mark each finding as confirmed by reading or needs a running site, with file and line, severity, the conditions an attacker needs, and the fix. End with the list of what you checked and found sound, so the report shows its coverage.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The result is `security-audit.md` as an artifact on the session, with a `url` that downloads it without a key for an hour; reading the session again returns a fresh link. Nothing is pushed to the repository and nothing is posted to GitHub, which matters for a plugin whose `SECURITY.md` routes reports through a private program.

The report has four parts. The entry-point table comes first, since a reader can check it against the code in minutes and any row with an empty capability cell is a lead. Findings follow, each with its file and line, severity, what an attacker must already have, whether it was confirmed by reading or needs a running site, and the change that closes it. Then the reviewed suppressions, each with a verdict. Last is the coverage list: what was examined and judged sound, with the lines that justify the judgment.

A maintainer reads the conditions on each finding before the severity. A weakness that requires the `manage_options` capability, or another plugin returning a hostile value from a filter, is a different matter from one any signed-out visitor can reach, and the report states which is which without deciding what the project's threat model should be.

## Run it on every release candidate

The natural moment is before a version is tagged. The person preparing the release sends this body to `POST /o/{org}/sessions` with the release branch in the resource URL, as `https://github.com/your-org/your-app/tree/release-branch`, and a `request_id` that is a UUID v5 of the repository and version so a second click starts nothing new. A `webhook_url` on the key receives `run.completed` with `session_url` when the report is ready.

An agency that maintains many plugins can keep a standing check with an automation in each plugin's Project: this prompt, read-only switched on, and a `schedule` trigger with a monthly `cron`. Each fire starts one run whose report is an artifact on its session, visible to the members of that Project and not to the public repository.

## Why run it on Rush?

An audit means installing a plugin's dependency tree and running tools over code you may not trust yet, such as a plugin you are about to adopt or a contributor's large branch. In its own sandbox that touches nothing else: no local WordPress, no saved credentials, no other checkout. Every command the agent ran and every file it opened is in the transcript at `GET /o/{org}/sessions/{id}/messages`, so the coverage list at the end of the report can be checked against what was read.

The report is also private by construction. It is a file on a session in your own org, not a comment on a public pull request, so a real finding can go through the project's disclosure process before anyone else sees it.

## Frequently asked questions

### Does it try to exploit what it finds?

No. It starts no WordPress site and sends no requests to any site of yours. Findings come from reading the code and are labelled as confirmed by reading or as needing a running site to confirm. If you want proof against a staging site, that is a second run with a prompt that names the site and what it may do there.

### Is this a replacement for a professional audit or a bug bounty?

No. It is a thorough first pass that inventories entry points and checks the well-known WordPress mistakes at each one, which is where most plugin vulnerabilities come from. Logic flaws that depend on how a site is configured still need a person who knows the deployment.

### Can it audit a plugin I did not write, before I install it?

Yes, if the code is in a repository the Rush GitHub App can reach. Put the plugin's source in a private repository of your own and name that in `resources`. The agent audits what is in that checkout, so say which version it is and where it came from.

### Will the findings appear on GitHub?

No. The prompt tells the agent to open no issue and no pull request, and the report is returned as a session artifact. Share it through whatever private channel your `SECURITY.md` names.

## More WordPress plugin jobs

- [Review Pull Requests on a WordPress Plugin](https://getrush.ai/run/review-pull-requests/wordpress-plugin/)

## The same job on other stacks

- [Run a Security Audit on an Angular App](https://getrush.ai/run/security-audit/angular/)
- [Run a Security Audit on an ASP.NET Core App](https://getrush.ai/run/security-audit/aspnet-core/)
- [Security Audit of a Chrome Extension](https://getrush.ai/run/security-audit/chrome-extension/)
- [Run a Security Audit on an Electron App](https://getrush.ai/run/security-audit/electron/)
- [Run a Security Audit on an Elixir App](https://getrush.ai/run/security-audit/elixir/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
