=== phpwarden ===
Contributors: phpwarden
Tags: security, vulnerabilities, monitoring, inventory, cve
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.4.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Reports installed plugins, themes, WordPress and PHP versions to phpwarden, which ranks vulnerabilities by real-world exploitation.

== Description ==

phpwarden connects a WordPress site to a [phpwarden](https://phpwarden.io/) project.

https://www.youtube.com/watch?v=eBR4--6SfsY

The plugin reports which components are installed. Your phpwarden dashboard matches them against known vulnerabilities and ranks the results by real-world exploitation: first whether a vulnerability is in the CISA Known Exploited Vulnerabilities (KEV) catalog, then by its EPSS score. You see what to patch first instead of a flat list of CVEs.

= What it does =

* Sends an inventory report twice a day, shortly after a plugin or theme is installed, updated, activated, deactivated or deleted, and when you press "Send report now".
* Shows the result of the last report on the settings page: time, status, and the number of exposed components and KEV-listed vulnerabilities.
* Optionally (off by default, separate consent) checks the site daily for changed or unexpected PHP files, new administrator accounts and suspicious scheduled tasks, and includes the result in the report.
* Report only: it never makes changes to your site on behalf of the service, and ignores any instruction in the service's response.

= What it is not =

This plugin is **not a firewall and not a malware scanner**. It does not block requests, look for malware signatures or clean infections. The optional tamper check tells you that files changed; it does not remove anything. It runs alongside security plugins such as Wordfence or Patchstack and does not replace them.

= Data sent =

Each report contains exactly this, and nothing else:

* The plugin's own agent version (for example `phpwarden-wp/1.4.0`).
* The site address (`home_url()`).
* The PHP version and PHP server API (for example `fpm-fcgi`).
* The WordPress core version.
* For every installed plugin: slug (directory name, or for a single-file plugin its file name without .php), main file path relative to the plugins directory, name, version, whether it is active, and the newer version WordPress knows of, if any.
* For every installed theme: slug (directory name), name, version, whether it is active, and the newer version WordPress knows of, if any.
* `remote_updates: false`, a fixed value telling the service that this plugin never accepts actions from it.
* Only if you also check the separate, optional "Usage names" box: `usage`, four lists of names (no content) used to mark findings that are likely not reachable on your site. They are: registered shortcodes and blocks that appear in published posts, pages or widgets (up to 2,000 recent published posts are read on your site to find them), registered REST API namespaces, and registered AJAX action names, plus the number of posts read. At most 300 names per list.
* Only if you also check the separate, optional "Tamper check" box: `accounts`, `cron` and `integrity`, the result of the daily tamper check: the login names, user IDs and registration dates of administrator accounts (no e-mail addresses); the names of scheduled tasks, and which of them carry PHP code or a long encoded string in their arguments (the arguments themselves are not sent); and for each changed or unexpected PHP file its path, which check found it (official checksum, recorded baseline or the uploads rule), and the names of any well-known backdoor patterns seen in it, plus a per-component summary (version, number of files, date of the baseline). At most 100 files. File contents are never sent.

The project token is sent in the `Authorization` header to identify your project. No e-mail addresses, passwords, post content, visitor data, file contents or secrets are sent, and no user accounts unless you turn on the optional tamper check (administrator login names only). The plugin loads no external assets and contains no tracking.

= Tamper check (optional, off by default) =

A separate checkbox on Settings > phpwarden, unchecked by default, and only active while the main consent box is also checked.

Once a day, in short background steps run by WP-Cron, the site itself:

* compares WordPress core and each plugin from WordPress.org with the official checksums for the installed version (from api.wordpress.org and downloads.wordpress.org);
* lists PHP files that do not belong: extra PHP in wp-admin or wp-includes or inside a WordPress.org plugin, and any PHP file in the uploads folder (an empty "Silence is golden" index.php is ignored);
* for themes, premium and custom plugins, must-use plugins and drop-ins, which have no official checksums, records a checksum of each PHP file the first time and reports files that change or appear later. A new version records them again;
* checks changed and unexpected PHP files for nine well-known backdoor patterns, such as eval of decoded data or request input passed to a command function;
* lists administrator accounts and scheduled tasks, so the dashboard can tell you when a new administrator appears or a task carries code.

It only reads. It never changes, moves or deletes a file. It is **not a malware scanner**: a file that was already malicious when its baseline was recorded is not reported, and apart from administrator accounts and scheduled tasks the database is not read. After you have checked a reported change yourself, "I checked the changes: accept the current files" (or `wp phpwarden integrity --accept`) records the current files as the new baseline. Turning the check off removes everything it stored.

= Configuration in wp-config.php =

    define( 'PHPWARDEN_TOKEN', 'your-project-token' );
    define( 'PHPWARDEN_API', 'https://app.phpwarden.io' );

Constants take precedence over the settings page and make the corresponding field read-only.

= WP-CLI =

    wp phpwarden activate <token> --consent   # stores the token, records consent, sends a report
    wp phpwarden sync                         # sends a report now (only if consent is given)
    wp phpwarden status
    wp phpwarden disable                      # withdraws consent; nothing more is sent
    wp phpwarden integrity [--enable] [--send] # runs the tamper check now and prints the result
    wp phpwarden integrity --accept           # after checking the changes: record the current files
    wp phpwarden integrity --disable          # turns the tamper check off and removes its data

= Multisite =

The plugin can be network-activated. It reports once for the whole network, from the network's main site, listing all installed plugins and themes. A plugin counts as active when it is network-active or active on the main site; plugins active only on other sites of the network are reported as inactive. Settings are on the main site (Settings > phpwarden) and require a network administrator.

== External services ==

This plugin connects to the phpwarden service at `https://app.phpwarden.io` (or the API base URL you configure). It is required for the plugin to do anything useful: the service matches your inventory against vulnerability data and shows the result in your dashboard.

* **Consent first:** nothing is sent until an administrator checks "I agree to send this site's software inventory to the phpwarden service" on Settings > phpwarden, or runs `wp phpwarden activate <token> --consent`. The box is unchecked by default. Defining `PHPWARDEN_TOKEN` in wp-config.php does not give consent on its own. Unchecking the box (or `wp phpwarden disable`) stops all reports.
* **What is sent and when:** the inventory listed under "Data sent" above, together with your project token, twice a day, about a minute after plugin or theme changes, when you press "Send report now", and when you run `wp phpwarden activate` or `wp phpwarden sync`.
* **Nothing is sent** without both consent and a project token.
* **WordPress's own update check:** to report which plugins and themes have updates waiting, the plugin reads WordPress's cached update list. If that list is missing or more than 12 hours old, it first asks WordPress core to refresh it, which is the same request to api.wordpress.org that WordPress makes on its own schedule. This happens only when a report is being sent, so never without consent, and it is skipped when the site has turned off WordPress's update checks.
* **Tamper check (optional):** only when its box is checked, the site downloads the official checksums of its WordPress version from api.wordpress.org (through WordPress core's own function) and of each installed plugin from `https://downloads.wordpress.org/plugin-checksums/<slug>/<version>.json`, once a day. These requests contain the WordPress version and locale, or a plugin's slug and version, and nothing else. WordPress.org: [privacy policy](https://wordpress.org/about/privacy/).
* Service provider: phpwarden. [Terms of service](https://phpwarden.io/terms), [privacy policy](https://phpwarden.io/privacy).

== Installation ==

1. Install and activate the plugin.
2. Create a project in your phpwarden dashboard and copy its token.
3. Go to Settings > phpwarden, paste the token, check the consent box (it explains exactly what is sent) and save.
4. Press "Send report now". The site appears in your dashboard.

== Frequently Asked Questions ==

= Do I need a phpwarden account? =

Yes. The plugin only collects the inventory; matching and ranking happen in your phpwarden dashboard.

= Does this replace Wordfence or Patchstack? =

No. This plugin is not a firewall or malware scanner. It tells you which installed components have vulnerabilities that are being exploited in the wild, so you know what to update first. Keep your firewall or scanner.

= Can phpwarden change my site? =

No. The plugin only sends the report described above. It never installs, updates, activates or deactivates anything, never creates or changes user accounts, and never runs instructions from the service. You make every change yourself, in WordPress.

= Where is the token stored? =

In the WordPress options table, or in `wp-config.php` if you define `PHPWARDEN_TOKEN`. The settings page only ever shows its last four characters.

= What happens if the report cannot be sent? =

Nothing on your site changes. The error is shown in the status box and the plugin tries again at the next scheduled report.

= Does it slow down my site? =

No. Reports are sent in the background by WP-Cron, not during visitor page loads, and the plugin adds nothing to the front end.

= What is removed on uninstall? =

All plugin options (token, settings, status) and its scheduled events.

== Changelog ==

= 1.4.0 =
* New optional "Tamper check", off by default and with its own consent box: once a day the site compares WordPress core and WordPress.org plugins with the official checksums, lists PHP files in the uploads folder, notices changed PHP files in themes and premium plugins, and reports new administrator accounts and scheduled tasks that carry code. Read only: it never changes a file. Not a malware scanner.
* New `wp phpwarden integrity` command.
* Uninstall also removes the usage-names setting.

= 1.3.0 =
* New optional "Usage names" setting, off by default and separate from the main consent: also sends the names (never content) of shortcodes and blocks used in published content, registered REST namespaces and registered AJAX actions, so the dashboard can tell which findings are likely not reachable on this site. Still report only.

= 1.2.0 =
* Nothing is sent until an administrator explicitly agrees: a new, unchecked consent box on the settings page (or `wp phpwarden activate <token> --consent`). This includes sites with the token set in wp-config.php.
* The settings page says what is sent and where, with links to the terms and privacy policy.
* New `wp phpwarden disable` to withdraw consent; `wp phpwarden status` shows the consent state.
* Readme documents every field sent and every action that sends a report.
* A notice on the Plugins screen when reports are off because consent has not been given yet (for example after upgrading from 1.1.0).
* The WordPress update-list refresh is skipped on sites that have turned off WordPress's update checks.

= 1.1.0 =
* Report only. Removed the optional remote updates: the plugin never acts on the site for the service.

= 1.0.0 =
* Initial release: inventory reports, status box, WP-CLI commands (it also had optional remote updates, removed in 1.1.0).
