Form Honeypot Design and Silent Rejection
A form honeypot is an optional HTML <input> field hidden from human visitors via CSS and accessibility attributes, but left in the raw DOM so automated scraping bots populate it. Because most commodity spam bots parse HTML forms directly rather than rendering CSS layouts, they fill every discovered input field to avoid failing required-field validation.
Unlike CAPTCHAs, a well-designed honeypot adds zero cognitive or accessibility friction for legitimate users while filtering out commodity bot traffic before any database write or outbound network call.
Three Design Pillars
1. Enticing Field Naming
Bots use heuristics to match input name attributes to plausible payload types, and sophisticated bots skip fields explicitly named honeypot, bot_trap, or confirm_human.
- Name the trap field after a common business attribute that isn't otherwise collected on the form, such as
website,url, orcompany. - Crawlers specifically target
websiteandurlfields to inject SEO spam links.
2. Autofill and Accessibility Isolation
Hiding the wrapper with display: none (Tailwind's hidden class) already removes the field from the keyboard Tab order and the accessibility tree. The risk is a human filling in the trap and being silently dropped, which can still happen if the stylesheet fails to load, if the hiding is later changed to off-screen positioning (which stays focusable), or through browser autofill. Add attributes that keep the field out of reach in those cases:
website = forms.CharField(
required=False,
widget=forms.TextInput(attrs={
"autocomplete": "off",
"tabindex": "-1",
"aria-hidden": "true",
}),
)
<div class="hidden" aria-hidden="true">
{{ form.website }}
</div>
| Attribute / Class | Purpose |
|---|---|
class="hidden" (display: none) |
Hides the field and, while the CSS applies, also removes it from the Tab order and the accessibility tree. |
autocomplete="off" |
Asks the browser not to autofill the field. Only a hint: Chrome often ignores it, so don't rely on it alone. |
tabindex="-1" |
Keeps the input out of the keyboard Tab sequence if the CSS doesn't apply. |
aria-hidden="true" |
Keeps screen readers away from the field if the CSS doesn't apply. |
3. Silent Rejection (Deceptive Success Response)
When the server detects a non-empty honeypot value, it must not return 400 Bad Request or a validation error message ("Spam detected").
if request.POST.get("website"):
return redirect("crm_contacts_thanks_path")
Check the raw request.POST before form validation. If the check sits inside form.is_valid(), a bot that fills the trap and also sends invalid data (a malformed email) gets the form's error page instead of the fake success, which is exactly the oracle silent rejection is meant to avoid.
Limitations
A honeypot only catches automated bots that blindly populate HTML inputs. It does not stop:
- A human attacker repeatedly submitting the form by hand.
- A targeted script (
curl, Playwright, Pythonrequests) written specifically against the endpoint that leaveswebsiteempty.
To defend against targeted floods, pair the honeypot with Per-IP Rate Limiting Behind a Reverse Proxy in Django.
References
- OWASP Automated Threats to Web Applications: OAT-017 Spamming - Automated comment/contact spam threats and countermeasures.
- MDN Web Docs: aria-hidden - Hiding non-interactive or trap elements from the accessibility tree.
- MDN Web Docs: HTML tabindex attribute - Using
tabindex="-1"to exclude elements from sequential keyboard navigation. - Django Public Contact Form Hardening – Honeypot and Rate Limiting - Lab implementing the
websitehoneypot field and unit tests in Django. - Unprotected Public Form Risks - Synchronous SMTP DoS and Quota Exhaustion - The operational risks that form bot filtering prevents.
- Web Application and Django Security MOC - Hub for Django and web application security notes.
Review cards
Flashcard How should you name a honeypot field, and why?
After a plausible field the form doesn't collect, such as website or url: smart bots skip names like honeypot or bot_trap, and spam crawlers go for website/url to drop links.
Flashcard Why isn't `autocomplete="off"` enough to keep autofill out of a honeypot?
It's only a hint and Chrome often ignores it, so the field must also be hidden and kept out of reach.
Quiz If the stylesheet fails to load, what keeps a honeypot input out of the keyboard Tab order?
-
tabindex="-1" -
autocomplete="off" -
class="hidden" -
tabindex="0"
class="hidden" only works while the CSS applies, autocomplete is about autofill, and tabindex="0" puts the field in the Tab order.
Flashcard Why check the honeypot on raw `request.POST` before form validation?
Otherwise a bot that fills the trap and also sends invalid data gets the form's error page instead of the fake success, which tells it something was rejected.
Flashcard Why answer a filled honeypot with the normal 302 to the thanks page rather than a 400?
An error is an oracle: the bot learns it failed and retries with variations. The fake success makes it move on, while the server writes nothing and sends no email.