When Is_Admin() Is Not a Security Check: How a Debug Helper in Social Warfare Became Unauthenticated RCE
Social Warfare 3.5.2 shipped a settings-migration helper that fetched a remote URL and eval()'d the response — guarded only by is_admin(). We walk through the code path, why that guard is a category error, and how to spot the same pattern in your own plugins.
On this page6
The helper nobody remembered was still registered#
Social Warfare's database migration class was written to move settings between sites. In lib/Social_Warfare.php the plugin constructs new SWP_Database_Migration() unconditionally, and the class's constructor hooks itself onto plugins_loaded at priority 100. That means it runs on every request the site serves — front-end, AJAX, REST, cron — not only when an administrator visits the settings screen.
The debug switch it exposes is reachable from the query string. SWP_Utility::debug() is a one-line helper that compares $_GET['swp_debug'] against a key, so a visit with ?swp_debug=load_options is enough to route into the migration branch. The migration code was never retired after deployment; it remained live on every request.
Two defects that only become dangerous together#
The branch itself does something unremarkable until you look closely. It calls file_get_contents() on the URL supplied in $_GET['swp_url'], strips a <pre>…</pre> wrapper off the body, and then hands the remainder to eval() as 'return ' . $options . ';'. There is no allow-list, no signature verification, and no sanitisation of the fetched bytes.
The guard in front of it is if (!is_admin()). That is the second defect, and it is the one worth internalising. is_admin() answers a routing question, not a permissions question — it reports whether the current request targets the admin dashboard context. A request to /wp-admin/admin-ajax.php returns true for is_admin() regardless of whether a user is logged in. Because debug_parameters() fires on plugins_loaded, well before admin-ajax.php dispatches any action or enforces authentication, the evaluation happens for anonymous visitors.
Those two lines — attacker-controlled input reaching eval(), and a guard that admits everyone — combine into unauthenticated remote code execution. See the Radar entry for the affected range and scoring.
What the 3.5.3 patch actually changed#
The fix in 3.5.3 is a deletion, not a patch around the edges. The entire load_options block comes out of SWP_Database_Migration::debug_parameters(): the file_get_contents() call, the <pre> parsing, and the eval() sink all disappear. With no code path that evaluates remote content, there is nothing left to exploit.
The release also tidies adjacent weak spots, which is good practice even though they are separate concerns:
SWP_Utility::store_settings()swapsdieforwp_die()and gains a newSWP_Utility::auth()helper enforcingis_admin() && current_user_can('administrator')before writing settings.SWP_User_Options::correct_invalid_values()sanitises withhtmlspecialchars()and rejects values containingscript,(,<, orfromCharCode— defence-in-depth against stored XSS in option values.Puc/v4p4/Plugin/Package.php::isMuPlugin()guards againstWPMU_PLUGIN_DIRbeing undefined andrealpath()returningfalse.
There is no configuration workaround. The vulnerable code runs on plugins_loaded whether or not any feature is enabled, so upgrading past 3.5.2 is the only remediation.
Where to look for the same shape in your codebase#
This bug class is not exotic. It is a migration or debug affordance that outlived its purpose, kept alive by a hook registered too early and protected by a check that does not mean what its name suggests. Two greps catch most instances.
- Search your source for
eval(,create_function(, andassert(— every hit is worth justifying in writing. - Search for
file_get_contents(,wp_remote_get(, andcurl_exec(where the URL comes from$_GET,$_POST, or$_REQUEST. Remote fetch of user-supplied URLs is SSRF on a good day and RCE the moment the body is evaluated. - Search for
is_admin()used as a gate and confirm every call site has an accompanyingcurrent_user_can()check.is_admin()alone never authorises anything. - Audit hooks registered on
plugins_loaded,init, andwp_loadedthat perform side effects. Anything sensitive belongs in anadmin_post_orwp_ajax_handler with a nonce and a capability check.
For detection on a running site, the practical signal is a request to /wp-admin/admin-ajax.php with swp_debug or swp_url in the query string from an IP with no session. WAF rules and access-log alerts on those parameter names are cheap and catch opportunistic scanning.
The lesson generalises past one plugin#
Every remote-code-execution story in WordPress has the same second act: a developer needed a guard, reached for the most convenient one, and picked a function whose name sounded like authorisation but measured something else entirely. is_admin(), is_user_logged_in(), and the presence of a nonce all share this property — each answers a narrow question about the request, and none of them answers may this actor do this thing.
The durable fix is procedural rather than syntactic. Any feature that fetches or evaluates data from outside the site should require an explicit capability check on the actor, never a context check on the request. And any code path that exists purely to support a one-time migration should be removed after the migration, not left registered on plugins_loaded waiting for someone to find it.
is_admin()tells you where a request is going, not who sent it — if your access control reads like a routing predicate, it is not access control.
Vulnerabilities covered
| Severity | Vulnerability | CVE | Published |
|---|---|---|---|
| High7.2 | Unauthenticated Arbitrary Settings Update | CVE-2019-9978 |
- High7.2VulnCrest analysisKEVPoCUnauthenticated Arbitrary Settings Update
Social Warfare
<3.5.3Update to 3.5.3
