# Built-in protections

> Rate limits, lockout, CAPTCHA, the audit log and the other defences every project has from the start.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://data.docs.sypnia.com/auth/protections/

For agents: Auth protections: rate limits kept in Postgres (sign-up 30/h/IP, OTP and recovery 5/h/e-mail and 30/h/IP, password sign-in 30 per 5 min per IP+e-mail with exponential lockout after 10 failures, refresh 1800/h/session, /oauth/token 600/min/client), CAPTCHA hook (Turnstile or hCaptcha), no user enumeration, audit log sypnia_auth.audit_log (IP stored as prefix + HMAC), refresh-token reuse detection, new-device e-mail (password sign-in from an unseen network), secret keys refused from browsers.

## Rate limits

Limits are kept in your database (`sypnia_auth.rate_limits`), so they hold however many copies of the engine run.

| Action                                     | Default limit                                                                      |
| ------------------------------------------ | ---------------------------------------------------------------------------------- |
| Sign-up                                    | 30 per hour per IP                                                                 |
| Sign-in links and codes, password recovery | 5 per hour per e-mail, 30 per hour per IP                                          |
| Password sign-in                           | 30 per 5 minutes per IP and e-mail; after 10 failures, waits that double each time |
| Token refresh                              | 1 800 per hour per session                                                         |
| `/auth/v1/oauth/token`                     | 600 per minute per client                                                          |

Every limit is a project setting. A limited request gets `429` with `Retry-After`.

## CAPTCHA

Set a provider (Cloudflare Turnstile or hCaptcha) and its secret; sign-up, sign-in links and codes, recovery and password sign-in then require `captchaToken` from your form.

## No user enumeration

Sign-in failures, recovery and sign-in links answer the same whether the e-mail exists or not.

## The audit log

`sypnia_auth.audit_log` records sign-ups, sign-ins, failures, refreshes, reuse detections, password and e-mail changes, bans, deletions, token and key creation and revocation, with the actor, the user agent and the time. IP addresses are stored as a network prefix (`/24` or `/48`) plus an HMAC of the full address, enough to spot patterns without keeping who is where. Kept 90 days by default.

## And also

- Refresh-token reuse ends the session ([Sessions and tokens](https://data.docs.sypnia.com/auth/sessions-and-tokens)).
- A password sign-in from a network the person has not used before e-mails them (`new_device`), when they already had a session.
- Secret keys sent from a browser are refused (`secret_key_in_browser`).
- Sensitive changes need a recent sign-in or a fresh code.
