Two administrator accounts appeared on a WooCommerce store. The activity log had no "Created user" entry for either of them. The access log had no POST to user-new.php, no REST call to /wp/v2/users that succeeded, no file upload. One of the accounts even had a valid login session with no login event in front of it.
Someone was writing straight into the database. The obvious suspects (a leaked database password, a remote MySQL client) were all ruled out by the logs. The writer turned out to be a contact-form entry: a Ninja Forms submission whose stored meta held a PHP payload, which a second plugin, FunnelKit's checkout module, later passed to include(). Nothing on disk changed. A file scanner had nothing to find.
🧩 Two plugins, one bad assumption
Ninja Forms stores every submission as a post of type nf_sub, with the field values in wp_postmeta. FunnelKit's checkout module also stores its page configuration in post meta, under keys that start with _wfacp_. One of those values describes the checkout template, including the directory the template file is loaded from.
Each plugin is reasonable in isolation. The problem is the combination:
- The attacker could make an anonymous form submission store meta keys that belong to the checkout plugin, not to the form. The resulting
nf_subposts hadpost_author = 0and carried a_wfacp_fieldsets_datavalue with atemplate_dirfield inside it. - The checkout plugin trusted that meta. When asked to render a checkout for a given post ID, it read the template settings from that post, let
template_diroverride the real template path, and then calledincludeon the result. includeaccepts PHP stream wrappers, not just file paths. Atemplate_dirthat starts withphp://filter/ordata://turns "load a template" into "run this code".
So the "file" that got included was never a file. It was a string in the database, attached to something that looked like a form entry nobody would ever open.
🧪 Building PHP out of nothing: php://filter chains
The stored values looked like this (shortened, and intentionally not a working chain):
php://filter/convert.iconv.UTF8.CSISO2022KR|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.CP866.CSUNICODE|...|convert.base64-decode/resource=php://temp
This is a publicly documented technique. Each convert.iconv.* step converts between two character sets, and some conversions prepend a few predictable bytes. Chaining dozens of them, with base64 encode/decode in between to discard the junk, builds an arbitrary string byte by byte, starting from an empty php://temp stream. The final string is PHP source, and include executes it.
Two properties make this nasty for defenders:
- There is no
<?php, noeval, nobase64_decode(in the stored value. Signature greps for classic web shells miss it completely. - The chain is long (thousands of characters) but made only of charset names. It reads like configuration noise.
On the site we cleaned there were dozens of distinct chains spread across more than a hundred fake form entries. Decoding them offline (in an isolated directory, never on the server) gave a short list of tiny payloads:
$wpdb->query($_GET[1]): a SQL console. Whatever is in the query string parameter1runs against the site database.system(...),readfile(...)and a plainevalstub.- Code that prints
DB_PASSWORD. wp_set_auth_cookie(<user ID>): log the requester in as a chosen user, with no password and no login event.
That last one explained the session with no login in front of it.
📜 The error log wrote the confession
The SQL console was not perfect. When the attacker sent a malformed statement, WordPress logged a database error, and the PHP error log line includes the full call stack. This is the line that tied everything together (values sanitized):
PHP message: WordPress database error You have an error in your SQL syntax ...
for query INSERT INTO wp_users (ID,user_login,user_pass,user_email,...) VALUES (9xxxxxxxx,'iadm_xxxxx',...,'iadm_xxxxx@example.invalid',...)
made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'),
apply_filters('template_include'), WP_Hook->apply_filters, WFACP_Template_loader->maybe_load,
WFACP_Template_Common->get_view, include('php://filter/convert.iconv.UTF8.CSISO2022KR|...
An INSERT INTO wp_users made by a checkout template loader, which is include-ing a php://filter URL. No legitimate code path looks like that.
The matching access-log lines were plain POST requests to the checkout page, each with a query string parameter holding base64-encoded SQL:
203.0.113.10 - - [..] "POST /checkout/?1=U0VMRUNUIDE%3D HTTP/1.1" 200 ...
U0VMRUNUIDE= is base64 for SELECT 1: the attacker testing the console. Later requests in the same pattern created users, granted administrator capabilities by writing wp_capabilities directly into wp_usermeta, flipped user_status, and replaced password hashes. Because the access log keeps the query string, every one of those statements was recoverable and could be decoded in order.
🕵️ Why the usual places showed nothing
- Activity log plugins hook WordPress functions such as
wp_insert_user()andset_role(). A rawINSERTthrough$wpdbcalls none of them, so nothing is recorded. - File integrity checks passed. Core checksums were clean, no plugin file was modified, and nothing was written to disk.
- Malware scanners that read the database look for script tags,
eval, base64 blobs and known loaders. A chain of iconv charset names does not match any of that. - The rogue accounts had unusual IDs (nine-digit values far above the table's normal range) because the attacker chose them. Some inserts even went into a leftover table from an older table prefix, where they did nothing. Worth checking anyway: an inert table today can become an active one after a misconfigured restore.
- Removing the admins did not remove the access. The form entries were still in the database, so the attacker could recreate accounts or simply request an auth cookie for an existing administrator at any time.
🔎 Read-only checks (run these first)
Replace wp_ with your table prefix and run these as the site's own database user. Nothing here writes anything.
1. Stream wrappers anywhere in post meta. Legitimate values almost never contain these:
SELECT m.meta_id, m.post_id, p.post_type, p.post_author, p.post_date_gmt,
m.meta_key, LEFT(m.meta_value, 120) AS sample
FROM wp_postmeta m
JOIN wp_posts p ON p.ID = m.post_id
WHERE m.meta_value LIKE '%php://%'
OR m.meta_value LIKE '%data://%'
OR m.meta_value LIKE '%phar://%'
OR m.meta_value LIKE '%convert.iconv.%'
ORDER BY p.post_date_gmt;
2. Form entries carrying another plugin's meta. A Ninja Forms submission should only hold _field_*, _form_id and similar keys:
SELECT m.meta_key, COUNT(*) AS n, MIN(p.post_date_gmt) AS first_seen, MAX(p.post_date_gmt) AS last_seen
FROM wp_posts p
JOIN wp_postmeta m ON m.post_id = p.ID
WHERE p.post_type = 'nf_sub'
AND m.meta_key NOT LIKE '\_field\_%'
GROUP BY m.meta_key
ORDER BY n DESC;
Anything starting with _wfacp_ in that list is a red flag.
3. The same search across every text column in every table (options, usermeta, plugin tables). This prints only table and column names with a hit count:
DB=your_db; U=your_db_user
mysql -u "$U" -p -N -e "
SELECT CONCAT('SELECT ''',TABLE_NAME,'.',COLUMN_NAME,''', COUNT(*) FROM \`',TABLE_NAME,'\` WHERE \`',COLUMN_NAME,'\` LIKE ''%php://filter%'' OR \`',COLUMN_NAME,'\` LIKE ''%data://%'';')
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA='$DB' AND DATA_TYPE IN ('text','mediumtext','longtext','varchar')" "$DB" \
| mysql -u "$U" -p -N "$DB" | awk '$2 > 0'
4. Administrators, including in leftover prefixes. List every *_capabilities row that grants administrator, from every users table in the database:
SELECT TABLE_NAME FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME LIKE '%usermeta';
SELECT um.user_id, u.user_login, u.user_email, u.user_registered, um.meta_key
FROM wp_usermeta um
LEFT JOIN wp_users u ON u.ID = um.user_id
WHERE um.meta_key LIKE '%capabilities'
AND um.meta_value LIKE '%administrator%'
ORDER BY um.user_id;
Repeat the second query for each usermeta table the first one returns. Look for IDs far outside the normal range, .invalid or throwaway email domains, and accounts your activity log never recorded as created.
5. The logs. The error-log stack trace and the query-string console are the strongest evidence:
# include() of a stream wrapper, anywhere in the PHP error logs
zgrep -h "include('php://\|include('data://" /path/to/logs/*error*.log* | cut -c1-300
# POSTs to the checkout page with a numeric query parameter
zgrep -hE '"POST /checkout/\?[0-9]=' /path/to/logs/*access*.log* | cut -c1-250
# decode the SQL that was sent through ?1=
zgrep -hoE '"POST /checkout/\?1=[^ ]+' /path/to/logs/*access*.log* \
| sed -E 's/.*\?1=//' | python3 -c "
import sys, base64, urllib.parse
for l in sys.stdin:
v = urllib.parse.unquote(l.strip())
try: print(base64.b64decode(v + '=' * (-len(v) % 4)).decode('utf-8', 'replace'))
except Exception: print('[raw]', v)"
Run the decoder on your own workstation against a copy of the logs, not on the server.
🧹 Cleanup without losing anything
- Full database dump first, verified non-zero. Then a targeted dump of exactly the rows you are about to delete (
--no-create-info --complete-insertwith a--whereon the post IDs). Hash both. - Delete in one transaction: first the meta rows of the malicious
nf_subposts, then the posts. Check the counts before committing, and re-run checks 1 to 3 afterwards: they should return nothing. - Do not stop at the rogue admins. Delete them (and their sessions and application passwords) only after the entries are gone, or they come back.
- Rotate what the payloads could read: the database password (the payload printed it), the authentication salts in
wp-config.php(to kill every forged cookie), and the passwords of every real administrator. - Restrict the database user. If it accepts connections from any host (
'user'@'%'), limit it to the web server. - Update or deactivate both plugins. Check both vendors' changelogs. Until a release clearly fixes the meta trust (on the checkout side) or the arbitrary meta write (on the form side), treat updating as insufficient on its own. If the store does not use FunnelKit's checkout pages, deactivating that module removes the
includesink. - Flush the object cache (Redis/Memcached) after the database cleanup, so no cached copy of the meta survives.
🧪 Indicators and quick checklist
nf_subposts withpost_author = 0that carry_wfacp_*meta keys_wfacp_fieldsets_datawith atemplate_dirstarting withphp://filter/,data://orphp://temp- Any meta or option value containing
convert.iconv.chains - PHP error-log stack traces ending in
WFACP_Template_Common->get_view, include('php://filter... POST /checkout/?1=<base64>or?0=in the access log- Administrator accounts with nine-digit IDs,
@example.invalidemails and no "Created user" event - Active sessions in
session_tokenswith no matching login event *_capabilitiesrows granting administrator in tables from an old prefix
❓ FAQ
How can a contact-form entry run PHP code?
By itself it can't. It becomes dangerous when another plugin reads a value from that entry's meta and passes it to include. Here the checkout plugin let a stored template_dir override its template path, and include accepts php://filter and data:// stream URLs, which can produce PHP code without any file on disk.
Why didn't the activity log show the new admin accounts?
The accounts were created with raw SQL (INSERT INTO wp_users and a direct wp_capabilities write) through a database console in the payload. Activity log plugins only see changes made through WordPress functions such as wp_insert_user(), so nothing was recorded.
Is deleting the rogue administrators enough?
No. As long as the malicious form entries exist, the attacker can run SQL again, recreate the accounts, or request a login cookie for any existing user. Remove the entries first, then the accounts, then rotate the database password and the WordPress salts.
Will a file scanner find this?
Not on disk, because there is nothing on disk. Search the database for stream-wrapper strings (php://, data://, convert.iconv.) and check the PHP error log for include('php:// stack traces.