Magento spam customer registration blocked by a honeypot and form timer

Magento spam customer registrations usually show up as a slow surprise. Someone opens Customers > All Customers and finds pages of accounts nobody recognises: random names, addresses at mailinator.com or yopmail.com, first names like www.cheap-pills.example, or template text such as {{var ...}}. None of them ever placed an order.

These accounts are made by bots, not people. Below we explain why bots sign up to Magento stores, how to measure the problem with a few SQL queries and a log search, which settings Magento already gives you, and a free module our team wrote that blocks most of these sign-ups without bothering real shoppers.

Why bots create fake customer accounts

Most of these bots are not after your store in particular. They post to any registration form they find. Some want the welcome email: they put a link or a short message in the first name field, and your store mails it to whatever address they typed. Others probe for template injection, which is why names with {{ show up. We covered how a Magento template flaw was attacked through store emails in our post on the fake PayPal payment failed emails.

Even when nothing gets in, the cost is real. Each fake account can send a welcome or confirmation email to an address nobody reads, and many of those addresses bounce. Mail providers watch bounce rates, so your order and password emails start landing in spam. The customer grid fills with junk, your customer count means nothing, and newsletter or marketing exports pick up thousands of dead addresses.

Bots reach Magento through three doors: the storefront form at /customer/account/create/, which posts to /customer/account/createpost/; the GraphQL mutations createCustomer and createCustomerV2 at /graphql; and the REST endpoint POST /V1/customers, which Magento opens to guests by default.

How to check for Magento spam customer registration by hand

Run these queries in a MySQL client connected to the store database. Magento stores created_at in UTC, so the queries use UTC_TIMESTAMP(). If your install uses a table prefix, add it to the table names.

New accounts per day

SELECT DATE(created_at) AS day, COUNT(*) AS new_customers FROM customer_entity WHERE created_at >= UTC_TIMESTAMP() - INTERVAL 30 DAY GROUP BY day ORDER BY day;

Compare the daily numbers with your order count for the same days. When new accounts run far ahead of orders, or jump on one day and stay high, bots are signing up.

Top email domains

SELECT SUBSTRING_INDEX(email, '@', -1) AS domain, COUNT(*) AS accounts FROM customer_entity WHERE created_at >= UTC_TIMESTAMP() - INTERVAL 30 DAY GROUP BY domain ORDER BY accounts DESC LIMIT 20;

Gmail, Outlook and local providers at the top are normal. Throwaway services, or one strange domain with hundreds of accounts, are not.

Names with links and no orders

SELECT e.entity_id, e.created_at, e.email, e.firstname, e.lastname FROM customer_entity e WHERE (e.firstname LIKE '%http%' OR e.firstname LIKE '%www.%' OR e.firstname LIKE '%{{%' OR e.lastname LIKE '%http%' OR e.lastname LIKE '%www.%' OR e.lastname LIKE '%{{%') AND NOT EXISTS (SELECT 1 FROM sales_order o WHERE o.customer_id = e.entity_id);

Which IP addresses post the form

On the server, count the registration posts per IP in your web server access log. The log path depends on your setup:

grep 'POST /customer/account/createpost' /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -20

A handful of IPs with dozens of posts each is a bot. Behind a CDN or load balancer the first field may be the proxy’s address, so check that your log records the real client IP. GraphQL sign-ups won’t show up this way, because every GraphQL call is a POST to /graphql and the mutation name sits in the request body.

What Magento already gives you

  • Built-in CAPTCHA. Go to Stores > Settings > Configuration > Customers > Customer Configuration > CAPTCHA. Storefront CAPTCHA is on by default, but the default forms are only Login and Forgot password. Add “Create user” to the Forms list to protect the registration page. Adobe’s CAPTCHA guide has the full settings.
  • Google reCAPTCHA. Stores > Settings > Configuration > Security > Google reCAPTCHA Storefront, then set “Enable for Create New Customer Account”. It needs keys from Google. See Adobe’s reCAPTCHA guide.
  • Email confirmation. Customers > Customer Configuration > Create New Account Options > Require Emails Confirmation. Fake accounts can’t log in until someone clicks the link, but the account is still created and the confirmation email still goes out.

CAPTCHA works, and if your shoppers accept it, keep it on. Many store owners turn it off after complaints from shoppers who find it awkward, especially on a phone. That is the gap our module fills.

Blocking the bots with our free module

We wrote Magento 2 Spam Registration Blocker to stop these sign-ups with checks shoppers never see. On the storefront registration form it adds:

  • A honeypot field placed off-screen. People never see it. Bots that fill every field get refused.
  • A signed form timer. The form carries a hidden timestamp signed with your store’s crypt key. Posts with a missing, forged or day-old timestamp are refused, and so are posts sent faster than 3 seconds after the page loaded. A bot that posts straight to createpost without loading the form has no valid timestamp.

On the storefront form and on the GraphQL createCustomer and createCustomerV2 mutations it adds:

  • A disposable email block with a bundled list of 211 throwaway mail services, plus your own extra and allowed domains in the admin.
  • A per-IP limit, by default 5 new accounts per IP address per 60 minutes, counted in the Magento cache.
  • A links-in-names check that refuses first or last names with http, www., a domain, or {{.

Every refusal gets the same message, “We could not create your account. Please try again.”, so a bot can’t tell which check caught it. Each one is written to var/log/spam_registration_blocker.log with the reason, the channel, the IP address and the email domain, never the full address. For accounts already in the store, bin/magento mconnect:spam:list --days=90 lists recent customers with no orders that use a disposable domain or have a link in their name. It is read only, so you review the list and delete what you’re sure about from Customers > All Customers. Take a database backup before a large delete.

Install

composer config repositories.magento2-spam-registration-blocker vcs https://github.com/mcsventures/magento2-spam-registration-blocker
composer require mconnect/module-spam-registration-blocker:^1.0
bin/magento module:enable Mconnect_SpamRegistrationBlocker
bin/magento setup:upgrade
bin/magento setup:di:compile (production mode only)
bin/magento cache:flush

Then open /customer/account/create/, view the page source and look for mcsrb_website and mcsrb_token. If they are missing, your theme doesn’t print the form.additional.info container, and with the timer on every storefront sign-up would be refused. Luma and themes built on it print it. The settings are under Stores > Configuration > M-Connect Media > Spam Registration Blocker, and every check has its own switch. The README on GitHub has curl commands to test each check.

Where the blocker stops

  • The honeypot and timer don’t apply to GraphQL. A headless or PWA front end would have to send those fields, so we left them out. GraphQL sign-ups get the domain, name and IP checks only.
  • It doesn’t cover the REST API. POST /V1/customers is open to guests by default and skips these checks. If you don’t use it, block it at your web server or firewall.
  • The registration page stays out of the full page cache while the module is on, because the timestamp has to be fresh. On a standard install the CAPTCHA module already does the same, so nothing changes.
  • Other sign-up forms, such as a pop-up from another extension, are refused if they post to createpost without the hidden fields. Turn the timer off for that store, or add the fields to that form.
  • The per-IP count resets when the cache is flushed, and an office or mobile network can share one IP. Raise the limit if that fits your customers.
  • If a headless front end sends sign-ups to GraphQL from its own server, every account comes from that server’s IP. Turn the per-IP limit off in that case and limit sign-ups per visitor in the front end.
  • No disposable list is ever complete. Add new domains from your log to the extra list.
  • It doesn’t delete accounts, and it sends no data to any outside server.

When fake accounts are a sign of something bigger

A wave of fake accounts is often the first thing a store owner notices, not the only thing going on. If the names carry template code, if accounts keep arriving through REST or a custom endpoint, or if your store has fallen behind on patches, look further. Our post on what happened to stores that didn’t patch SessionReaper in time shows how fast that goes wrong. Bot traffic also eats PHP workers, because the registration page is never served from cache; our Magento speed checklist lists the checks we run on every store.

Need sign-up rules this module doesn’t have, such as manual approval for trade accounts? Our Magento module development team builds them.

Want us to check the whole store? Start with a Magento security audit, or let us look after it with our Magento support plans from $599 a month. Starting prices in USD, final quote after a short call. Contact us.

The source code and issue tracker are on the module’s GitHub page. The download and changelog are on the Magento 2 Spam Registration Blocker product page.

Sources

More free extensions from our team

Every free module we have released so far is on our free Magento 2 extensions page, each with its setup guide and Composer package. Our paid modules are in the Magento 2 extensions store.

    Need Magento expert help?

    We provide result-driven solutions to expand the competency level and productivity.

    Instant Help CenterAvailable!

    Monday to FridayResponse promised within 24 hours!

    Magento health check report showing cron, indexer and cache status

    Load Comments

    Your email address will not be published. Required fields are marked *

    5 4 3 2 1