A bot added around 5,000 addresses to my newsletter
By Flavio
Tagged: Cloudflare
How out-of-office replies exposed a bot attack on my newsletter, why double opt-in was not enough, and how I protected the signup flow.
Yesterday I started getting a strange number of automatic email replies.
“I’m on vacation.”
“I’m out of the office.”
One reply like that is normal after sending a newsletter. Getting several of them at once wasn’t, especially because I hadn’t sent one.
They were triggered by newsletter confirmation emails, which gave me the clue I needed.
I opened Sendy and found thousands of suspicious new subscribers. From the signup spike, it looked like the bot had submitted around 5,000 addresses.
Most stayed unconfirmed, but 34 addresses from that same attack window ended up confirmed.
The mistake I made
A while ago, I removed Google reCAPTCHA from my newsletter forms. It had caused problems, and I wrongly thought double opt-in would be enough on its own.
Double opt-in and bot protection solve two different problems. With double opt-in, a submitted address isn’t added to the active newsletter until someone opens the confirmation link. That part worked, and most of the fake submissions stayed unconfirmed.
Sendy still stored every pending address and sent out every confirmation email, though. That meant the attack could generate thousands of unwanted emails, bounces, automatic replies, and complaints, and hurt my sending reputation.
And in this case, 34 records did get confirmed. I couldn’t tell how those 34 confirmations happened, so I treated all of them as part of the incident. Double opt-in kept most of the junk off the active list, while leaving the signup endpoint unprotected.
The form was too easy to call
My newsletter forms were posting directly to Sendy.
Anyone who found that endpoint could bypass my site and submit addresses with a script. Once I removed the CAPTCHA, there wasn’t any real barrier left in front of it.
I changed the flow so the browser doesn’t talk to Sendy directly anymore:
browser
→ my Cloudflare Pages Function
→ Sendy API
The server endpoint only accepts the newsletter lists I explicitly allow, and it talks to Sendy using an API key that never reaches the browser.
I also blocked direct public submissions to the main newsletter list on the Sendy server. Putting protection on the new endpoint wouldn’t do much good if the old unprotected route still worked.
Adding Turnstile
I replaced reCAPTCHA with Cloudflare Turnstile.
Turnstile adds a token to the form after checking the visitor. My Pages Function sends that token to Cloudflare and verifies it before doing anything with Sendy.
I don’t just check the success value, either. The token also has to contain the expected action and hostname, so a valid token created for another form or another site gets rejected.
Doing the check on the server is what matters. A Turnstile widget in the browser isn’t enough protection on its own, because a bot can ignore the page and call the endpoint directly.
Adding a rate limit
I didn’t want to rely on Turnstile alone, so I added a rate limit of five signup attempts per IP address in a ten-minute window. I hash the IP before storing the counter in Cloudflare KV.
The rate limit runs before Turnstile and Sendy. When an IP makes too many attempts, the request gets rejected right away with a 429 Too Many Requests response.
Rate limiting isn’t perfect either, since a distributed bot can use lots of IP addresses. Combined with Turnstile, server-side validation, and a closed Sendy endpoint, it makes the attack much harder and limits the damage if one layer fails.
Now the complete flow looks like this:
browser
→ allowed-list check
→ rate limit
→ server-verified Turnstile
→ authenticated Sendy API
→ confirmation email
It’s the same approach I describe in how to harden a public form endpoint: reject bad requests before they reach the part of the system doing expensive or hard-to-undo work.
Cleaning up the list
Stopping the next attack didn’t remove the records already sitting in Sendy.
I added a bulk cleanup command to my Sendy CLI. It does a dry run first, shows what it’s going to remove, and requires an explicit confirmation before deleting anything.
I used it to remove the suspicious records from the attack, and I also cleared older unconfirmed records that had piled up over time. Then I removed the 34 confirmed records from the same attack window and verified that none were left.
The dry run was essential, because a bulk delete command pointed at a mailing list isn’t something I want to run on trust.
What I learned
I’d been treating double opt-in as a complete newsletter signup defense, and it clearly isn’t. Going forward, I want all four pieces in place:
- double opt-in to keep unconfirmed addresses out of the active list
- server-verified bot protection to control who can submit the form in the first place
- rate limiting to cap how often someone can try
- no direct public path to the email provider, so bots can’t go around the other checks
I also want cleanup tools ready before I need them.
Those out-of-office replies looked like noise at first, but they’re what alerted me to the whole problem.
Want me to talk about your product? You can sponsor this site.
Related posts about cloudflare: