Skip to content

Hazeloft Security best practices

How to move Hazeloft Security from Dry run to Live without rejecting real users, what to mount on each kind of route and what happens on an error.

Last updated:

Most problems come from rules moved to Live too early or from protections that stopped without anyone noticing. This page is about both.

Dry run first

Each rule has a way of being wrong that shows up only on your traffic:

  • Bot Detection rejects legitimate integrators on API routes (curl, HTTP libraries, your customers’ scripts).
  • Shield finds attack signatures in text written by people: an editor, a chat or a support form can produce rejections on ordinary content.
  • Email validation with blockFree rejects Gmail, which, for most consumer products, means most sign-ups.
  • The challenge rejects every client that is not yet sending the header: cached pages, mobile apps that have not been updated, an intermediary that strips unknown headers.

In Dry run, all of these are lines in a log. On Live, they are your users’ errors.

The procedure:

  1. Start the rules in Dry run, on real traffic.
  2. Read in the console what would have been rejected and check that it is not legitimate traffic.
  3. Move a single capability to Live.
  4. Repeat. If you change one at a time, you know which one produced a complaint.

All the steps are done from the console, without a redeploy.

What to mount on each kind of route

Route What fits
Sign-up, sign-in, password reset protectSignup() at sign-up, challenge, rate limiting.
Public forms (contact, newsletter) Shield, email validation, rate limiting.
API called by other servers Shield and rate limiting, without Bot Detection and without the challenge.
Free-text routes (editor, chat, import) Shield with scanBody: false, rate limiting.

The challenge is mounted only on routes where your browser client actually runs the SDK.

What the rate limit counts on

By default, the limit counts per IP address. On routes where the user is signed in, people on the same network appear under the same address and use up each other’s limit. Count per user:

await security.protect(request, { fingerprint: `user:${session.userId}` });

Give each limit its own name. Two limits without a name share one counter.

When protection stops without a denial

Rate limiting is the only rule that leaves your process, so the only one that can fail for reasons outside your code. Such a failure gives conclusion: "error" on that rule, and with failOpen: true (the default) an error is aggregated as allow.

Situation What happens
The service does not answer within 500 ms, or answers with an error The rule errors, the request passes. There is no retry.
5 failures in a row The SDK stops trying for 30 seconds.
The key’s monthly decision quota is used up The rule errors, the request passes.
Invalid API key The rule errors, the request passes.

Two consequences:

  • Alert on conclusion: "error", not just on denials. All the cases above are visible in decision.results. A limit that has stopped looks exactly like a limit nobody is hitting.
  • On routes that must never run unprotected, set failOpen: false on that engine and handle decision.isErrored(). You are then choosing to reject the request rather than give up the protection.

With protectSignup(), the checks that could not run appear in verdict.skipped.

Troubleshooting

The challenge rejects everyone. Most likely, your clients are not sending the header yet. Keep it in Dry run until the missing code no longer appears in decision.results.

The rate limit does not seem to work. Check that each limit has a distinct name, that you count on the right key (the IP address or the user) and that the rule does not show conclusion: "error".

Before Live

  • Every capability has run in Dry run, on real traffic.
  • You have checked that it does not catch legitimate traffic.
  • You have an alert on conclusion: "error".
  • Every rate limit has its own name.
  • API routes have no Bot Detection and no challenge.
  • You move one capability to Live at a time.

All documentationSecurity product page

This site uses measurement and advertising technologies. You can accept or decline them.

How we handle your data: Privacy policy · Cookie policy