Dev.to Security πŸ” Cybersecurity πŸ‘ 2 πŸ“– 3 min read

Finding and removing fake WordPress sign-ups with WP-CLI

Bots create fake WordPress accounts through an open registration form. A bot finds /wp-login.php?action=register, or a form from a membership plugin, and submits it thousands of times. Site size doesn't matter. Bots loo

Bots create fake WordPress accounts through an open registration form. A bot finds /wp-login.php?action=register, or a form from a membership plugin, and submits it thousands of times.

Site size doesn't matter. Bots look for open registration forms, not for big sites.

The accounts can carry spam links in profiles or comments. The bots behind them may also test whether the site emails a password, or wait for a plugin flaw that lets a Subscriber do more than it should.

1. Is registration open at all?

wp option get users_can_register

1 means anyone can register through the WordPress form. If nobody needs an account on the site, close it:

wp option update users_can_register 0

That is the same box as Settings > General > Anyone can register. Store and membership plugins can run their own sign-up forms with their own switches. On WooCommerce, check WooCommerce > Settings > Accounts & Privacy for account creation at checkout and on the My Account page.

2. Keep the default role low

wp option get default_role

For the WordPress form this should print subscriber. Never editor or administrator. Store and membership plugins can assign their own roles (WooCommerce uses customer), and a membership plugin can hand new users more than you expect, so check those too.

3. If you need sign-ups, add friction

Pick two controls, not all of them. Every extra step costs real sign-ups.

  • A CAPTCHA on the form blocks most scripted sign-ups.
  • Email confirmation keeps the account inactive until the owner clicks a link.

A honeypot field, a block on disposable email domains, a per-IP limit and manual approval are the other options.

4. List the suspicious accounts

Newest first:

wp user list --role=subscriber --orderby=registered --order=DESC \
  --fields=ID,user_login,user_email,user_registered --format=csv

On a big site, end the command with > users.csv and open the file in a spreadsheet.

On a store or membership site, run it again with --role=customer or the member role your plugin adds. Look for a burst of accounts on one day. Odd usernames and addresses from one email domain are clues too. Don't delete every Subscriber: real members live in the same list.

5. Delete them

Back up the database first, and confirm every ID in the list is an account you want gone. Also check that user 1 exists and is the account that should receive their content.

wp db export before-cleanup.sql

Check that the export succeeded and that you could restore it. Then replace the example IDs with the ones you verified:

wp user delete 101 102 103 --reassign=1

--reassign=1 moves the accounts' content to user 1 instead of deleting it. WP-CLI has no undo command. Getting the accounts back may mean restoring the database, which also rolls back every other change made since the export.

6. Check it worked

Watch the Users screen for a week. If fake accounts keep appearing, find out which form they come through and whether its controls are on.

If you moved the registration address with a security plugin, open the old one in a private window. It should return a 404. A moved path doesn't help when the form sits on a public page, so keep the CAPTCHA either way.

The original guide has the full table of bot controls and the WooCommerce settings.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.