r/WordpressPlugins • • 2d ago

Help [HELP] How can I test this domain blocking plugin?

I installed the plugin Restrict Usernames Emails Characters V 5.1 because a few hours ago I received a flurry of new user registrations all from @ DomainToBeBlocked.

I made two minor configuration updates. Then to activate, it forced me to check "Anyone Can Register" in Settings/General. It was previously unchecked, which is one reason the underlying situation is odd.

The second reason is there is nowhere on my site where a new user can simply register. New users are added only by making a purchase.

And a third reason is my site traffic does not show any pages were visited as many times as the number of new users created.

So I don't see how or where the registrations were created, and I don't see how I can proactively try to create a new user with their domain as a test of the plugin.

The registrations have stopped since I activated the plugin so maybe that's the best test of all. But I would still like to determine how and where the new users were generated so I can address that vulnerability. Thanks for your input.

1 Upvotes

12 comments sorted by

1

u/Dunzan 1d ago

Hey u/TopSydeWP and u/thomas-at-caseproof thanks to you both. Testing the plugin on the default register page showed it did work there, but I woke up to a handful more registrations from the domain I want to block. So I unticked Anyone Can Register, removed the plugin, and deleted the latest new users. None of them had made any purchases.

Turning to the Woo Accounts & Privacy settings, I see "Enable guest checkout (recommended)" was the only box ticked. I just unticked it. I've added a tick to "Enable log-in during checkout." I've left the two boxes under "Account creation" unticked, and the two boxes under "Account creation options" are both unticked plus greyed out. Is all that OK?

u/TopSydeWP said to "put Cloudflare Turnstile on registration and checkout" while u/thomas-at-caseproof provided what I think is a PHP snippet, yes? Should I be considering implementing either/or or both/and? Thanks.

1

u/Dunzan 1d ago

u/RhysJonesDev and u/thomas-at-caseproof I'm glad to see you in agreement and I've configured as you recommend. The thing is, this restores my settings to how they were before I started getting these bogus users. Some were created while Anyone Can Register was off, and others while it was on but supported by the plugin, so we still don't really know how they got in.

In any case, from the rest of the ideas shared in this thread, I'm now down to checking out Cloudflare Turnstile and comparing it with the Draco Insomnis plugin that u/DavidMunozCabrisas mentioned. I'll probably go with whichever is simpler for me to understand.

→ More replies (1)
→ More replies (2)

1

u/TopSydeWP 2d ago

We'd uncheck Anyone Can Register again, even if that plugin stops working, because with it on, wp-login.php?action=register takes signups from anyone. Bots post straight to forms without loading pages, so your analytics never counted them. On WooCommerce, check Settings > Accounts & Privacy for account creation on the account page, and put Cloudflare Turnstile on registration and checkout. We're TopSyde, a managed WordPress host, and we see these bursts of bot accounts on WooCommerce stores we look after too.

1

u/Dunzan 2d ago

Thanks for your reply. You showed me where I can test and indeed see the plugin blocking as hoped. That sets me right for now.

But you're suggesting I go further because checking Anyone Can Register may invite more such intrusions. Is that right? If so, how do you suppose the batch today got created when ACR was not checked?

Also, I now realize there are two registration URLs. One I hard coded that only has products for sale so it doesn't seem to represent a risk vector for this issue.

The other is the default you pointed me to which could create a "subscriber" with zero privileges. I'm then notified immediately and can delete the user. What does anybody have to gain by initiating that game with me? Other than the minor distraction and hassle, what risk do I really have by checking ACR that would be erased by unchecking?

Thanks again!

1

u/TopSydeWP 2d ago

Yes. We'd guess today's batch came through WooCommerce, which has its own account settings and ignores Anyone Can Register. Checkout and the My Account page can both create customers when bots post to them directly.

With ACR on, the bigger risk comes later. Security advisories keep listing plugin flaws that only need a subscriber login, so each throwaway account is someone already logged in when one of your plugins gets one. On our clients' sites we update a plugin with a known flaw as soon as a fix exists.

1

u/thomas-at-caseproof 2d ago

I'd bet on WooCommerce for the batch too. Anyone Can Register only governs core's form at wp-login.php. Woo's My Account registration form and account creation at checkout run on their own settings, so accounts can keep appearing with that box unchecked.

To find the actual door, sort Users by registration date and see whether any of the new accounts placed an order. Then search the raw server access log (not analytics, since bots don't bother running JavaScript) around those timestamps for POSTs to /my-account/ or ?wc-ajax=checkout. No orders attached usually means the My Account form, and if you don't need it, untick "Allow customers to create an account on the My account page" under WooCommerce > Settings > Accounts & Privacy.

When you test the blocker, try the blocked domain on that Woo form in a private window, not only on wp-login.php. A plugin that hooks core registration may never see Woo's.

I also wouldn't leave Anyone Can Register on just to keep one plugin happy, since it reopens wp-login.php?action=register as a second door. A few lines on Woo's own registration filter block the domain with the setting off (PHP 8+):

add_filter( 'woocommerce_registration_errors', function ( $errors, $username, $email ) {
    if ( str_ends_with( strtolower( $email ), '@domaintobeblocked.com' ) ) {
        $errors->add( 'blocked_domain', 'Registrations from this domain are not accepted.' );
    }
    return $errors;
}, 10, 3 );

1

u/WP_Dev_Studio 1d ago

The plugin forcing "Anyone can register" on is normal, since it hooks into the registration process. That doesn't mean a public form exists on your site, though. A few places registrations can come from:

•        WooCommerce. Check WooCommerce > Settings > Accounts & Privacy. If "Allow customers to create an account on the checkout / My Account page" is on, bots can create accounts that way.

•        Direct endpoints. wp-login.php?action=register and the REST API can accept signups even if no page links to them.

•        Bots don't show up in analytics. Tools like GA only count visitors who run JavaScript. Check your raw server access logs for POST requests to those endpoints instead.

To test the plugin, open an incognito window, register (or check out) with an email at the blocked domain, and see if it's rejected. Since the spam stopped after you activated it, it's probably working. I'd also add a CAPTCHA and a security plugin like Wordfence to close the hole itself.