By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
10alert.com10alert.com
  • Threats
    • WordPress ThreatsDanger
    Threats
    A cyber or cybersecurity threat is a malicious act that seeks to damage data, steal data, or disrupt digital life in general. Cyber threats include…
    Show More
    Top News
    Malware Reigned Supreme In 2012
    8 months ago
    BEWARE THE THINGBOT!
    8 months ago
    Is your PC a part of botnet? Check it!
    8 months ago
    Latest News
    Safeguards against firmware signed with stolen MSI keys
    1 day ago
    WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin
    1 day ago
    Wordfence Intelligence Weekly WordPress Vulnerability Report (May 15, 2023 to May 21, 2023)
    6 days ago
    Wordfence Firewall Blocks Bizarre Large-Scale XSS Campaign
    1 week ago
  • Fix
    Fix
    Troubleshooting guide you need when errors, bugs or technical glitches might ruin your digital experience.
    Show More
    Top News
    The creator of malware has infected her own computer
    8 months ago
    Windows 11 build 22622.450 (KB5016700) releases in the Beta Channel
    8 months ago
    Windows 11 build 22000.613 (KB5012592) outs with new fixes
    8 months ago
    Latest News
    How automatically delete unused files from my Downloads folder?
    4 months ago
    Now you can speed up any video in your browser
    4 months ago
    How to restore access to a file after EFS or view it on another computer?
    4 months ago
    18 Proven Tips to Speed Up Your WordPress Site and Improve SEO | 2023 Guide
    5 months ago
  • How To
    How ToShow More
    What is two-factor authentication | Kaspersky official blog
    2 days ago
    Acer refreshes Windows 11 PCs for work and play: Swift Edge 16 and Predator Triton 16
    4 days ago
    NVIDIA GeForce RTX 4080 New Mercury Editions of Razer Blade 16 and Blade 18 now available
    4 days ago
    How Oxy uses hooks for maximum extensibility
    How Oxy uses hooks for maximum extensibility
    5 days ago
    The personal threat landscape: securing yourself smartly
    5 days ago
  • News
    News
    This category of resources includes the latest technology news and updates, covering a wide range of topics and innovations in the tech industry. From new…
    Show More
    Top News
    How to delete Automatically cookie files
    8 months ago
    Millions servers affected by Exim software
    8 months ago
    AutoComplete WooCommerce Virtual Products
    8 months ago
    Latest News
    How to create virtual drive (VHD, VHDX, Dev Drive) on Windows 11
    2 days ago
    How to enable Taskbar End Task option to close apps on Windows 11
    2 days ago
    How to check USB4 devices specs from Settings on Windows 11
    2 days ago
    How to enable new header UI for File Explorer on Windows 11
    1 week ago
  • Glossary
  • My Bookmarks
Reading: How to Use Cloudflare to Secure Your WordPress Site
Share
Notification Show More
Aa
Aa
10alert.com10alert.com
  • Threats
  • Fix
  • How To
  • News
  • Glossary
  • My Bookmarks
  • Threats
    • WordPress ThreatsDanger
  • Fix
  • How To
  • News
  • Glossary
  • My Bookmarks
Follow US
FixHow To

How to Use Cloudflare to Secure Your WordPress Site

Tom Grant
Last updated: 13 January
Tom Grant 8 months ago
Share
8 Min Read

Cloudflare Firewall Rules for Securing WordPress This guide is aimed at security-minded webmasters who run a WordPress site or blog on a Cloudflare-enabled domain. On the free plan, Cloudflare grants five firewall rules that are empty by default.

Contents
1. Block wp-login.php Attacks2. Block xmlrpc.php Attacks3. Protect the wp-admin Area4. Block No-Referer Requests to Plugins5. Reduce Spam by Blocking Direct Requests to wp-comments-post.php

By adding WordPress-specific rules I describe on this page, you can secure your site and block attacks before they even reach your web host’s server.

Whitelist Your IP Address

Before you implement any firewall rules, you should first whitelist your own IP. This way you won’t be affected should you decide to block your WordPress admin area from outsiders (which I will explain in a minute).

This can be done by accessing your Cloudflare dashboard and clicking Firewall, then Tools, entering your IP*, and choosing Whitelist in the drop-down menu.

Whitelisting an IP in CloudFlare Firewall.

Whitelisting an IP in CloudFlare Firewall.

*You have several choices here in the order of decreasing security:

  • Whitelist your exact IP address. Optimal choice if your ISP grants you a static IP. Note that if your IP changes, you will need to reenter it lest you get locked out of your WordPress admin area.
  • Whitelist your ISP’s entire IP range. Good choice if you have a dynamic IP.
  • Whitelist your country. This won’t protect you from attacks coming from inside your own country, but it can be a convenient option if you travel frequently and use Wi-Fi to connect to your WordPress site.

An IP address or a country whitelisted in this manner will be exempt from all firewall rules, so you won’t need to add exceptions for each individual rule.

1. Block wp-login.php Attacks

If you peek at your server logs, you’ll probably find numerous IPs from all over the world trying to access your wp-login.php file. This is by far the most common attack on WordPress installations. These are usually automated scans which do not pose a big threat, but you can still block them off for your peace of mind.

This of course assumes that you (the admin) are the only user on your site. If you have multiple users or use a membership plugin, you’ll probably want to skip this rule.

In your Cloudflare dashboard, click Firewall once again, then press the blue Create a Firewall rule button. Name it whatever you like and enter the following:

  • Field: URI Path
  • Operator: contains
  • Value: /wp-login.php

[Action: Block]

If you did it right, you should see the following in the Expression Preview section.

  (http.request.uri.path contains "/wp-login.php")

Save the rule, and it should be enabled automatically. Cloudflare will now block every attempt to connect to wp-login.php except from the IP you whitelisted.

These brute force attempts will vanish from your server logs, but you’ll be able to track them on Cloudflare’s Firewall Events section should you wish to verify that the protection is working.

2. Block xmlrpc.php Attacks

After wp-login.php, xmlrpc.php is the second most common attack target. XML-RPC has legitimate uses, such as blogging from a smartphone or posting content to multiple WordPress sites at once. If you don’t do that, then it can be safely blocked. Follow the same procedure as previously and create the rule:

  • Field: URI Path
  • Operator: contains
  • Value: /xmlrpc.php

[Action: Block]

You should see the following in the Expression Preview section.

  (http.request.uri.path contains "/xmlrpc.php")

3. Protect the wp-admin Area


Now let’s make it so you and only you can access your admin area. This rule is slightly more complex because you need to make two exceptions.

First is /wp-admin/admin-ajax.php, which is used by certain plugins to display dynamic content on your website. As such, despite being located inside the /wp-admin/ folder, it needs to be accessible from the outside.

Second is /wp-admin/theme-editor.php, which runs an error check every time you edit your theme through the built-in editor by creating a loopback request to your homepage. If you don’t add this exception, the check will fail with a message “Unable to communicate back with site to check for fatal errors” and your modifications won’t be saved.

Go ahead and create the following rule:

  • Field: URI Path
  • Operator: contains
  • Value: /wp-admin/

[AND]

  • Field: URI Path
  • Operator: does not contain
  • Value: /wp-admin/admin-ajax.php

[AND]

  • Field: URI Path
  • Operator: does not contain
  • Value: /wp-admin/theme-editor.php

[Action: Block]

Or, just click Edit expression and paste in the following.

  (http.request.uri.path contains "/wp-admin/" and not http.request.uri.path contains "/wp-admin/admin-ajax.php" and not http.request.uri.path contains "/wp-admin/theme-editor.php")

4. Block No-Referer Requests to Plugins

Most WordPress sites get hacked through insecure plugins. The best approach, of course, is not to install them in the first place, but you can also create a firewall rule blocking direct access to /wp-content/plugins/.

Legitimate requests which come through your website have something along the lines of ”http://yoursite.com/page” as the HTTP referer and should be allowed. You may also want to allow known good bots (such as the Google crawler) just in case they try to index something—such as an image—inside your plugins folder.

Create the following rule:

  • Field: URI Path
  • Operator: contains
  • Value: /wp-content/plugins/

[AND]

  • Field: Referer
  • Operator: does not contain
  • Value: yoursite.com (replace with your real domain)

[AND]

  • Field: Known Bots
  • Operator: equals
  • Value: Off

[Action: Block]

Or, just paste this expression in directly (remember to replace yoursite.com with the actual address).

  (http.request.uri.path contains "/wp-content/plugins/" and not http.referer contains "yoursite.com" and not cf.client.bot)

5. Reduce Spam by Blocking Direct Requests to wp-comments-post.php

I’ll be honest: the effect of this rule will be minimal as spam bots these days are sophisticated enough to spoof the referrer. This will only block bots hammering the wp-comments-post.php file directly. Still, the same tip is described in WordPress Codex (except they use a .htaccess rule rather than Cloudflare), so if it’s good enough for them, it’s good enough for me.

The rule is as follows:

  • Field: URI Path
  • Operator: equals
  • Value: /wp-comments-post.php

[AND]

  • Field: Request Method
  • Operator: equals
  • POST

[AND]

  • Field: Referer
  • Operator: does not contain
  • Value: yoursite.com (replace with your real domain)

[Action: Block]

And here’s the expression to save you the time.

  (http.request.uri.path eq "/wp-comments-post.php" and http.request.method eq "POST" and not http.referer contains "yoursite.com")

Your Website Is Now Slightly More Secure


These five rules should cover the most common WordPress attacks, but feel free to adjust and combine them according to your needs.

Most attacks you see in your logs come from automated bots just dumbly scanning websites for vulnerabilities, but should a person from outside your whitelisted IPs try to access your admin area, they will be greeted with an “Error 1020” page like this (you can confirm this by accessing it via a proxy or VPN).

This is the page a potential attacker will see after triggering one of your firewall rules.

This is the page a potential attacker will see after triggering one of your firewall rules.


Translate this article

TAGGED: Cloudflare, PoC, Security, Split tunneling, Threat, Threats, Vulnerabilities, WordPress
SOURCES: turbofuture.com
Tom Grant January 13, 2023 October 7, 2022
Share this Article
Facebook Twitter Reddit Telegram Email Copy Link Print

STAY CONECTED

24.8k Followers Like
253.9k Followers Follow
33.7k Subscribers Subscribe
124.8k Members Follow

LAST 10 ALERT

Safeguards against firmware signed with stolen MSI keys
Threats 1 day ago
WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin
WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin
Wordpress Threats 1 day ago
How to create virtual drive (VHD, VHDX, Dev Drive) on Windows 11
News 2 days ago
How to enable Taskbar End Task option to close apps on Windows 11
News 2 days ago
How to check USB4 devices specs from Settings on Windows 11
News 2 days ago

Recent Posts

  • Safeguards against firmware signed with stolen MSI keys
  • WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin
  • How to create virtual drive (VHD, VHDX, Dev Drive) on Windows 11
  • How to enable Taskbar End Task option to close apps on Windows 11
  • How to check USB4 devices specs from Settings on Windows 11

You Might Also Like

Threats

Safeguards against firmware signed with stolen MSI keys

1 day ago
WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin
Wordpress Threats

WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin

1 day ago
News

How to create virtual drive (VHD, VHDX, Dev Drive) on Windows 11

2 days ago
How To

What is two-factor authentication | Kaspersky official blog

2 days ago
Show More

Related stories

How To Starting Chrome from the command line
How to fix error 0x80070057 in Chrome?
Windows 10 How To Disable Slide to Shutdown
Windows search not working (FIX)
How to watch movies and TV series for free on Kinopoisk?
How to enable DNS OVER HTTPS in Microsoft Edge?
Previous Next

10 New Stories

What is two-factor authentication | Kaspersky official blog
Acer refreshes Windows 11 PCs for work and play: Swift Edge 16 and Predator Triton 16
NVIDIA GeForce RTX 4080 New Mercury Editions of Razer Blade 16 and Blade 18 now available
How Oxy uses hooks for maximum extensibility
The personal threat landscape: securing yourself smartly
Wordfence Intelligence Weekly WordPress Vulnerability Report (May 15, 2023 to May 21, 2023)
Previous Next
Hot News
Safeguards against firmware signed with stolen MSI keys
WPDeveloper Addresses Privilege Escalation Vulnerability in ReviewX WordPress Plugin
How to create virtual drive (VHD, VHDX, Dev Drive) on Windows 11
How to enable Taskbar End Task option to close apps on Windows 11
How to check USB4 devices specs from Settings on Windows 11
10alert.com10alert.com
Follow US

© 10 Alert Network. All Rights Reserved.

  • Privacy Policy
  • Contact
  • Customize Interests
  • My Bookmarks
  • Glossary
Go to mobile version
adbanner
AdBlock Detected
Our site is an advertising supported site. Please whitelist to support our site.
Okay, I'll Whitelist
Welcome Back!

Sign in to your account

Lost your password?