Zen, in-app firewall for PHP | by Aikido
Zen, your in-app firewall for peace of mind– at runtime.
Zen is an embedded Web Application Firewall that autonomously protects your apps against attacks and provides advanced access controls features.
Zen protects your PHP apps by blocking malicious user input that could lead to security vulnerabilities. It guards against SQL injections, command injections, path traversal attacks, and more. Running directly on your PHP app's server, it offers seamless installation and low maintenance.
Features
Zen will autonomously protect your PHP applications from the inside against:
- 🛡️ SQL injection attacks
- 🛡️ Command injection attacks
- 🛡️ Path traversal attacks
- 🛡️ Server-side request forgery (SSRF)
- 🛡️ Attack wave detection
Zen operates autonomously on the same server as your PHP app to:
- ✅ Secure your app like a classic web application firewall (WAF), but with none of the infrastructure or cost.
- ✅ Rate limit specific API endpoints by IP or by user
- ✅ Allow you to block specific users manually
Install
Zen for PHP comes as a single package that needs to be installed on the system to be protected.
Prerequisites:
- Ensure you have sudo privileges on your system.
- Check that you have a supported PHP version installed (PHP version >= 7.2 and tested up to 8.5). See the support matrix for platform and runtime details.
- Make sure to use the appropriate commands for your system or cloud provider.
Manual install
For Red Hat-based Systems (RHEL, CentOS, Fedora)
x86_64
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.5.29/aikido-php-firewall.x86_64.rpm
arm64 / aarch64
rpm -Uvh --oldpackage https://github.com/AikidoSec/firewall-php/releases/download/v1.5.29/aikido-php-firewall.aarch64.rpm
For Debian-based Systems (Debian, Ubuntu)
x86_64
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.5.29/aikido-php-firewall.x86_64.deb
dpkg -i -E ./aikido-php-firewall.x86_64.deb
arm64 / aarch64
curl -L -O https://github.com/AikidoSec/firewall-php/releases/download/v1.5.29/aikido-php-firewall.aarch64.deb
dpkg -i -E ./aikido-php-firewall.aarch64.deb
We support Debian >= 11 and Ubuntu >= 20.04. You can run on Debian 10, by doing this setup before install: Debian10 setup
For Alpine Linux (beta)
Alpine 3.20 or newer is supported. Download the APK matching your architecture:
ARCH="$(uname -m)"
curl -L -O "https://github.com/AikidoSec/firewall-php/releases/download/v1.5.29/aikido-php-firewall.${ARCH}.apk"
apk add --allow-untrusted "./aikido-php-firewall.${ARCH}.apk"
The APK is distributed as a standalone package, so its signing key is not installed in Alpine. This is why --allow-untrusted is required.
Deployment setup
Managed platforms
Aikido Token setup
- The standard way of setting the Aikido Token is via environment variables ->
AIKIDO_TOKEN="your token". - Another way of doing that, is adding the
AIKIDO_TOKENvariable in your.envfile. - If you are unable to set any of the above, there's an alternative way of doing that from PHP, by following the "Token setup from PHP code".
Troubleshooting
Read our troubleshooting documentation.
[!IMPORTANT] If you switch PHP versions after installing Zen, you will need to reinstall the firewall. See Switching PHP versions in the troubleshooting documentation for detailed instructions.
Supported libraries and frameworks
PHP versions
Zen for PHP supports the following PHP versions: 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5.
Web frameworks
Zen for PHP is Web-framework agnostic, meaning that it will work on any PHP Web framework that you want to use.
Zen for PHP can do this because the monitored functions are hooked at the PHP-core level.
Database drivers
- ✅
PDO- ✅
MySQL - ✅
Oracle - ✅
PostgreSQL - ✅
ODBC and DB2 - ✅
Firebird - ✅
Microsoft SQL Server - ✅
SQLite
- ✅
- ✅
MySQLi - ✅
PostgreSQL - 🚧
Oracle OCI8 - 🚧
SQLite3
Outgoing requests libraries
- ✅
cURL- Including wrappers, when configured to use cURL as adapter:
- ✅
file_get_contents
Reporting to your Aikido Security dashboard
Aikido is your no nonsense application security platform. One central system that scans your source code & cloud, shows you what vulnerabilities matter, and how to fix them - fast. So you can get back to building.
Zen is a new product by Aikido. Built for developers to level up their security. While Aikido scans, get Zen for always-on protection.
You can use some of Zen’s features without Aikido, of course. Peace of mind is just a few lines of code away.
But you will get the most value by reporting your data to Aikido.
You will need an Aikido account and a token to report events to Aikido. If you don't have an account, you can sign up for free.
Here's how:
- Log in to your Aikido account.
- Go to Zen.
- Go to apps.
- Click on Add app.
- Choose a name for your app.
- Click Generate token.
- Copy the token.
- Set the token as an environment variable,
AIKIDO_TOKEN
Running in production (blocking) mode
By default, Zen will only detect and report attacks to Aikido.
To block requests, set the AIKIDO_BLOCK environment variable to true.
See Reporting to Aikido to learn how to send events to Aikido.
Additional configuration
- Track custom events: trigger events that Playbooks can act on
- Configure trusted proxies and custom client IP headers
- Configure Zen using environment variables for authentication, mode settings, debugging, and more
Benchmarks
Zen for PHP benchmarks are splitted into 2 categories:
- Benchmarks for single PHP operations (function calls) that are monitored by Zen
- Benchmarks for round-trip requests to PHP apps protected by Zen
We do automated benchmarks on each new version and we store the result in the repo. If you need some specific benchmarks for (OS, PHP version) pairs, check the benchmarks folder.
The benchmarking times displayed in this readme are computed with PHP 8.1 on the latest Ubuntu version.
Benchmarks for PHP operations
| Benchmark | Avg. time w/o Zen | Avg. time w/ Zen | Delta |
|---|---|---|---|
| Shell Execution | 1.3139 | 1.3509 | 0.0370 ms |
| Path Access | 0.0129 | 0.0160 | 0.0031 ms |
| Outgoing Request | 0.1030 | 0.1321 | 0.0291 ms |
| Sql Query | 0.0138 | 0.0169 | 0.0031 ms |
Benchmarks for PHP requests
| Benchmark | Avg. time w/o Zen | Avg. time w/ Zen | Delta |
|---|---|---|---|
| Request With Rate Limiting Enabled | 1.2310 | 1.6480 | 0.4170 ms |
| Request With User Setting | 1.2230 | 1.4430 | 0.2200 ms |
| Request Simple | 1.2370 | 1.3730 | 0.1360 ms |
Uninstall
Manual uninstall
For Red Hat-based Systems (RHEL, CentOS, Fedora)
rpm -e aikido-php-firewall
For Debian-based Systems (Debian, Ubuntu)
dpkg --purge aikido-php-firewall
For Alpine Linux (beta)
apk del aikido-php-firewall
Bug bounty program
Our bug bounty program is public and can be found by all registered Intigriti users at: https://app.intigriti.com/researcher/programs/aikido/aikidoruntime
Contributing
See CONTRIBUTING.md for more information.
Code of Conduct
See CODE_OF_CONDUCT.md for more information.
Security
See SECURITY.md for more information.