A contact form anyone could use to flood our inbox
The form’s API sent an email for every request it received, with no limit on how many, how fast, or how big. A simple script could flood our inbox and use up the sending account’s daily limit, so real enquiries would stop arriving.
- Type
- Review of our own system
- Target
- The contact form API on hikmasolutions.co.za (Next.js route that sends email through a Gmail account)
- Vulnerability class
- Missing rate limiting and input limits (resource abuse)
- Severity
- Medium (self-assessed, CVSS 3.1 base 5.3: AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L)
- Outcome
- Fixed in the site redesign, retested
- Disclosure
- Our own system. Published after the fix.
- Date
- November 2026
How it was found
Code review of the API route, asking one question: what stops someone calling this directly, without the form, thousands of times?
The route only checked that name, email and message were not empty. There was no rate limit, no size limit, no bot check, and no error handling around the email send.
I also checked whether a visitor could add extra recipients by putting line breaks into the subject or reply-to fields (email header injection).
Validation
I tested on a local copy of the production code, not the live site, because testing live would have sent real emails.
30 requests in a row all reached the email-sending step. A 1 MB message was accepted and passed to the mailer. A failed send crashed the request with an unhandled error.
Header injection did not work. The mail library (Nodemailer 7) strips line breaks from headers, so no extra recipients could be added. The route only ever sends to one fixed inbox, so it was never an open relay.
Before the fix (30 POST requests to /api/contact)
30 x 500 (31 send attempts in the server log)
1 MB message -> accepted and sent to the mailer
After the fix (same test)
5 x 502 (send attempted; no mail server in the test sandbox)
25 x 429 "Too many messages. Please try again later, or WhatsApp me."Impact
Anyone on the internet, with no account, could flood one inbox and burn through the Gmail account’s daily sending limit. Real enquiries would then fail without anyone noticing, and the account could be flagged for spam.
No data was exposed and nobody else could be emailed, which is why this is rated Medium and not higher.
The fix
A hidden honeypot field that bots fill in and people don’t.
A limit of 5 messages per IP address every 10 minutes. On Vercel the client IP header is set by the platform and can’t be spoofed by the sender.
Length limits on every field, a proper email format check, and a try/catch around the send that returns a clear message instead of a crash.
What I learned
The limit is kept in memory, so each server instance counts separately. It stops casual abuse, not a determined attacker spreading requests across many IPs. A shared store or a CAPTCHA would be the next step if abuse ever shows up.
Any endpoint that triggers something with a real cost, like sending email, needs a limit from day one.