Agility, Java programming, New technologies and more…
  • rss
  • Home
  • Management
  • Agile Programming
  • Technology
  • Linux
  • Event
  • Android app
  • Contact
  • About the author
  • English
  • Francais

Tips to make your WordPress website secure

Fabian Piau | Wednesday October 10th, 2018 - 06:43 PM
  • Print
  • Twitter
  • LinkedIn
  • Facebook
  • Pocket

 Version française disponible

Update
January, 14th, 2021 : Update security headers, replaced “Feature-policy” with “Permissions-policy”.

WordPress is one of the most popular CMS (Content Management System). That popularity also means that it is a target of choice for hackers.
In this article, I will give you some tips to keep your website secure and avoid being attacked.


1. Use latest versions

This is true for WordPress itself but also for all your extensions. There are new versions available regularly. If a plugin has not been updated for a while, it is probably not maintained anymore and you might need to remove or replace it. This is also applicable for your theme.
The version of PHP is also important, check with your hosting provider that you are running the latest version of PHP (7.X), especially the versions 5.X won’t be supported by the end of the year.
Also, note that the more extensions you have installed, the more risk you are taking, as your WordPress configuration will rely on more 3rd party code. You should only keep the plugins that you really need. If a plugin is disabled, don’t keep its source code and remove all its associated files.


2. Use secure login details

Never use the default admin user. If you do, disable this account and create your own account with a personalized username.
Choose a strong password. If several users are managing your website, make sure the permissions are valid and avoid giving the admin permission to everyone.


3. Scan your website

This is an easy and quick way to find vulnerabilities and see if one of your plugins is vulnerable or not. You can use these 2 online tools:

  • WordPress Security Scan (my favourite with a detailed report)
  • WPSec


4. Use .htaccess files to protect your directories

The .htaccess file is a server configuration file. It allows you to define rules for your server to follow.

For example, in /wp-content/uploads, I have created the following .htaccess:

# Deny access to everything by default
Order deny,allow
Deny from all

# Allow access to media files
<FilesMatch '\.(jpg|jpeg|png|gif|bmp|zip|rar|pdf)$'>
    Allow from all
</FilesMatch>

This config ensures only media files are accessible from the browser, any JavaScript, PHP files will be discarded. It is not 100% bulletproof as only the extension is checked, but it is better than nothing.

To avoid execution of malicious PHP in some folder (e.g. in /wp-includes), you can create another .htaccess file with the following content:

<Files *.php>
Order allow,deny
Deny from all
</Files>


5. Review file and directory permission

Make sure the critical files (wp-config.php, php.ini…) are not writable publicly, only readable. Only owners should be able to write.


6. Use security headers

You can check which security headers you currently use with this online tool.

At the root folder, update the .htaccess file and add:

# Extra Security Headers
<IfModule mod_headers.c>
	Header set Strict-Transport-Security 'max-age=31536000; includeSubDomains'
	Header set X-XSS-Protection '1; mode=block'
	Header set X-Frame-Options 'sameorigin'
	Header set X-Content-Type-Options 'nosniff'
	Header unset Server
	Header always unset X-Powered-By
	Header unset X-Powered-By
	Header unset X-CF-Powered-By
	Header unset X-Mod-Pagespeed
	Header unset X-Pingback
</IfModule>

In wp-config.php, add:

/** Extra Security */
header('X-Frame-Options: SAMEORIGIN');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('Strict-Transport-Security:max-age=31536000; includeSubdomains; preload');
header('Referrer-Policy: no-referrer-when-downgrade');
header('Content-Security-Policy: upgrade-insecure-requests');
header('Permissions-Policy: autoplay=(), camera=(), encrypted-media=(), fullscreen=(), geolocation=(), microphone=(), midi=(), payment=()');
header_remove('X-Powered-By');
header_remove('Server');
header_remove('X-CF-Powered-By');
header_remove('X-Mod-Pagespeed');
header_remove('X-Pingback');
@ini_set('session.cookie_httponly', true);
@ini_set('session.cookie_secure', true);
@ini_set('session.use_only_cookies', true);


7. Do not expose too much information

At the root folder of your website, in php.ini, add the line:

expose_php = Off

Your current version of PHP will not be exposed.


8. Backup your website regularly

Last but not least! You don’t need a particular software or extra plugin to achieve this.

  • With your favourite FTP tool (e.g. Filezilla), save all the files available on your server.
  • For the database, use the available MySQL backup feature. Many hosting companies provide access to phpMyAdmin, an online tool.

I recommend doing a backup every month, and keep the history of the last 6 backups somewhere safe. Of course, it depends on the volume of articles you are writing and how critical is your data.


That’s it! If you have done all the above, your website should be more resilient to attacks. In the worst case, you should be able to recover easily.

Happy safe blogging!

Related posts

Maven siteMaven Site, one step further IT securitySome basic rules to prevent your accounts from getting hacked Apache CamelFirst steps with Apache Camel printerOptimize your website for print in 5 minutes
Comments
No Comments »
Categories
Technology
Tags
hacking, hacker, security, wordpress
Comments rss Comments rss
Page 1 of 11
Download CarmaBlog App

RSS feeds

  • RSS Feed RSS - Posts
  • RSS Feed RSS - Comments

Most viewed posts

  • Changing the language in Firefox - 114,915 views
  • Using Google Forms / Drive / Docs to create an online survey - 61,528 views
  • FAQ – Online survey with Google Forms / Drive / Docs - 41,324 views
  • Customizing Gnome 3 (Shell) - 29,099 views
  • The meaning of URL, URI, URN - 15,919 views
  • Java EE & CDI vs. Spring - 14,816 views
  • Open Street Map, better map than Google Maps? - 13,776 views
  • Comparing NoSQL: Couchbase & MongoDB - 13,525 views
  • Firefox Nightly, Aurora, Beta, Desktop, Mobile, ESR & Co. - 12,725 views
  • First steps with Apache Camel - 11,724 views

Recent Comments

  • Saint hilaire albert on FAQ – Online survey with Google Forms / Drive / Docsmerci beaucoup
  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsNon, ce n’était pas la bonne pratique effectivemen…
  • Saint hilaire albert on FAQ – Online survey with Google Forms / Drive / Docsah, alors je crois avoir trouvé : mon lien se term…
  • Fabian Piau on FAQ – Online survey with Google Forms / Drive / DocsJe n'arrive pas à reproduire car si vous cliquez s…
  • Saint hilaire albert on FAQ – Online survey with Google Forms / Drive / Docsje vais tenter d'être plus précis : j'envoie un li…

Recent posts

  • Flagger – Monitor your Canary deployments with Grafana - 6 months and 3 weeks ago
  • Flagger – Canary deployments on Kubernetes - 8 months and 2 days ago
  • Flagger – Get Started with Istio and Kubernetes - 8 months and 2 weeks ago
  • Expedia CoderDojo in London - 1 year and 6 months ago
  • Volunteering at Devoxx4Kids - 1 year and 8 months ago
  • A Java 11 migration successful story - 2 years and 3 weeks ago
  • Tips to make your WordPress website secure - 2 years and 3 months ago
  • Devoxx UK 2018 – Day 2 - 2 years and 7 months ago
  • Devoxx UK 2018 – Day 1 - 2 years and 8 months ago
  • TransferWise, Revolut and Monzo, a small revolution for travelers and expats - 2 years and 11 months ago
  • Autocomplete for Git - 3 years and 8 months ago
  • Swagger, the automated API documentation - 3 years and 10 months ago
  • Microservices architecture – Best practices - 4 years and 3 months ago
  • FAQ – Online survey with Google Forms / Drive / Docs - 4 years and 8 months ago
  • QCon London 2016 – Project Jigsaw in JDK 9 – Modularity comes to Java - 4 years and 9 months ago
Buy me a coffee

Language

  • Français
  • English

Follow me!

Follow me on Linkedin
Follow me on Twitter
Follow me on Stackoverflow
Follow me on Github
Follow me on Rss
Link to my Contact

Email subscription

Enter your email address to receive notifications of new posts.

Tags

.net agility android bash best practices blog cache cloud computing conference continuous integration css developer devoxx docker docs drive eclipse extreme programming firefox flagger forms google helm hibernate istio java job jug kubernetes london mobile computing overview performance plugin programmer qcon script sharing society spring tool ubuntu windows wordpress

Links

  • Blog Ippon Technologies
  • Blog Publicis Sapient
  • Blog Zenika
  • Classpert
  • CommitStrip
  • Coursera
  • Le Touilleur Express
  • Les Cast Codeurs Podcast
  • OCTO talks !
  • The Twelve-Factor App

Categories

  • Event (15)
  • Linux (3)
  • Management (7)
  • Agile programming (29)
  • Technology (44)

Archives

  • June 2020 (1)
  • May 2020 (2)
  • July 2019 (1)
  • May 2019 (1)
  • December 2018 (1)
  • October 2018 (1)
  • June 2018 (1)
  • May 2018 (1)
  • January 2018 (1)
  • May 2017 (1)
  • March 2017 (1)
  • October 2016 (1)
  • April 2016 (2)
  • March 2016 (1)
  • November 2015 (1)
  • May 2015 (1)
  • February 2015 (1)
  • December 2014 (1)
  • November 2014 (1)
  • September 2014 (2)
  • August 2014 (1)
  • July 2014 (2)
  • June 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (1)
  • November 2013 (1)
  • October 2013 (3)
  • September 2013 (5)
  • July 2013 (1)
  • June 2013 (1)
  • May 2013 (1)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (1)
  • January 2013 (2)
  • December 2012 (2)
  • October 2012 (1)
  • September 2012 (1)
  • July 2012 (1)
  • May 2012 (1)
  • April 2012 (1)
  • March 2012 (1)
  • February 2012 (1)
  • January 2012 (2)
  • December 2011 (1)
  • November 2011 (2)
  • October 2011 (2)
  • September 2011 (1)
  • July 2011 (1)
  • June 2011 (2)
  • April 2011 (1)
  • March 2011 (1)
  • February 2011 (1)
  • January 2011 (2)
  • November 2010 (2)
  • September 2010 (1)
  • August 2010 (1)
  • July 2010 (1)
  • June 2010 (1)
  • May 2010 (1)
  • April 2010 (1)
  • March 2010 (1)
  • February 2010 (1)
  • December 2009 (1)
  • November 2009 (1)
  • October 2009 (2)
  • September 2009 (2)
  • August 2009 (3)
  • July 2009 (1)
  • June 2009 (2)
Follow me on Twitter
Follow me on Linkedin
Follow me on Stackoverflow
Follow me on Rss
Link to my Contact
Follow me on Github
 
Fabian Piau | © 2009 - 2021
All Rights Reserved | Top ↑