---
title: Spam and security
description: Eight defence layers cheapest first, the honeypot rules, server-side Turnstile verification, rate limits, origin checks and why rejections look like success.
---

The biggest risk for a free form relay is not spam reaching the owner; it is strangers using the service to send spam to people who never asked for it. Domain verification plus (from Phase 2) recipient double opt-in closes that: nobody can receive mail through ContactUsIQ without proving control of both the website and the inbox. The layers below deal with the spam that still arrives at a legitimate form.

## The eight layers, cheapest first

| Layer | Check | Cost | Outcome |
| --- | --- | --- | --- |
| 1 Edge | Body size, content type, known bad user agents, missing `Origin` on JSON | none | drop |
| 2 Honeypot | Hidden field filled | none | silent reject |
| 3 Origin | `Origin` or `Referer` not on the form's verified domains | none | silent reject |
| 4 Rate limit | Per IP per form: 5 per 10 minutes; per form: 60 per minute; per workspace daily ceiling by plan | Redis call | `429` or silent reject |
| 5 CAPTCHA | Turnstile token verified server-side with the client IP | one HTTPS call | reject on failure; forms without the widget run at "strict" heuristics |
| 6 Heuristics | Link count, URL-only messages, disposable-email domains, repeated payload hash, language mismatch with the site, per-form block list | in-process | score 0 to 1 |
| 7 AI verdict (Pro) | A language model classifies spam, scam, sales pitch or genuine and explains why | one API call, only when the score is in the grey zone | score refined, category and urgency attached |
| 8 Owner feedback | Mark spam or not spam in the inbox | none | trains the per-workspace threshold and the shared reputation list |

The **sensitivity** setting per form (Relaxed, Normal, Strict) moves the threshold at which a scored submission is hidden as spam rather than delivered. Hidden submissions are still stored for 30 days so a false positive can be rescued from the inbox.

## Honeypot rules

- The field is named `_honeypot` and must arrive empty. A filled value is a silent reject.
- Hide it with CSS (off-screen or `display:none`), not with `type="hidden"`: bots that fill every text input will then fill it too. Add `tabindex="-1"`, `autocomplete="off"` and `aria-hidden="true"` on the wrapper so real visitors and screen readers skip it.
- Autofill extensions occasionally fill hidden inputs. The off-screen position and `autocomplete="off"` make that rare; if a real visitor reports a lost message, that is the first thing to check.
- The embed and widget scripts add their own honeypot; you only need one in hand-written forms.

## Turnstile, verified server-side

The Turnstile site key is public and goes in the page. The secret never leaves the intake function, which calls Cloudflare's `siteverify` with the token and the client IP. The token arrives as the `cf-turnstile-response` field, which the managed widget injects into the form automatically. Clients that render Turnstile with the explicit API pass the token themselves and should reset the widget after every attempt so a retry gets a fresh token.

Turnstile is invisible for most humans and needs no cookie banner in most jurisdictions: it sets no ContactUsIQ cookies, and its own storage is strictly necessary for the challenge. If Turnstile is unreachable the intake API falls back to heuristics-only mode rather than failing closed, so an outage at Cloudflare never loses a lead. hCaptcha can be added as a second adapter for customers who ask; Turnstile is the only CAPTCHA until then.

## Rate limits

| Scope | Limit | Behaviour |
| --- | --- | --- |
| Per IP per form | 5 per 10 minutes | `429` with `Retry-After` in seconds |
| Per form | 60 per minute | `429` |
| Per workspace | daily ceiling by plan | silent reject beyond the ceiling |

Counters live in Redis and are allowed to be approximate. Plan quotas that matter for billing count accepted submissions only and are recomputed from Postgres nightly, so a bot attack cannot exhaust a customer's allowance. At 100% on Free, submissions are still stored and shown in the inbox; only email delivery pauses.

## Origin checks

The `Origin` header (or `Referer` for HTML posts) must match a verified domain of the form or one of its subdomains. JSON requests from browsers also hit the `OPTIONS` preflight, which returns CORS headers for verified domains only. A form can be set to allow any origin for native apps and development. The client IP used everywhere is the one from the platform's trusted edge header; caller-supplied `X-Forwarded-For` is ignored.

## Silent rejects

A rejected submission (honeypot, origin, spam score above the threshold, over the workspace ceiling) returns the same success-looking `200`, thank-you page or `303` as an accepted one. Bots learn nothing from the response. The rejection and its reason are recorded, shown in the analytics and, for spam-scored messages, kept 30 days in the hidden view. The only non-success responses are `400` (malformed), `404` (no such form), `413` (too large) and `429` (rate limited).

## Security controls

- Tenant isolation by Postgres Row Level Security on `workspace_id`; the service role key is used only by the intake function and the worker, never by the browser.
- API keys and verification tokens are stored hashed. Keys carry a visible prefix and can be rotated without downtime.
- The Turnstile secret, a least-privilege IAM credential for SES and the Stripe secret live in environment variables scoped to production; previews use test keys.
- Webhooks out are signed with HMAC-SHA256 and a timestamp; webhooks in (SES via SNS, Stripe) are verified with the provider's signature before any database write.
- A Content Security Policy and standard security headers are applied to the dashboard. The embed script is served with Subresource Integrity hashes.
- Admin actions require the platform role, are logged to the audit log with the acting account and persona, and impersonation is read-only.
- Attachments (later) are scanned, size-capped, served through signed URLs and never inlined in email.

## Your side of the contract

- Keep the honeypot and never pre-fill it.
- If you set a CSP, allow `https://api.contactusiq.com` in `script-src` and `connect-src` and `https://challenges.cloudflare.com` in `script-src` and `frame-src`.
- Do not proxy submissions through your server unless you must; it makes every visitor share your server's IP for rate limits.
- Add the privacy line under the form. See [Privacy](/privacy).
