All articles

An account and settings guard for WordPress: the plugin looks at the result of an attack

Ensomedia Security 1.1.34 records or refuses a change that gives someone administrator rights or opens the site when the request has no right to make it. What it checks, what it cannot see and how to turn it on.

Radek, ENSOMEDIAPublished 4 min readPo polsku

Attacks on WordPress plugins start in many ways and end in much the same way. Someone gets an account with administrator rights, or changes a setting that will give them one: registration is opened, the default role is raised, the administration email address is replaced. A request firewall recognises attack shapes that are already known. A new vulnerability has a shape nobody has described yet.

So in version 1.1.34 the Ensomedia Security plugin has an account and settings guard. It does not look for a known attack. It looks at what the request is trying to change and asks whether the request had the right to change it.

What it checks

The guard reacts when a request tries to:

  • give an account, or a role that accounts already hold, rights to manage users, plugins, themes or settings, or to post unfiltered code,
  • add a network super admin,
  • open registration or raise the default role of new accounts,
  • change the site address, the WordPress address or the administration email address,
  • activate another plugin or switch the theme,
  • switch Ensomedia Security itself off or delete its settings.

WordPress lets only a user with the matching capability make each of these changes. A plugin with a flaw can skip that check and write the change on behalf of someone who is not even signed in. The guard asks again at the moment of the write: who is the signed-in user of this request, and would WordPress let that user make this change.

Two modes

Record only is the default, also after an update. It changes nothing on the site. It writes the event to History: the address the request came from, the path without its query string, and what handled it (an AJAX action, a REST route, a scheduled task or a file). If the alert for new administrators is on, you also get an email, at most ten of these a day.

Block refuses the change. An account keeps its role, a new account gets a role without these rights, a setting keeps its value or is put back, and the plugins and the theme stay as they were. The "Turn on full protection" button sets this mode.

Each History entry says one of three things: refused (the change was not made), put back (the change was made and then undone) or recorded (the change stands).

What passes without a question

Your own changes in the dashboard, WP-CLI, and the installation and updates of WordPress, plugins and themes. Tools that sign in as an administrator pass too, such as remote management of many sites.

A plugin may add a new role with any rights. Creating a role gives nobody anything. The guard judges the moment an account gets that role or the role becomes the default.

If you run a company sign-in service or a directory sync that creates administrators with no one signed in, name its hooks in the SHIELDWAVE_ACCOUNT_GUARD_TRUST constant in wp-config.php. Before you switch to Block, leave Record only on for a few days and read History.

What the guard cannot see

We say this plainly, because it decides how far you can rely on it:

  • a flaw that makes WordPress treat the request as an administrator's. The guard asks who is signed in, so such a flaw passes,
  • code that writes to the database with its own SQL instead of WordPress functions,
  • code that runs before the plugin loads,
  • another plugin's code running in the same request, which can undo a refusal.

The account and settings guard does not replace plugin updates or a firewall. It is one more layer for the day those two fail.

How we checked it

Before the release the feature went through a table of 232 cases on a copy of a real WordPress with WooCommerce. It held attempts to grant rights through every route WordPress offers, and ordinary work: creating accounts in the dashboard, WooCommerce installing its roles, a customer registering at checkout, plugin and theme updates.

The first run of that table found several routes where a change went through without a trace. We fixed them and ran the whole table twice more. In the third run every escalation attempt was refused or put back, and no ordinary action was refused. This is our own test. There is no independent test of this feature.

We did not run the table on a multisite network or on a MySQL database. Those paths are covered by unit tests and by reading the code.

What else is in 1.1.34

  • Search fields are checked against every firewall rule. Before, some attacks passed there as plain text. Ordinary searches still pass, "c++" and "50% off" included.
  • When a firewall rule cannot read a value because of PHP's limits, the request is no longer let through silently. Record only records it and Block refuses it.

How to turn it on

Update the plugin to 1.1.34. The guard starts in Record only. Change the mode under ShieldWave > Settings, in "Account and settings guard", or with the single "Turn on full protection" button on the Overview screen.

The plugin is free and works without an account: Ensomedia Security on WordPress.org.