request-shield in front of a public site
This page is for administrators and hosting teams of public sites. Public sites receive scanners, credential attacks and scrapers every day. request-shield is a small web application firewall for PHP that decides about each request before the Exponential kernel starts: it refuses scanners and broken requests, slows floods, asks suspicious clients for an invisible browser check, and can restrict the administration (Security hardening: A shield in front).
Contents
- What it is and is not
- Classifier and shield side by side
- Introducing it
- Procurement and governance notes
- Related pages
What it is and is not
- A separate library: https://github.com/cjw-network/request-shield, MIT license, by the CJW Network.
- Not part of Exponential's
composer.json; you add it withcomposer require cjw-network/request-shield, or as a checkout outside the document root. - It cannot tell a right password from a wrong one: account lockout and two-step sign-in stay Exponential's job.
- It does not see static files the web server serves itself.
Classifier and shield side by side
| Kernel request classifier | request-shield | |
|---|---|---|
| Does | classifies only (probe, traversal, injection, scanner, 404 bursts) | decides: refuse, slow, challenge, ban, or only log |
| Runs | inside the kernel | before the kernel |
| Log | var/log/security.log | its own log and a live view under /rs/ |
| Settings | settings/requestclassifier.ini | its rule files |
They use the same rule names where they overlap, so a line in one can be found in the other.
Introducing it
- Install the library; copy the Exponential example rules from its
examples/exponential/directory to a directory the web server never serves (the library suggestssettings/request-shield/). - Choose the main file:
exponential-admin-uri.rules(administration at/adminon the same host) orexponential-admin-host.rules(administration on its own host). - Switch it on for every request: with PHP-FPM a
Shield::protectFile()call at the top ofconfig.phporauto_prepend_file; under Velocity the file named in the constantEXP_REQUEST_PREPEND_FILE(since 6.0.15). - Monitor mode first (
set mode monitor, as the examples ship): read the log for a few days while editors work. - Adapt the site-specific lines (siteaccesses, extension modules that take forms, host names, load balancer).
- Check and test after every change:
bin/request-shield check <main file>,bin/request-shield test <main file>,bin/request-shield trace <main file> "GET https://www.example.gov/...". - Switch to
set mode enforce; keep the ban and strict rules watched until their log is clean. - To switch it off, use
set mode off, not removing the include.
Procurement and governance notes
- It is third-party open source software: record it in your software inventory with its license and version, and follow its releases like any dependency.
- Its log holds addresses of visitors; include it in your records of processing and its retention in your retention plan.
- The example rules restrict system URLs and administration modules on the public site, which also reduces the attack surface for scanners.
Related pages
- Security hardening
- Request logs
- request-shield and request rules for hosts
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.