PHPackages                             szepeviktor/waf4wordpress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. szepeviktor/waf4wordpress

ActiveLibrary[Security](/categories/security)

szepeviktor/waf4wordpress
=========================

WAF for WordPress

v0.2.0(7mo ago)14426827[8 issues](https://github.com/szepeviktor/waf4wordpress/issues)MITPHPPHP ~7.4.0 || ~8.1.0

Since Dec 24Pushed 2mo ago15 watchersCompare

[ Source](https://github.com/szepeviktor/waf4wordpress)[ Packagist](https://packagist.org/packages/szepeviktor/waf4wordpress)[ RSS](/packages/szepeviktor-waf4wordpress/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (6)Used By (0)

WAF for WordPress
=================

[](#waf-for-wordpress)

[![License](https://camo.githubusercontent.com/58b94528d42334e34e3091db574c96276e18255c19928f522c1e664284eeb8ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f737a65706576696b746f722f77616634776f72647072657373)](https://github.com/szepeviktor/waf4wordpress/blob/master/LICENSE)[![PHP Version](https://camo.githubusercontent.com/a068e8d94bd8cafe6f730888a1748632134d04b7482ef2c2143d29a34f245a08/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f737a65706576696b746f722f77616634776f726470726573732f706870)](https://github.com/szepeviktor/waf4wordpress/blob/master/composer.json)[![Packagist stats](https://camo.githubusercontent.com/57004997d6e1a7c4e4e77434033eda5b1b5d6047ff5cb0371a9aa7a193f81716/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737a65706576696b746f722f77616634776f726470726573732e737667)](https://packagist.org/packages/szepeviktor/waf4wordpress/stats)[![Latest version](https://camo.githubusercontent.com/29f5b0351a4db61863c811b3f20106546d273b1b10200e9da444fd63f7e782f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737a65706576696b746f722f77616634776f726470726573732e737667)](https://packagist.org/packages/szepeviktor/waf4wordpress)[![PHPStan enabled](https://camo.githubusercontent.com/ebcc4e7df2b777cc00845dd2e39fd072868192a6e4ccc071765b627c59a35f16/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d343443433131)](https://phpstan.org/)

Stop real-life attacks on your WordPress website and trigger [Fail2Ban](https://github.com/fail2ban/fail2ban).

💡 Before using this WAF you have to clean your website, get rid of even tiny errors. See your access and error logs daily and run this WAF without Fail2ban for a week.

This WAF does not give proper HTTP responses to unusual requests. It blocks the attacking IP address instantly, the purpose of this are the following.

1. Prevent website compromise in further requests
2. Prevent DoS attacks

Shared hosting has no server-wide banning (because of trust issues) but you can still install this software without Fail2Ban to stop attacks by using one of the Miniban methods.

Support my work
---------------

[](#support-my-work)

Please consider sponsoring me monthly if you use my packages in an agency.

[![Sponsor](https://github.com/szepeviktor/.github/raw/master/.github/assets/github-like-sponsor-button.svg)](https://github.com/sponsors/szepeviktor)

Theory
------

[](#theory)

Your WordPress - really general HTTP - security consists of the followings.

1. Use HTTPS
2. Have daily backups
3. Block [known hostile networks](https://github.com/szepeviktor/debian-server-tools/tree/master/security/myattackers-ipsets)
4. Have Fail2Ban installed (controls the firewall)
5. Maintain your website and use [strict Fail2Ban filters](https://github.com/szepeviktor/debian-server-tools/tree/master/security/fail2ban-conf)which ban on the first suspicious request instantly
6. Deny direct access to core WordPress files, themes and plugins
7. Install WAF for WordPress (this project)
8. Use [Leanmail](https://github.com/szepeviktor/debian-server-tools/tree/master/security/fail2ban-leanmail)for filtering Fail2Ban notification emails

See the [Block WordPress attack vectors](https://github.com/szepeviktor/wordpress-website-lifecycle/blob/master/WordPress-security.md)note in my other repository for an overview of the topic.

Composer installation
---------------------

[](#composer-installation)

Technically this is not a WordPress plugin nor an MU plugin. WAF for WordPress is distributed and autoloaded as a Composer package.

1. Issue `composer require szepeviktor/waf4wordpress` command
2. Load `vendor/autoload.php` from your `wp-config`
3. Instantiate `SzepeViktor\WordPress\Waf\HttpAnalyzer` class early in `wp-config````
    require dirname(__DIR__) . '/vendor/autoload.php';
    new SzepeViktor\WordPress\Waf\HttpAnalyzer();
    ```
4. Create an MU plugin in `wp-content/mu-plugins/waf4wordpress.php````
