MirLabs / The blog / Security / Open source

Blocking a bot without blocking a whole office

A shared IP address can get blocked because of a single infected machine. Sentinelle 0.5 keeps permanent bans, but lets humans through in one click.

· Cyril Delage · 2 min read · Lire en français

Three people working in an open-plan office
Photo: LYCS Architecture on Unsplash

Sentinelle, my Symfony security bundle, blocks the addresses that look for your secrets: a .env, a .git folder, a key. Bans escalate: 24 hours the first time, 7 days the second, then permanent. An address that comes back after a week to look for your .env again is not passing by chance.

That choice has a blind spot, and I did not want to hide it.

One address, several people

Behind a single IP address there can be a lot of people: a company network, a school, a mobile operator sharing its addresses among thousands of customers. One infected machine on that network scans your site, and the whole address ends up blocked. With a permanent ban, real visitors, maybe customers, can no longer get in, without knowing why.

The easy answer would be never to ban permanently again. I did not take it: scanners come back, and a ban that expires lets them back in.

Letting humans through

Since version 0.5, a browser whose address is blocked no longer hits a wall. It sees a page that explains: "Your network was blocked after suspicious requests." With a button.

On a click, the browser does a small calculation in JavaScript, under a second, with no captcha and no outside service. Once it is done, it gets a signed pass, valid 24 hours, tied to that address. The innocent colleague carries on with their visit. The bot, which does not do the calculation, stays outside.

Three safeguards:

  • sensitive files stay closed to everyone, pass or not;
  • attempts are limited, and each challenge works only once;
  • if a browser holding a pass tries an attack, the pass is withdrawn for the whole address.

Protection that breaks the site destroys more than it defends

That is the rule that has guided Sentinelle from the start. It was born of an incident: I nearly blocked a Mailgun server by hand, which would have silently cut off all incoming email for one of my sites. Since then, critical providers cannot be blocked, and webhooks never trigger a ban.

The pass page applies the same rule to people: be hard on bots, without making the humans who share their address pay for it.

Sentinelle is free and open source. The documentation also explains the setting not to forget behind a proxy (trusted_proxies), without which all your visitors share the same address.

A project like this one?AI integration, a site to make readable by assistants, security: let's talk.
Contact me

Read next