• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WAF for WordPress 🔥 with 60+ security checks and weekly updates

WAF for WordPress

Stop real-life attacks on your WordPress website and trigger 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

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

Sponsor

Theory

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

  1. Use HTTPS
  2. Have daily backups
  3. Block known hostile networks
  4. Have Fail2Ban installed (controls the firewall)
  5. Maintain your website and use strict Fail2Ban filters 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 for filtering Fail2Ban notification emails

See the Block WordPress attack vectors note in my other repository for an overview of the topic.

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
    <?php
    /*
     * Plugin Name: WAF for WordPress (MU)
     */
    if (! function_exists('add_filter')) {
        exit;
    }
    new SzepeViktor\WordPress\Waf\CoreEvents();

Manual installation

💡 Please see Composer-managed WordPress for managing WordPress with Composer.

Technically this is not a WordPress plugin nor an MU plugin.

  1. First download WAF for WordPress then extract files to a directory, e.g. waf/
  2. Instantiate SzepeViktor\WordPress\Waf\HttpAnalyzer class early in wp-config
    require_once __DIR__ . '/waf/src/HttpAnalyzer.php';
    require_once __DIR__ . '/waf/src/CoreEvents.php';
    new SzepeViktor\WordPress\Waf\HttpAnalyzer();
  3. Create an MU plugin in wp-content/mu-plugins/waf4wordpress.php
    <?php
    /*
     * Plugin Name: WAF for WordPress (MU)
     */
    if (! function_exists('add_filter')) {
        exit;
    }
    new SzepeViktor\WordPress\Waf\CoreEvents();

Configuration

WAF for WordPress is configured in source code before class instantiation. in wp-config.

Create custom filters for Fail2Ban catching these PHP messages.

  • Likely malicious requests: Malicious traffic detected: may be banned after 6 attempts per 10 minutes
  • Surely break-in attempts: Break-in attempt detected: may be banned instantly

How to support PayPal IPN, Braintree and custom entry points in poorly written plugins

Copy this into your in wp-config.php.

// Enable PayPal IPN in WooCommerce
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
    if ( '/wc-api/WC_Gateway_Paypal/' === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ) {
        // PayPal IPN does not send Accept: and User-Agent: headers
        $_SERVER['HTTP_ACCEPT'] = '*/*';
        $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 PayPal/IPN';
    }
}

// Enable Braintree Webhooks
new \Waf4WordPress\Braintree_Fix( '/braintree/webhook' );

// Enable email opens in Newsletter plugin
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
    $newsletter_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
    if ( '/wp-content/plugins/newsletter/statistics/open.php' === $newsletter_path
        || '/wp-content/plugins/newsletter/statistics/link.php' === $newsletter_path
    ) {
        // UA hack for old email clients
        $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 ' . $_SERVER['HTTP_USER_AGENT'];
    }
    unset( $newsletter_path );
}

// Enable email open tracking in ALO EasyMail Newsletter plugin
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
    $alo_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
    if ( '/wp-content/plugins/alo-easymail/tr.php' === $alo_path ) {
        // UA hack for old email clients
        $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 ' . $_SERVER['HTTP_USER_AGENT'];
    }
    unset( $alo_path );
}

Bug reports and feature requests

Open a new issue

Where script kiddies look for WordPress

  • /backup/
  • /blog/
  • /cms/
  • /demo/
  • /dev/
  • /home/
  • /main/
  • /new/
  • /old/
  • /portal/
  • /site/
  • /test/
  • /tmp/
  • /web/
  • /wordpress/
  • /wp/

Best not to create these directories to avoid lengthy log excerpts.

More Repositories

1

debian-server-tools

Tools and living docs 🧬 for Debian-based servers and Web Applications
Shell
460
star
2

w3-total-cache-fixed

A community driven build of W3 Total Cache. The aim is to continuously incorporate fixes, improvements, and enhancements over the official WordPress release of W3 Total Cache.
PHP
237
star
3

phpstan-wordpress

WordPress extensions for PHPStan ⛏️
PHP
212
star
4

wordpress-plugin-construction

Tools 🧰 for developing and running WordPress websites
PHP
89
star
5

wordpress-speedtest

VPS Speedtest for WordPress with 160 results: 🏆 UpCloud (raw memory and CPU benchmark)
PHP
48
star
6

windows-workstation

Prepare my Windows 10 workstation
JavaScript
40
star
7

wordpress-website-lifecycle

How to work with WordPress 📅 for long years
PHP
40
star
8

starter-plugin

Template for WordPress plugins, it took 7️⃣ years to write
PHP
35
star
9

wordpress-autoloaded

🔟% Faster WordPress ⚡ without unconditional class loading + Composer
Shell
29
star
10

composer-envato

Composer plugin for Envato 💚 Install WordPress themes and plugins from ThemeForest‎‎ and CodeCanyon
PHP
28
star
11

tiny-cache

🚄 Cache WordPress post content, template part, translations and nav menu output in persistent object cache
PHP
27
star
12

wplib

wp-cli wrapper shell scripts to manage multiple sites with sudo
Shell
26
star
13

auto-login

Automatically log in to WordPress during development - an MU plugin
PHP
22
star
14

composer-managed-wordpress

Install and manage WordPress with Composer 👨‍🚀
Shell
18
star
15

github-link

GitHub Link WordPress plugin
PHP
15
star
16

WordPress-the-good-parts

A sustainable and modernized version of WordPress core.
PHP
13
star
17

tiny-cdn

Use an origin pull CDN with very few lines of code - WordPress plugin
PHP
13
star
18

very-clean-code

How to code without future problems ⚪
11
star
19

RootFiles

Important files in the document root which get downloaded without links.
PHP
11
star
20

acf-get

Strongly typed Advanced Custom Fields get_field function variants
PHP
11
star
21

Toolkit4WP

OOP toolkit 🔧 for daily tasks in WordPress development.
PHP
10
star
22

phpcs-psr-12-neutron-hybrid-ruleset

My useful frankenstein PHPCS ruleset 👓 for OOP WordPress development
PHP
10
star
23

plugin-installer-speedup

WordPress Plugin Installer Speedup
PHP
9
star
24

infrastructure-for-hosting-web-applications

My policies on hosting anything web-related 💾
9
star
25

WPHW

WordPress the hard way, plugin refactoring
PHP
9
star
26

monit-services

Michael Fladischer's monit plugins (mirror)
9
star
27

SentencePress

A set of words that is complete in itself. - OOP wrappers for WordPress
PHP
8
star
28

image-factory

Advanced real-time image optimization with mozjpeg on your server - WordPress plugin
PHP
8
star
29

unique-email-address

Normalize an email address 📨
PHP
7
star
30

option-inspector

Option Inspector plugin for WordPress
PHP
7
star
31

resource-versioning

It’s important to make resources (images, scripts, stylesheets, etc.) cacheable.
PHP
6
star
32

rectorize

Run rectorphp/rector on PHP 8.0 code to downgrade it
PHP
6
star
33

wordpress-persistent-admin-notices

Persistent admin notices for WordPress.
PHP
5
star
34

uninformative-words

Variable names you should avoid 👺
5
star
35

github-repository-inspection

Viktor attacks your repository with a 🔎
5
star
36

injector-php-7

Recursive dependency injector for PHP 7.4
PHP
5
star
37

wp-cli-check-update

Check wp-cli version for update via Github API
PHP
4
star
38

smtp-uri

SMTP URI WordPress plugin
PHP
4
star
39

phive

Install PHIVE in GitHub Actions
Shell
4
star
40

package-path

Get full installation path of any Composer package
PHP
3
star
41

hosting-check

Hosting (webspace) checker
Shell
3
star
42

how-to-operate

THis is hot stuff on people working with web applications 🌶
3
star
43

svn-updater

Enables installation of a WordPress plugin's SVN trunk version.
PHP
3
star
44

byte-level-care

Living with zero problems while developing your web application
Dockerfile
3
star
45

svg-validator

Validate SVG files in your GitHub Actions workflow
Shell
3
star
46

ip-info

IP address info - an HTML app
HTML
3
star
47

running-laravel

Running Laraval framework-based web applications for long years 🪘
PHP
3
star
48

github-next-example-block

Block for your README (React)
TypeScript
2
star
49

wordpress-install

Install and manage WordPress with Composer in agency-type projects
2
star
50

ISO-3166-orszagnevek-magyarul

Ország- és területnevek magyarul 🇭🇺
Shell
2
star
51

html-validate

Mirror of html-validate npm package
TypeScript
2
star
52

frontend-debugger

Frontend Debugger WordPress plugin
PHP
2
star
53

smart-image-resize-test

Fork of https://wordpress.org/plugins/smart-image-resize/ WordPress plugin
PHP
2
star
54

gitify

Convert WordPress-versioned zip release archives to a tagged git repo
Shell
2
star
55

acf-custom-database-tables-test

Static analysis for Advanced Custom Fields: Custom Database Tables
PHP
2
star
56

debian-normalized

My very first normalized Debian Docker image
Shell
2
star
57

composer-theme-fusion

Composer plugin for ThemeFusion ⬢
PHP
2
star
58

multipart-robotstxt-editor

Customize your WordPress site's robots.txt and include remote content to it.
PHP
2
star
59

zdkimfilter

"z" DKIM filter for Courier-MTA using the OpenDKIM Project's library
C
2
star
60

systemjs-example

Usage example for conditional resource loading in WordPress websites
JavaScript
2
star
61

phpstan-phpdoc

PHPDoc and typehint checks **only** for PHPStan 📜
2
star
62

wp-cli-database-prefix-command

Perform operations on prefixed database tables, a wp-cli package
PHP
2
star
63

courier-pythonfilter

Courier pythonfilter (mirror)
Python
1
star
64

fruit-alphabet

🍏 🍌 🍒
1
star
65

phive-action-example

An example on how to use PHIVE in GitHub Actions
1
star
66

html2text

Convert HTML to Markdown-formatted text.http://www.aaronsw.com/2002/html2text/
Python
1
star
67

KATA

KATÁ-s lettem! Kisadózó vállalkozások tételes adója
1
star
68

courier-pythonfilter-custom

Email correction and spam filters for the Courier MTA
Python
1
star
69

shared-hosting-aid

When you must touch websites on shared hosting
PHP
1
star
70

getter-setter

You 👨‍💻 don't have to write/generate getter and setter methods anymore!
PHP
1
star
71

machine-language

Machine Language WordPress plugin: Toggles human and machine language (aka IDs) on admin pages
PHP
1
star
72

Seo-Panel

World's first seo control panel for multiple websites
PHP
1
star
73

bandwidth

Bandwidth: a memory bandwidth benchmark
1
star
74

browser-feelings

The modern browser is an untameable, pulsating ball of goo.
1
star
75

lean-filter

Adblock Plus filter
Shell
1
star
76

OOP4WordPress

OOP API-s for WordPress
1
star
77

amd-window

Helps depending on the window object
JavaScript
1
star
78

VoIP

☢️ Telefonálás mikrohullámok nélkül
1
star
79

typos-on-you

Run Typos on any GitHub repository
1
star
80

phpstan-editorlink

Editor link error formatter for PHPStan
PHP
1
star
81

Unified-Post-Types

WordPress plugin to unify your custom post types.
PHP
1
star
82

DMARC-XML-Schema

Official DMARC XML Schema from RFC-7489
1
star
83

wp-cli-readme-command

Validate readme.txt of themes and plugins
PHP
1
star
84

szepeviktor

About Viktor 🟣
1
star
85

wp-cli-option-list-command

wp-cli-option-list-command
PHP
1
star
86

phive-install

GitHub action to install PHP tools with PHIVE
1
star
87

szepeviktor.github.io

A Debian mirror for modern webservers
Shell
1
star
88

water-in-the-air

I like water getting in the air 💧💧💧
1
star
89

zero-bytes-theme

Zero Bytes theme for WordPress
PHP
1
star
90

Watcher

Watcher-getzze
Python
1
star
91

keyboard

What makes a keyboard useful for you.
1
star
92

google-tag-manager-tag-lister

List tags of Google Tag Manager
Shell
1
star
93

mkpasswd

Encrypt a password as crypt(3) libc function does: with salt and hashed
JavaScript
1
star
94

fast-forward-youtube-ads

⏩ Bookmarklet for YouTube with two JavaScript function calls only
1
star
95

woocommerce-critical-vulnerability-sql-injection

Difference between WooCommerce release 5.5.0 and 5.5.1
PHP
1
star
96

phpcs-ruleset-validator

GitHub action for PHPCS rulesets
Shell
1
star
97

custom-sucuri

Custom settings for Sucuri Scanner WordPress plugin
PHP
1
star
98

spruce-reporter

🇭🇺 Report browser UA, IP address, UTC time
HTML
1
star