WordPress Security
ULTIMATE WORDPRESS SECURITY
The complete guide to securing your website against online attack
Introduction��������������������������������������������������������������������������������������� 06
Principles of Security������������������������������������������������������������������������ 15
Backups�������������������������������������������������������������������������������������������� 77
Patching������������������������������������������������������������������������������������������� 93
Logging������������������������������������������������������������������������������������������� 136
Conclusion�������������������������������������������������������������������������������������� 140
Since its release in 2003, WordPress has become the leading platform
for building and developing a website. It powers over forty percent
of all websites on the internet, and over 500 new WordPress sites
come online each day. WooCommerce, a popular ecommerce plugin,
is used in over thirty percent of all online shops, processing millions of
sales each year.
A 2013 study found that 30,000 websites get hacked every day, and
given the growth in the number of websites since then, this figure has
surely grown substantially. The public internet can be a battleground,
and putting your website out there means exposing it to a consistent
level of scanning, probing and attacking. And while hundreds of
thousands of WordPress sites do get hacked every year, the reasons
for the attacks are quite consistent, predictable, and preventable.
If you are a website owner, the framework within this book will help
you ask better questions about the security of your site and have an
informed conversation with your website developer about how it is
being managed. If you are a web developer, this book will provide
more information on how to correctly secure your clients’ websites
and implement proactive solutions for your clients, rather than having
to deal with the aftermath of a website breach. While the cost of a
cleaning up after a website breach can vary greatly, an average figure
of $57,000 appears to be quoted often, and this is only set to increase.
07
As you begin to learn more about securing your site, you will find
the same principles can be applied to other areas of IT within your
business or home. Backups, patching, strong passwords, and limiting
user permissions, for example, apply equally well to other computer
systems. I would encourage you to explore where else you can apply
this knowledge too.
08
Knowing
Your Enemy
If you know the enemy and know yourself, you need not fear the result
of a hundred battles.
If you know yourself but not the enemy, for every victory gained you
will also suffer a defeat.
If you know neither the enemy nor yourself, you will succumb in every
battle.
—Sun Tzu, The Art of War
Let’s take a look at who we are defending ourselves against, why they
are attacking, and answer the question of why me?
Putting your website out onto the internet means exposing it to the
ongoing drone of attack activity that is part of the background noise
of the internet. This year, hundreds of thousands of websites will have
09
someone successfully break in and attack their site. For the companies
that remove malware infections and restore hacked websites, three
quarters of the time they find it was a WordPress site which was
involved. Does this mean then that WordPress itself is insecure?
What makes WordPress so popular is not only its cost (free), but its
ease of use overall. It provides a way for non-technical users to quickly
set up an attractive, powerful, and fully functioning website using
clickable menu options and drag and drop features.
But these features among users are also what makes WordPress such
a focused target for attackers. Criminals go where the crowds are, as it
increases their chances of success. Also, the very fact that WordPress
is so easy to use means you often have inexperienced administrators
running sites without realising what is required to manage and maintain
them on an ongoing basis, especially when it comes to online security.
Depending on the industry you are in, businesses have been known
to actively engage freelance computer programmers to attack the
websites of their competitors, and there are many services online
offering hackers-for-hire. These are very targeted types of attack, and
thankfully most companies treat computer security as a non-competitive
11
space. Most companies feel there are more than enough attackers
to go around already, but it should not be ruled out—particularly in
industries such as gambling.
Whether the attackers you face are groups or individuals, the vast
majority of attacks on your website will come from automated scripts
or programs which scan the internet for websites they can break into.
These automated scripts run twenty-four hours a day, seven days a
week, and allow the person who runs the script to ramp up the number
of sites they can attack to a massive scale. This attacker also needs
not to get involved personally until they have a successful hit on a
website.
12
Once someone has access to your website, what do
they do with it?
y SEO Spam – Attackers flood your posts and pages with hidden text
and links in order to boost SEO ranking for the other sites. As an
SEO tactic, Google and the search engines are aware of this and
are able to ignore it for ranking purposes, but will instead mark your
site as being infected and post a red warning page when someone
tries to go to your site from a Google search result.
y Ads – An attacker may infect your site with ads that will pop up as
your visitors browse your site. Again, these are usually related to
drugs, adult material, or gambling.
y Warning pages – When someone tries to visit your site from Google
or other search engines, if they don’t put up a warning page, search
engines may drop your site from ranking in search results.
y Brand reputation damage – Visitors get the perception that you are
promoting adult or gambling sites, or that you are not serious about
security. It is embarrassing to be informed that your site infected
someone’s computer with malware, as they hold you responsible
for it. Security is a big trust factor for websites these days; so if
people perceive that you are not serious about it, it affects their
opinion of your brand.
y Lost time – Suffering a hack costs you more than money. You
have to divert your focus into cleaning up the site, hiring security
professionals or website developers, dealing with hosting providers,
moving your site if necessary, and so on. This all involves taking
time and energy away from what is most important, such as selling
your products or creating content to spread your message.
Why Me:
The question often arises: ‘Why would someone attack me? I only run
a small online shop or blog’. In reality, any website is of interest to an
attacker and attacks are almost never personal. The vast majority of
them are opportunistic, and done via an automated script or program
searching the internet for websites it can break into and infect.
No matter how big or small your organisation is, attackers don’t care
about your site specifically. If they can exploit it to spread malware,
attack your audience, make a statement, or make a financial gain for
themselves, then thats what they are interested in. If you are running
an online shop, you will be targeted. It only takes a few days for a newly
registered site to begin receiving attack traffic, so early, proactive steps
are vital to protect yourself.
15
Principles of
Security
Risk
Note that while we aim to reduce the risk to your site as much as is
possible, you cannot ever totally eliminate it. That is to say you can
never truly be 100% secure. There is always the possibility that an
attacker will come up with a new, clever attack tomorrow that no one
has thought of before and use it against your site. There is always a
risk to your site, even if it’s one that you never would have considered.
What would happen if tomorrow your web hosting company suddenly
17
went bust and turned off all of their servers? It may not be an attack in
the traditional sense, but it would bring your site offline and certainly
would have an impact on you. Are you prepared for it?
So, your goal here is risk reduction, not risk elimination. The more
security you apply, the greater it costs you. This would involve 100%
uptime, hosting your website on multiple servers distributed across
the globe using massive bandwidth connections for DDoS protection
against the largest traffic floods, going back to college to learn to
code so you can personally review plugins to ensure there are no
vulnerabilities, etc. So rather than eliminating risks, you manage them
in choosing a respectable and responsible host, configuring your site
appropriately, and putting sufficient measures in place like backups
and rapid or scheduled patching to achieve a cost-effective level of
security.
Attack surface
It is often stated that all software contains bugs, though that is not
to say that all of those bugs make the software vulnerable to attack.
Where a vulnerability is discovered, developers often try to get a patch
out as soon as possible, but sometimes they only become aware of a
vulnerability once attackers have exploited it to break into websites. In
such cases, there will always be some victims, and the update is then
about containing and limiting the extent of the problem.
So, even regular patching may not protect you. But if that piece of
software or plugin isn’t installed on your site, you were never exposed
to the risk in the first place.
Your aim should be to reduce the plugins you use to just those that
you need and no more. A recent study of 50,000 websites found that,
on average, there were twenty-three plugins installed per site. If you
have a lot of advanced features on your site, you could expect to need
and use over fifty plugins. The very popular wpbeginner.com site uses
sixty-two active plugins. It is also important to be aware that more
plugins means more troubleshooting if something odd starts to happen
on your site, and you will have to disable and selectively enable them
one by one to locate the source of the problem.
But your first and primary concern is to get your site working the way
you want it to. It is important that security does not dictate what you
can accomplish with the site, but rather enables and supports your
endeavours in a way that reduces your risk of attack. If you need fifty
plugins or more to get the full features out of your site, then that is what
is needed. The next question should be: ‘How do we do it securely?’
19
Defence in Depth
Consider the example mentioned above, where your web host suddenly
turns off all of their web servers. That’s okay, you have backups. Oops,
the backups were on the same server. That’s okay, you also have them
stored in your Google Drive.
The final point to make is that security never ends. There are some
aspects where once you set your site up, you can forget about it—but
security is not one of those. Your site needs ongoing maintenance and
updates to ensure that it stays fully patched, backups are being taken
and tested, etc.
Throughout the book, I mention particular plugins and the role they
perform in securing your website. There are many plugins to choose
from in the WordPress ecosystem performing similar roles. The ones I
mention happen to be the ones I use on my sites and am familiar with,
but you may have different preferences. There are no affiliate links
used, nor do I earn a commission if you choose to use the plugins
mentioned in this book.
A friend of mine runs a successful online health and wellness store, and
received an email from someone claiming to have found a vulnerability
on his site. There was a lot of technical detail in the email, including
mentions of customer details being hijacked, passwords being stolen,
tricking users into entering their details in the wrong places, and so on.
Quite scary stuff on the face of it!
My friend didn’t know quite what to make of it, or do with it, and so he
did what most of us would do—he ignored it. Life is a busy place at the
best of times. And then came the follow up mail: ‘Is there any update
about my bounty for finding this bug?’
As more digital products have come into our lives over the past few
years and our lifestyles have become more reliant on online services,
finding security bugs in them before the bad guys do has become quite
a priority. And given the complexity and severity of some of these bugs
and vulnerabilities, the companies making these products and services
don’t always have the time or resources to find them.
Bug bounties are where the companies ask security researchers and
programmers to test out and hack into their product to find ways to
break it, with the offer of cash payments once they find and responsibly
disclose details of the bug to the company. Originally, tech companies
looked with disdain on people who notified them of serious security
products in their products. Apple was notorious for not responding when
notified of serious bugs and flaws in their products, and sometimes
even threatened researchers with legal action for not using the product
in strictly the way it was intended. After all, it meant work for them to
have to go in and fix these problems, which used up time and money.
They also potentially faced bad publicity if word got out about these
issues. And finally, fixing existing products distracted from getting the
next product out the door to paying consumers.
23
Eventually, with the explosion of online services and the embarrassment
from security researchers organising conferences to discuss and
publicise their findings, the big tech companies began to put in place
programs where researchers could disclose what they have found
quietly. In return, the company would commit to fixing it within a given
timeframe and reward them by paying them for their effort.
This has become quite a lucrative source of income for some especially
skilled hackers, but has also had the added effect of security researchers
looking elsewhere to see who can pay them for finding problems with
their sites or online services. There is a whole microcosm of less-
skilled hackers scanning the internet and websites now for problems
or vulnerabilities, and then seeking payment in return for details of
what they find.
This often comes with an implicit threat—if you don’t pay me for what
I have found, wouldn’t it be terrible if someone were to use it to bring
down your site?
At the same time, there are many security researchers who actively
seek out vulnerabilities and disclose these bugs discreetly to service
owners so they can be fixed. They believe in the openness and
community nature of the internet, and that helping to secure it benefits
everyone. One of the most active groups is the Dutch Institute for
Vulnerability Disclosure (https://www.divd.nl/), which has over 5,500
responsible disclosures to their name.
When Donald Trump was running for President of the US, they
discovered that his details were part of a database of LinkedIn user
accounts which had been stolen four years before, and released publicly
in 2016. They found that his LinkedIn password (yourefired) was also
being used for his Twitter account (note: password reuse), and set
about documenting and quietly reporting this to the US Government
authorities, as social media was a major part of his campaign efforts.
24
If you have an online presence and are contacted by someone claiming
to have found a flaw or vulnerability on your site, there is an established
process which is accepted as standard, and which puts you in control
of how to respond:
1. You ask the contact to provide full details of what it is they have
found without disclosing it publicly or to anyone else; called
responsible disclosure. You can’t move forward unless you know
what the problem is, and maybe the ‘data leak’ they have found is
the free PDF you are giving away to customers who sign up to your
email list.
Remember that all software will have bugs. All websites are
and will be at risk of some sort of attack. It comes down to the
security mechanisms you have put in place to account for these
(remember: defence in depth). In my friend’s case, what was
found was a feature all online stores would be exposed to, but
it would take a lot of work to exploit, and wouldn’t result in the
immediate access to customer details as was described in the
initial email.
25
You also have to judge the tone of the email. Was there an implicit
threat if you didn’t pay up, or was it done out of a genuine desire to
help? Remember, the power equation is all on your side, so these guys
are doing it without a guarantee of a payday, but what you get in return
is a more secure online presence.
If you are going to pay, base it on the seriousness of the problem and
what it would mean to you if someone were to exploit it (remember:
likelihood and impact).
Contact Information
Security concerns aren’t going away, and the more we come to rely on
the internet for our businesses and online lives, the more important it is
that we accept that vulnerabilities in our systems may well be present
and discovered. You need to make it easy for security researchers
to contact you and have a plan for accepting and reviewing such
notifications. The quicker you are able to respond to such emails, the
quicker you will be able to secure your website.
27
Add a section to your site explaining how you can be contacted for
security concerns
Have a process for verifying the risks of what they have reported
with a trusted technical source
In March 2016, John Podesta was busy working away on the electoral
campaign for US presidential hopeful Hillary Clinton when an email
popped up in his Gmail inbox. The mail, appearing to come from
Google, reported it had blocked someone from the Ukraine from
logging into his account. Google is smart enough to know that, even
if the correct password is used, a new login from a location or country
you have never logged in from before probably means trouble, so they
often ask you to verify this new location first. Podesta was curious and
asked his IT team to take a look.
The campaign team replied saying that the mail looked legitimate and
recommended Podesta change his Google password—standard and
good advice, seeing as it looked like someone actually had his Google
password. Although the IT team sent him a link to reset his password
in their email, Podesta instead used the link which was in the original
email and set up a new password in the page that it brought him to.
It turned out that the email had not come from Google to begin with,
but from a team of Russia-based attackers. When Podesta set up a
new Gmail password, he did it through a copycat site the attackers
had set up, so they now also knew what his password was. What
followed was a seven-month period in which the attackers had access
to thousands of emails in Podesta’s Gmail account, which were then
released publicly in order to influence the outcome of the 2016 US
Presidential elections.
The following year, in the French Presidential election, the same thing
happened. The contents of Gmail mailboxes from five individuals
29
close to the Presidential candidate Emmanuel Macron were released
publicly in hopes of swaying the public vote.
What happened to each of these individuals was that they had fallen
foul of phishing emails, where legitimate-looking emails are sent to
people, instructing them to do something urgent and take some action
using a link provided in the email or a file attached to the mail. In the
cases above, the link brought the users to a page that looked very
similar to Google’s password reset page, but which was in fact set up
by the attacker; and thus they were able to see the new passwords
being entered.
While these stories are of very high profile people, the truth is that
this sort of attack happens every day to thousands of people across
the world. Phishing emails are still one of the most effective ways
of attacking an individual or organisation as they talk directly to the
person sitting behind the screen and the words can directly influence
you to do something. The phrasing of the email is used to gain your
trust, raise your curiosity, or exploit your fears of something negative
happening, ultimately leading to you clicking on the link or opening the
attached file.
What they are hoping to get are your bank details, and many people
and companies have had their accounts emptied as a result of this.
But if attackers can make money from breaking into your website as
well, then that’s what they will do. People have found their ecommerce
payments being redirected to different bank accounts, viruses being
30
planted to infect visitors to their site, or their website being used to
send spam emails; all as a result of losing control of their passwords.
Sometimes, the attacker may choose to deface your website, redirect
traffic to competitor websites, or simply delete the whole thing—just
because they can.
Attackers also know that people are typically lazy when it comes
to passwords, and use the same password across many different
accounts. So if they know the password you use for your website,
there is a good chance you use the same password for your social
media accounts, other online accounts, and maybe even your bank.
Known as Credential Stuffing, they then use automated programs to
try your account details to log in to numerous other online services,
and if you share passwords between your grocery shopping site and
your Facebook account, then they can take control of these from you.
• Do you know the sender? Many phishing emails are sprayed out
into peoples’ mailboxes in the hope that someone will click, and
typically a small percentage do. Be suspicious of mails coming
from people or companies you do not know or trust.
Many malicious attachments try and exploit out of date software on your
computer, so you need to look at what is installed on your computer.
Renowned security journalist Brian Krebs (https://krebsonsecurity.
com/) has three basic rules for limiting the majority of computer security
threats:
1. If you didn’t go looking for it, don’t install it – Only install something
that you went looking for in the first place. Don’t install anything
using the links provided by an email or website. If a site or email
says you need Java, Adobe, or any other program, use Google to
search for that program yourself and install it. Many attacks have
begun through a fake website or email convincing the user to click
a link to install malicious software.
When you are finished working on your website, writing a new post, or
updating the product listing, it can be convenient to simply close down
the window and go off about your day. Very often though, this does not
log you out of your website. This can be convenient, as you don’t have
to enter your password in order to log in next time you want to update
the site, but as is often the case, convenience and security are the two
factors that need to be weighed up against one another.
Make it a habit to log out of your website once you are finished updating
or editing it. If there is a chance for anyone else to use your computer,
they would have access to your website simply by going directly to the
login page. This can be a nuisance if you know the person, i.e. a family
member, or make a bad situation worse if you don’t, i.e. in the case of a
virus infection where an attacker has remote access to your computer.
Secondly, password managers make remembering long, strong
passwords and easy to use. Once you go to your login page, the
password manager will enter your login details and log you in; no
typing needed from you. Set it up so that the password manager logs
out of your account after a short time period, and when you close the
browser, so other people do not have access to this also.
For personal and home computers, there are many free and paid
solutions. The free versions work excellently for scanning and detecting
known viruses on your machine, with additional features being offered
in the paid versions. If you’re looking for free AV software, check out
Avast or AVG, two established and well respected products.
Windows 10 does come with its own built-in anti-virus program call
Windows Defender. It is highly rated and what I use. There aren’t
many options to configure in it though, and the interface isn’t the most
attractive, but it is effective and runs by default if you have no other AV
product installed. Being Microsoft’s own product, it works well with the
operating system, has limited impact on system performance and gets
regular virus updates.
If you would like guidance or help with securing the laptops and
computers in your home or business, feel free to go to https://
dermotdowney.com/index.php/call to book a free, no obligation 15
minute call. We can go over where you are at currently, what you are
looking to achieve, and what the next steps are to take.
35
End of Chapter Checklist:
If you are using a shared laptop, have separate accounts for each
user and password protect them. Give your users reduced privileges
and have a separate, password protected, Admin account for
installing software
36
Server Side
Security
Luca runs an online shop selling woollen and printed silk scarves she
makes personally. She ran her store for a few years before her website
suffered its first malware infection. She found out after a customer
emailed to say they got a warning that ‘This site may harm your
computer’ when they visited her site. While it did not stop them from
browsing that time, it left enough of an impression for them to email
her to bring it to her attention.
Luca knew she had to act. She found a freelance expert online to clean
it up, and they notified her that there indeed was a malware script on
her site, which they then removed. They also submitted the site to
Google to remove the warning message. Job done, or so she thought.
A week later, Luca received an email on her phone from her web host
notifying her that malware had been detected on her site and they
were suspending her account. It was actually the second email they
had sent; she missed the first one a few days prior. This was again
disastrous news for her ecommerce store. If customers couldn’t get
to her store, they would go elsewhere, as there was no shortage of
options for customers looking for printed scarves online.
She got back in touch with the security expert she had dealt with, who
again found and removed the infection, and she notified her hosting
company requesting they release the suspension on her account.
Shortly afterwards, she got another email that her site might be hosting
malware, and she realised something major needed to be done. The
security expert had mentioned that, given the security precautions he
had taken on the first occasion, repeat infections may indicate that the
problem lies with her hosting account.
Luca had not been overly happy with the level of service from her
web host for the while, but it had never been a big enough of a pain to
37
justify the hassle of moving from them. There were just too many other
things demanding her time and attention in running her business. Now
though, she had had enough, and this was the perfect reason to make
the move she had been wanting to make.
It has been a number of months now since her last website infection,
and she has been able to get back to focusing on her online store
and providing custom scarves to customers. She feels confident that,
whatever the root cause was, changing her host certainly was a big
contributor to solving the problem.
It is clear that the quality of your hosting provider has a large impact on
the overall security of your site. In situations where your site is being
run from a server which also hosts a number of other sites, unless
your web host has set it up correctly, then your security is only as good
as the security of the other sites. In fact, your security is only as good
as the security of the poorest site, and you don’t know who that is nor
have any control over them.
An infection on one site can spread to all other sites on that server, and
even if you clean up your site, it will quickly get reinfected. Let’s take
a look at the different models of hosting and the security implications
of each.
38
Shared hosting is a very common option for hosting a website. Your
web host puts your website onto a server with many other websites
and you all share the resources and power of that server. It is similar
to renting a room in a large house. You have your room for putting up
your stuff in, but you share the main facilities—kitchens, bathrooms,
water, etc—with many other tenants.
With shared hosting, your web host is trying to get as many websites
running on the one server as they can. If one website requires a lot
of power for it to run, then this comes at the expense of all the other
websites on the same server, who may end up running slower as a
result.
Many sites and blogs start out on shared hosting until they find they
need to migrate up to a more powerful or managed platform as their
requirements or audience grows.
The last hosting model is to rent a dedicated server. With this, you are
renting a full server for your own, private dedicated use. This is the
most expensive of the three options, and requires that you have the
skills and ability to manage and secure a server environment. This is
often used when a website or application needs the power of a whole
server for its own usage. If you are using this, you have a website or
app that is power hungry and generating enough revenue to justify the
cost.
40
With each of these options (shared hosting, VPS, and dedicated
server), there is also the option of having it unmanaged or managed.
Unmanaged means you are responsible for setting things up and
maintaining them yourself, such as patching, upgrades, backups, etc.
A managed solution means someone from the web host company
takes care of this for you, which can add to the cost, but allows you to
focus on maintaining your site without worrying about the underlying
technical aspects.
Database
The database is where all of the data and content for your WordPress
website is stored. When a visitor comes to your site and opens a
page, WordPress quickly searches the database, extracts the text and
content needed, and presents it to the visitor in the format and layout
you have set up for your pages.
The data is stored in what are known as ‘tables’ in the database, and
42
the most common type of attack—known as SQL Injection—is where
a visitor sends a command to the database through either the URL
address bar of your site or a form in your website. What makes an
attacker’s job much easier is if they know the names of the tables in
the database.
Wordpress uses standard names for all of its database tables. If you
haven’t changed the name, then an attacker already knows what your
database table names are called. A simple way to protect against this
is to change the names slightly by changing the prefix—the series of
letters at the start of the database names.
Before you make this change, take a backup of your site in case
something goes wrong. If your database gets broken, you will not be
able to access your site afterwards.
There are many plugins which will allow you to do this, but I am going
to use iThemes (https://wordpress.org/plugins/better-wp-security/)
here, as it is a popular security plugin with a lot of other features we
will be covering in this book.
Back in the Change Database Table Prefix module, simply the drop
down menu to Yes and click Save Settings. iThemes will now run
through your database and change the table names and update the
Wordpress files so it knows how to access the data again now.
This is a simple task to do, and changing it once in the lifetime of your
website it will be enough.
File Permissions
File permissions control who can read or write to files on your server,
and whether they can run any scripts or programs in a particular folder.
It is an important part of allowing users or programs on a server just
enough permission to do what they need to do, but no more.
Having the permissions set correctly can prevent attackers from running
scripts and programs if they manage to upload them to your site, and
in a shared hosting environment, is also a step towards limiting the
damage an infection on another site can do to you.
File and folder permissions are shown using a three digit number,
representing what the users on the server can do, i.e. read files,
write to files, and/or run scripts and programs from that folder. We
are not going to get into the details of understanding of the numbers
specifically, but where the values match the Suggestions, they are
44
marked in green, so those are okay. If your settings differ then those
are marked as a Warning and it is recommended you change them to
match the suggestions.
I need to correct the permissions of my wp-config and .htaccess files to match the
suggested values
45
1. Changing file permissions on the server is done from your hosting
account. Log in, find the File Manager, and click into it.
In the cPanel web hosting program, click to access the file manager
2. Using the directory structure, navigate to the file or folder you wish
to modify, right click on it, and select Change Permissions. (Some
file manager programs may call this CHMOD in the right click menu,
but it is the same thing.)
Use the left hand menu to navigate to the folder containing the file to be modified; in
this case it is in the main web directory, public_html
The permissions of this wp-config file are set to 666, allowing all users on the server
to read and write to, i.e. change, this file
46
3. Tick or untick the boxes until you get the correct numerical value as
suggested by the iThemes plugin. Then click Change Permissions
or OK to save.
That’s all that is needed. The permissions are now updated and you can
verify this by going back to iThemes and reloading the file permissions
module.
PHP version
PHP is code that runs on your web server, and if there are any bugs
or security vulnerabilities within PHP, these can be exploited by an
attacker to undermine the security of your server. An attacker can use
a bug within the version of PHP you are using to upload and run code
of their own, and thus take over your server, attack your database, or
traverse (browse around) the files and folders behind your site and view
content you hadn’t intended to make visible or had stored in protected
areas of your site, such as a password protected video course.
The versions of PHP that Wordpress is being run on, courtesy of https://wordpress.
org/about/stats/
48
PHP Version Security Support Until
7.3 06-Dec-2021
7.4 28-Nov-2022
8 26-Nov-2023
Given all of this, you might be wondering why people don’t upgrade
their PHP software sooner? Part of the reason is that people don’t know
about it, or perhaps don’t realise how important it is. Website owners
who are familiar with patching usually focus solely on keeping their
website patched, but neglect to maintain the server software which
the site runs on. There is also a sense of caution over fear of ‘breaking
something’. We will discuss this further in the chapter on Patching, but
you then need to plan for it rather than using it as a reason to ignore
patching altogether.
2. At the top of the Site Health page are two options, Status and
Info. Click on Info.
This means having a thorough and written-out test plan so you can
test out every feature of your site, and taking a full backup of your site
before doing any upgrade. You should pay particular attention to the
plugins on your site, and test their functionality.
50
To avoid doing so on your live site, it is a good idea to test on a staging
site first. Your staging site has to be on a different server though. In
the chapter on Backup and Recovery, we will discuss setting up a
temporary site using UpdraftClone. This allows you to choose the
version of PHP on your temporary site so you can safely test the
behaviour of your site without affecting your live site.
If there are any problems, you can investigate them, look up solutions,
or contact developers or support teams and work on getting them fixed.
Once you are ready, you can then go back to your live site, upgrade
your PHP, and make any changes you need to resolve any problems
you discovered in testing.
2. Log into your hosting account, and find and click into MultiPHP
Manager.
3. Tick the checkbox beside the domain name you want to upgrade,
and from the menu on the right hand side choose an upgraded
version of PHP
51
Use iThemes to set your site file and folder permissions correctly
Know what version of PHP your site is on and when security support
for it ends
It didn’t take long before eager PhD students figured out ways to
steal the list of passwords to extend their time on the system, and
thus began the game of cat-and-mouse that has been played ever
since. Someone tries to break into a system by guessing or attacking
the login system, prompting the defenders to take extra measures to
prevent this.
Let’s take a look at the attacks on the password of your website, and
what you can do protect against them.
The single action you can take which will have the greatest impact
on your websites security is to choose a good, strong password. No
security measure exists in isolation, so doing this and nothing else is
not good security. But getting into the habit of using strong, unique
passwords is the most impactful step you can take to protect yourself
online.
Every year, security firms review the lists of hacked accounts and
password lists being sold on the internet to analyse the passwords
people are using, and the same patterns tend to show up repeatedly.
Below are the top thirty passwords in use in 2020. It is estimated that
one out of fifty people are using at least one of these to protect a
sensitive account, such as a website, social media account, or work
related account; it is not hard to see why hackers get such value from
these lists.
55
1. 123456 11. 1234567 21. 123
The rules for making a strong password have been with us for some
time now, and they are still very relevant:
Of all the rules, the one about length should be given the most
consideration. It is often said that a long password is a strong password.
The main reason is that a long password is more resistant to cracking
attempts, but it also allows you to build in the other required characters
in a way that makes sense and you can possibly remember. Also
56
known as a passphrase, a long password should consist of at least four
words, and can consist of song or poem lyrics, positive affirmations, or
sentences that mean something personal to you:
• WilliamShakespeare(1564-1616)
• I’dlike2teachtheWorld2Sing
• 2021-IamNOTasmoker!!
• Correct-Horse-Battery-staple
Password Reuse
• Make it long.
• Make it complex.
• Make it unique for every service and website you log in to.
The best kind of password is one that you could never remember,
something like:
• \?s~7XuGU&2sQn#x
• 4QptwNeEZD@Pk1We&a
• #kjqfbu24IQ*kkg1CZd=(JD&U3m.v30”
Password managers are a service that generate and store long, strong,
and unique passwords for you for each service you need. Passwords
are stored in a vault, which you access through a master password,
which is the only long, strong, and unique password you must
remember. With password managers, you get the security of using
extremely strong and unique passwords without having to remember
them.
There are also offline password managers which do not send your
information up to the cloud. Keepass (https://keepass.info) is a very
well-regarded password manager which saves your passwords in an
encrypted file on your own computer, so you always have control over
where your vault is. There are some convenient features, such as
automatic website logins, which Keepass is unable to offer. And using
it between different computers is a little more challenging, as you would
have to move your encrypted vault between the computers, probably
by emailing it to yourself. Keepass also does not offer a version for
mobile devices.
It is a good idea to print off a set of one time login codes and store
them somewhere safe. Don’t have any other information on the page,
so if someone finds it there is nothing telling them what the codes are
for.
The ‘factors’ in the name describes the ways in which you can
authenticate, or identify, yourself. One way of identifying yourself is
through something you know. If you know the password to log on to
your website, then your website assumes the person logging on is you.
The second way is through something you have, such as your phone.
If you can prove that you have your phone in your possession by
providing the code number from it, then your website is happy to let
you in.
If you have ever drawn money from an ATM machine, then you are
already familiar with how two factor authentication works. In order to
get the money from your account, you have to authenticate yourself to
your bank. You do this through using your bank card. But having the
card itself isn’t enough, as a card can get stolen, so you also have to
know the PIN number to use with it. Thus you are using two factors,
or methods, of authenticating yourself in order to access your money.
1. Download and install a 2FA app to your smartphone. There are many
apps available in the App Store (iPhone) or Play Store (Android),
but I would recommend the Authy app, as it allows you to back up
your accounts in case your phone gets lost or dies. Their website
(https://authy.com/) also has some great guides on explaining 2FA
and how to set it up for many different types of service.
3. Go into the WordPress Users menu and click into each user account
for which you want to set up two factor authentication.
5. Using the 2FA app on your phone, scan the QR code or enter the
code into the Authentication Code box and click Verify.
63
Your phone and website are now synchronised in terms of the codes
which will be accepted. To test it, log out of your website and back in
again. After entering your username and password, you should see a
screen asking you for an Authentication Code. Enter the six-digit code
from your phone to log in.
Two factor authentication offers strong protection for your site’s login,
but if the setup feels confusing, feel free to go to https://dermotdowney.
com/index.php/call to ask for help. We can arrange a screen sharing
session where you are guided through the process and come away
comfortable with how it all works.
64
Password Expiry
There has been debate around this practice for some time, as attackers
do not steal and then sit on a password for ninety days or more unless
it was part of a huge database of stolen accounts; and then only
because they have been busy attacking all other accounts before they
got around to yours. If someone successfully steals your password,
and especially if they have been specifically targeting you, they would
look to use it as soon as possible. If they got your website password,
one of the first things they would do is log in and create a new user
for themselves so they have guaranteed persistent access to guard
against you changing your password.
A very useful feature to protect your site is to hide the login page URL.
By default, WordPress uses wp-admin as the page to login to the admin
dashboard. By changing this to something else, you dramatically cut
down on the number of login attempts being made to your site. An
65
example would be to change:
https://your-website-name.com/wp-admin ---> https://your-website-
name.com/knockknock
Known as security through obscurity, you are not actually securing your
site, just hiding a feature. It is similar to hiding a tab on a spreadsheet
containing your passwords and sending it to your work colleagues, or
hiding the key to your front door under the mat. You are relying more
on secrecy than on true security practices, and once an attacker learns
about the secret, you are back to the original problem. But it is a useful
and effective tactic at cutting down on the numbers of automated bots
which are attempting to log in to your site, and so greatly reduces the
noise that will appear in your logs.
2. Along the top of the screen, click Advanced, and click into the tile
called Hide Backend.
3. Click the option to enable the ‘hide backend’ feature and enter the
new page name to be used for your login page.
Having changed the login URL for your website, what happens if an
automated bot still manages to find it and launch their login attempts, or
if someone else is trying repeatedly to get into your account? iThemes
has a great feature that limits the number of trial-and-error attempts
they can make before blocking a user for a period of time.
This will identify anyone who makes 3 wrong login password guesses
in a 7 day period, and block them from trying again for 15 minutes,
and massively slows down their efforts to break in. You can change
these settings to different values if you prefer, but you should notice a
significant drop in the login attempts being made on your website.
If you are allowing new users to sign up to your site, iThemes offers
you the opportunity to force them to use passwords which have not
appeared in previous password breaches through partnering with Troy
Hunt’s Have I Been Pwned (https://haveibeenpwned.com/) service.
This will take the first few characters of the scrambled password and
check if it appears in Troy’s online database of 613 Million passwords
(at the time of writing, and growing!), which have been stolen from
previous attacks on websites and services. If it appears in the database,
your site will ask the new user to choose another one.
These are password lists which are publicly available on the internet
for other attackers to use against your website. Using just the most
common 1 million passwords, an attacker’s success rate is over thirty
six percent, and with the most common ten million passwords, they
have a fifty four percent chance of success. Forcing your users to use
68
a unique password means they will not be vulnerable to this password
reuse attack.
The recommended advice is, unless you know that you need it, you
should disable this.
Your login page is the front door of your site, and it makes sense
to secure this as much as you can, as it gets a lot of attention from
unwanted visitors. Using these steps, you will have gone a long way
toward preventing these visitors from getting in and causing havoc on
your site.
70
End of Chapter Checklist:
Taking a backup of your site before doing any work is definitely good
advice, and we cover how to do this in the chapter on Backups. But if
you want to test out a new design change, plugin feature, or update the
site, it is a best practice to do so on a copy of your site, rather than on
the live, customer facing one.
Known as a staging site, this allows you to test out anything you need
to do without it negatively impacting your main production site.
You can install plugins, change designs, update, and patch as much
as you want with the assurance that none of this is affecting the site
your business relies on. Once you have completed your testing on
your staging site and are confident about the results, you can then go
back to your live site and replicate the steps there.
I am only using 6.47% of my available storage, plenty of room for a staging site!
Many hosting providers allow you the option to create a staging site
from within your hosting account. Log in to your control panel and see
if the option exists.
4. From your hosting web panel, install WordPress on your new sub-
domain.
6. Go back to your original site and install a plugin which will allow
you to migrate your site, such as Duplicator (https://wordpress.
org/plugins/duplicator/). You can also migrate your site using
74
UpdraftClone, as we will cover in the chapter on Backups
8. Your staging site should now be a copy of your main site, and ready
for you to start testing.
You are now ready to begin testing changes or upgrades to your site.
All of your data stays on your server, with nothing being sent to a
third party. WP Staging will also prevent search engines from indexing
the site and password protects it so visitors can’t accidentally stumble
upon it.
2. Click the WP Staging menu on the left and then Create New
Staging Site.
75
3. Enter a name for the new site and click Start Cloning.
Enter a name for your staging site and click Start Cloning
4. Once staging completes, click Open staging site and log in using
your username and password.
Staging sites created using this plugin are great for testing design
changes or plugin updates, except for PHP upgrades, as the staging
site uses the same version of PHP as your live site.
In the chapter on Patching, we will discuss how some sites are reluctant
to upgrade due to a fear of breaking the site. Along with taking a backup,
using a staging site is your way of testing the effect of upgrading your
plugins and themes upon your site.
Marty: Wait a minute, Doc. Are you telling me that you built a time
machine... out of a DeLorean?
Doc Brown: The way I see it, if you’re gonna build a time machine into
a car, why not do it with some style?
—Back to the Future, 1985
In 1998, two years into production of Toy Story 2, 150 people were
hard at work in the animation, lighting, and modelling departments of
Pixar. A team of systems administrators were tasked with maintaining
the computer systems on which the animators were creating the movie
characters, and one of their routine roles involved clearing out deleting
files which were no longer needed.
She jumped in her car and drove home to retrieve her computer,
wrapping it in pillows and blankets for the drive back. After a forty-five-
minute drive to the studio—at which time her little Volvo was effectively
worth about ninety-million dollars—they plugged in the computer,
downloaded everything, and set about restoring the file system on the
master computer.
Backups are essentially just copies of your site. For WordPress, this
involves copying both the files on your web server and the content of
the database.
Firstly, some web hosts only offer regular backups as part of their higher-
end services. Hosts often limit their role to looking after the servers
on which the websites run, but not the actual websites themselves. If
they do provide this service, then that’s great, but you need to know
this in advance so you don’t get caught in a situation where you need
backups and neither you nor your host has any.
When you run a backup, most plugins will store the copy on the same
server as your website, called a ‘local’ copy. This is convenient for
a speedy recovery, but dangerous from a security perspective, as it
80
means an attack on your web server could mean the loss of both your
website and all of its backups.
For this reason, another copy of the backup must always also be saved
remotely to a trusted cloud-based location like Dropbox, Google Drive,
or Amazon S3. This gives you insurance against an attack on your web
server and means you always have copies of your site to fall back to.
As they often say, two is one, and one is none...
A backup of your website still contains all of the customer and business
data in your live site, and so needs to be protected adequately.
Companies have had their data stolen not through attacks on their
live site, but through breaching their backup solution and stealing data
from there. Consider encrypting the backup, and ensure there is a
sufficiently long, strong password being used on the remote storage
account.
Each backup will use up space, particularly on your local web server,
so you would need to balance your backup frequency against the how
81
much storage space you have available to you with your host.
There are many good WordPress plugins with which you can take
backups of your website. We are going to cover one here: the very
popular UpdraftPlus. The free version offers regular backup scheduling
and copying the backups to a remote location, while the paid version
offers features such as backup encryption, copying to multiple remote
cloud locations, and automatically running backups before site updates
are installed.
Once installed and activated, you can get to your UpdraftPlus settings
via the Settings > UpdraftPlus Backups menu. The Backup/Migrate
tab allows you to run an immediate backup, which is useful to do
just before you begin making any changes to your site. All available
backups are also shown here, along with a Restore button to allow
you to quickly and easily restore your site back to that point in time.
Over on the Settings tab, you can set the schedule for your automated
backups and the remote location where your backups should be copied
to.
Though the option is there to have the backups sent by email, this
would not be a good solution due to the size of the files. I strongly
recommend using a cloud storage account, like Google Drive or
Dropbox, instead of emailing them to yourself.
Set your schedule, remote storage location and many other important settings
83
Set your files and database to be backed up on the same frequency,
and keep as many copies as you feel you will need. Take note that
these will use up space on your local server, so check how much space
your hosting provider has allowed so you don’t end up using it all up,
impacting your sites performance.
Further down the same page, in the Expert Settings section, there
are some further options—the most important of which is Automatic
Updates. Enable this so UpdraftPlus will be updated whenever an
update comes available. The Premium version also gives you the
option to encrypt your backups here.
If you ever need to use your backups to restore your live site, simply
go to the UpdraftPlus Backups plugin options and choose the date you
want to restore back to from the Existing Backups. Click Restore,
select all components (plugins, themes, etc), and click to continue.
Having and taking backups is only part of the backup process. In reality,
no one actually cares about backups. It is the ability to restore your data
that matters, so it is critical that you test your backups to ensure they
are not getting corrupted during the process. This avoids the problem
of finding out that your backups were not working for some reason
right when you need them the most, in the middle of some disaster.
Doing test restores gives you confidence in your ability to get your
critical data back when—not if—the need arises.
Let’s take a look at two methods for testing your restores using
UpdraftPlus; one where you do a test restore back to a temporary test
site you create on your own server, and the other using UpdraftPlus’s
servers in the cloud.
The first method involves creating a new staging site and uploading
your backups to it for testing. We cover staging sites in more detail in
another chapter, but essentially it is a copy of your site which is totally
separate to your main, live site, so you can make changes and test
new things—all without impacting or hurting your main site.
As this creates a copy of your whole site, it will use up storage space
on your server. Be sure you have enough free space by checking your
hosting account. If you do not have the space, use the second restore
method we describe below.
1. Backup files saved to Dropbox. Look for the files with a similar date.
2. Updraft splits backups into separate files for Database, Plugins, Themes, the
WordPress Uploads folder and Other website files
5. Drag your backup files into the box that appears. You can also
press the Select Files button to find your files on your laptop and
click them to import them.
86
Click Upload Backup Files and drag your files into the box that appears
8. Select all components and click to proceed with the restore process.
UpdraftPlus will show some warnings, as you are restoring your
site from https://your-site-name.com to https://your-site-name.com/
restore-testing/wp-admin, so it notices that the address is changing.
Click to continue.
87
When doing a backup restore test, restore all data to fully test your site
Once complete, click the blue button to return to your staging site settings page
Take note of the address bar to ensure it is the restored site you are testing and not
your main site. They will look the same!
11. Once you are finished with your testing, you should delete the staging
site which you created earlier. Log back in to your main site (https://
your-site-name.com/wp-admin), and go to WP Staging in the left-
hand menu. Click to delete your restore-testing site. This will remove
the staging site, its files, and database.
Delete the staging site to get back the space on your hosting account
89
Method 2 - Restore to UpdraftClone
If you have a large site, you might not have enough space on your
server or hosting account to use a staging site, which is a copy of your
whole site. You might also not want to do testing on the same server as
your live site in case anything goes wrong and the live site is affected.
UpdraftClone is a great alternative, as a copy is made of your site
using the same technology as what is used for the backups. So if your
site copies over to UpdraftClone successfully, you can be assured that
your backups are good also.
6. Once you have tested the clone and are satisfied your site was
copied across successfully, go to https://updraftplus.com/my-
account and delete the cloned site. While the clone is running,
tokens will be taken from your account each week, so do not leave
it running if you don’t need it any longer.
Having a test plan for your restored site involves browsing around your
restored site just as a normal user/customer would, visiting the sorts of
articles and pages they would visit, and using the features of the site
to ensure everything is working correctly.
Final Notes
Backups are a key part to the security of your website and give you piece
of mind, knowing that you can always roll back the clock if something
goes wrong. They are so important, in fact, that each year March 31st
is celebrated as World Backup Day (http://www.worldbackupday.com/
en/). Take the time to ensure you have backups set up for your site and
a plan to test them.
It is best to think in terms of when you will need a backup, rather than
if. There are many WordPress plugins available for taking backups,
and I would encourage you to thoroughly explore one that works for
you. So when the time comes, you are familiar with the restoration
process, and able to perform it quickly and confidently.
92
Backups and restore testing are fundamental parts of your overall
security plan for your website, but also your other IT assets like servers,
laptops, and home documents. If you want some help setting up your
backups, doing regular restore testing, or knowing what to test, please
go over to https://dermotdowney.com/index.php/call to book a call and
I’d be happy to help.
Write out and continually update a restore test plan for your website
93
Patching
Earlier in the year, the American NSA had lost control of a collection of
computer vulnerabilities they had been using to break into computers,
and these vulnerabilities were then published onto the internet. While
Microsoft had released a patch to ‘vaccinate’ and protect computers,
many companies are slow to update their computers, so when Russian
hackers used the NSA vulnerabilities to develop their virus, they knew
it would have a big impact.
Maersk had not only not installed the update, but a lot of their computers
were running on very old Windows platforms including Windows 2000,
which stopped receiving security updates back in 2010. Over 49,000
of their servers and laptops had their data wiped, including all of their
Windows computers. They had to order thousands of new laptops,
reinstall them all by hand, and get them issued back out to their staff
94
so they could continue working as best they could. It took months
for anything resembling normal operations to begin again, and the
eventual cost to them was over $350 million.
There are three aspects to your site that need regular updating:
Click Enable auto-updates to have all patches and updates automatically installed
For themes, go to Appearance and click into each theme. Here you
will see an option to Enable Auto-Updates. It is advisable to also turn
this on for all themes.
97
One of the concerns around automatic installation of updates is that
it might break features or functionality of your site. To fix a security
vulnerability, the developers must re-write code, and this can
sometimes change how things work within the software. Developers
test their code before pushing it out to websites, but sometimes issues
occur, though they are often spotted and fixed quickly.
The first step is to be sure your backups are being taken on a regular
schedule and restores have been tested. This will allow you to roll back
any changes or updates which cause problems, allowing your site to
continue to function as normal while you investigate any problems.
The second step is to have a strategy and schedule for how you patch
your websites. The approach you take may vary depending on the size
of your organisation.
The third step is to use a staging site for testing updates before applying
them to your live site. We discuss staging sites in more detail in another
chapter, but this allows you to test an update on a copy of your main
site and confidently demonstrate that it will not cause problems. If it
does break something, it gives you an opportunity to investigate ways
of fixing the problem, which you can also include as part of your plan
when updating the live site.
If, despite your efforts, you upgrade a plugin and still encounter a
problem on your live site, you can roll back the update to give yourself
time to investigate further. Plugins such as WP Rollback (https://
wordpress.org/plugins/wp-rollback/) allow you to go back to a previous
version of a plugin, or you can restore your site from the recent backup.
99
Nulled Plugins or Themes
While there are many free plugins and themes available for WordPress,
some also charge a fee for a licence to use them. Many free plugins
offer a Pro version with extra functionality for a one-time or recurring
monthly cost. Site owners may be interested in getting these additional,
feature-rich versions but without paying for them.
There is also the ethical side to the discussion. The reason great
software, such as WordPress itself and all of its additional features,
themes, and plugins exists at all is because developers around the
globe have put their time and energy into it. They wouldn’t or couldn’t
do this if they were not getting paid for their work, and it is right to
compensate someone if their efforts result in you having a better-
looking site that generates income for you.
All in all, the risks and costs to using pirated software on your site are
much higher than any benefit you gain. Pirated code can simply not be
trusted to be secure, and installing this malware to your site exposes
you to problems down the line which undermine any other steps you
take to secure your site.
If you would like help with keeping your site current and patched
against attacks, go over to https://dermotdowney.com/index.php/call
to book a call. We can go over how your site is currently maintained
and how to secure it against online threats.
101
End of Chapter Checklist:
For any plugins you are not comfortable with auto-updating, set up
a staging site for testing and check or update them on a regularly
scheduled basis
Ensure your site is being backed up frequently, and you are testing
your restores
Managing both the internal and external users, and what they can do
on the website, is a powerful way of keeping your site secure. Your aim
is to allow the user to do exactly what they need to do—whether that
is publish content, buy products or enrol in a course—but do no more
than that. You also want to prevent information leaking which doesn’t
need to be exposed.
When you set up a new user account, one of the things you will have
to select is its Role. By default, WordPress comes with a series of very
well-defined roles for what users who log in can do:
Other plugins may introduce new user roles, but the idea overall is that
users should only have the level of access that they need in order to do
their job on your website. If you have an author writing content for your
website, they do not need Administrator role. Known as the Principle
of Least Privilege, users should only have enough rights to do the job
they need to do, and no more. This reduces the temptation, and ability,
for them to do things on your site that they shouldn’t do and keeps you
in control of what people can and are doing.
Controlling who has a user account is big part of keeping your site
secure. In the chapter on Patching, we discuss various types of security
bugs and vulnerabilities which plugins may have, but one type is called
a Privilege Escalation vulnerability. With this, an attacker can exploit a
flaw in a plugin to give themselves higher privileges on your site than
what they are meant to have, or even what you have set for them.
The solution is to patch and upgrade the plugin which has the
vulnerability in it, but you can also take steps to limit the problem from
104
affecting your site by not allowing users to register for accounts if they
do not need to. Many sites need people to register and set up accounts.
But if this is something that is not needed for your site, it is best to
disable it. While the vulnerability in this case was in a membership
plugin, implying that user registration is needed on those sites, it could
just as easily appear in other plugins you may have installed.
If you do not need for people to register for your site, then this is a
feature that can be turned off. Go to Settings > General, and untick the
option for Membership. In security terms, if something is not needed,
then it should be turned off. With this, you have closed off a potential
avenue for harm and made your site easier to manage.
If your site does require registered users, set a regular schedule for
reviewing them. Click into the Users menu and review the list of users
and the Roles assigned to each. If a user doesn’t need to have access
to your site anymore, either Delete them or edit their account and set
the Role to ‘No role for this site’. This will leave their account in place,
but ensure it cannot be used to do anything. You can also set a new
password, which will also prevent their account from being logged into.
If you have staff members or content contributors, this should form part
of your Joiners, Movers, and Leavers (JML) process. Disabling the
account of former employees is an important step in preventing harm
when people leave your organisation.
105
There is some debate as to whether hiding your username benefits
the security of your website. There are many who feel that preventing
as much information disclosure as possible from attackers is the
best course of action. There are others with the viewpoint that the
real security to your site login comes from having a sufficiently secure
password and two factor authentication.
Once this is done, iThemes has a great feature in their security plugin
which will automatically block any attacker who tries to log in using the
‘admin’ username. On the WordPress menu, go to Security > Local
Brute Force Protection and enable the option for ‘Automatically ban
“admin” user’ and save your settings.
Whichever account you are using, it is also important that you log out
of them at the end of your session. Modern web browsers want to
make life simple and convenient for us, and will remember your login
details until you specifically log out of your accounts. Simply closing
your browser window or turning off your laptop will not log you out
of your WordPress account. If you are using a computer which other
people have access to, they can log into your account simply by going
back to your WordPress site and pick up right where you left off last
time.
An attacker may also try to hide their Admin user account. There are
two things you need to check here. Firstly, in the WordPress Users
list, check that the number of Admin accounts you can see on screen
matches the number in brackets on the Administrator filter. There are
code hacks that can hide Admin accounts from the WordPress user
listing, but these may still appear in the count of Admin users shown
on the filter.
Compare the number of users shown against the number of users WordPress tells
you registered on your site, particularly the Admins
The second and most definitive way to check for rogue Admin accounts
is to go to the database itself and review the users shown there. In
the control panel for your web hosting account, scroll down the list of
services until you come to the Databases section. A very common tool
for administering databases is called phpMyAdmin, so click on this to
connect to your database.
108
• On the left hand side, you will see a list of the databases on your
hosting account. Click into the one used for your WordPress site; in
the example below it is called ‘dermotdo_wp127’.
• You should see a list of data tables appear on the main screen.
These are the tables where the actual data for your website are
stored. Each table will begin with a prefix of letters and/or numbers.
In the example below, the prefixes are ‘wpjb_’.
• Click into the table called {prefix}_users and ensure the list of
users matches what you are seeing in WordPress. If not, take a
backup of your database and then delete any unusual entries.
109
Set a schedule for reviewing the users on your site, such as monthly
Part of what made the NSA’s surveillance feasible was the means
by which data moves from one location to another. When you visit
a website, your computer sends a request to the web server for the
webpage you want to view. Your computer rarely knows the exact
server the webpage is on, or where in the world it is. So its request gets
sent, or routed, between different networking devices, called routers,
as it moves across the internet, getting closer to the web server with
each hop. Routers are always looking for the fastest route to send the
internet traffic, and depending on how busy neighbouring routers are at
112
the time, this may not always be the most direct route geographically.
Diagrams showing the routes network traffic took to reach a web server in a
German data centre, from homes in Denmark and Spain
This not a new problem, nor is the NSA the first organisation to do this.
Traffic interception has long been a recognised dilemma. In the late
1990’s the internet company Netscape released the first versions of
an encryption standard for secure and private communication across
the internet. Originally called SSL (Secure Socket Layers—a name
still in common use), the standards went through several revisions and
upgrades. These are known today as TLS (Transport Layer Security).
Interestingly, the most common point of capturing data is the first point
you connect to. This could be your Internet Service Provider capturing
your data, or a public Wi-Fi point in a coffee shop or library that you use
to check your emails. Attackers sometimes set up a fake wifi hotspot
in a public place, so people will connect to it, and thus the attacker can
capture and read their emails and internet browsing activity.
1. It encrypts the data being exchanged between the website and the
visitor.
Encryption
Only the end points of the connection, the server and the computer,
are able to decrypt the traffic; meaning anyone tapping into the session
is unable to read anything that is being sent.
Integrity
If an attacker can get between you and the traffic going to your browser,
they can modify the data stream, which will never be for your benefit. At
its most basic, an attacker could use scripts to simply modify content
on your webpage, giving visitors different content and results to what
you actually have on the page. There was a time when Internet Service
Providers were injecting scripts into users’ traffic so ads would pop up
while they were browsing normal webpages.
More nefarious attacks on HTTP traffic would include injecting code into
the webpage which runs a crypto coin miner in the visitor’s browser.
This would cause the CPU of your visitors computers to start running
extremely high, as the code attempts to mine digital currencies using
116
their computer while they are browsing your site. As far as your visitor
can tell, it is your site making their computer run hot, giving you a bad
name.
Integrity is also important for website owners who accept file uploads
or input or comments from users of their website. They can have
confidence that the file or form contents the visitor filled out are correct
and as the visitor intended, and have not been tampered along the
way. It would be entirely possible for an attacker to swap a file that a
visitor uploaded for one containing malware and infect the website, but
with HTTPS, this is not possible.
Troy Hunt, the well renowned security researcher, has a great blog
posting and video showing just what can be done by tampering with a
HTTP connection, and talks in more depth about these types of attack.
His video is available at https://www.troyhunt.com/heres-why-your-
static-website-needs-https/.
117
Spoofing
When you type gmail.com into the address bar of your browser, you
expect to be brought to Google’s email service. Your browser reaches
out to the internet to see what server Gmail is on, then connects you to
that server so you can read your emails. It is possible for an attacker to
redirect your browser to a fake server so they can capture your Gmail
account password as you try to log in. This would be a serious threat
to the security of your information, and a threat to trust in the internet,
and so HTTPS has built in protections against this.
This web browser has noticed that this site could be attempting to fool you or intercept
your data
So, HTTPS uses TLS encryption to secure the traffic between the web
server and users’ computers, but it also does much more than this.
Before the Snowden revelations, HTTPS was seen as only something
that banks, website login pages, or the paranoid needed. Since the
revelations, there has been a massive uptake in the use of HTTPS,
so much so that over eighty percent of sites on the internet are now
delivered over encrypted connections—and this is set to increase
further still.
No warning message
displayed when website is
using HTTPS. Padlock icon
is a more reassuring icon for
visitors to see.
Implementation
Not too long ago, it was a costly affair to get a HTTPS certificate.
Certificate Authorities had a booming marketplace selling these, with
the basic certificates costing anywhere from fifty dollars per year up
to over $1,000 per year for certificates which involved an extended
validation process.
Its success has seen it become the largest issuer of free SSL/TLS
certificates in the world, and lead to integrations into cPanel control
panels and WordPress plugins to make upgrading to a secure
connection easy for websites to do. A few options are listed below, but
you may need to get some technical help for the configuration as the
options and features of each method can vary somewhat.
This host offers free secure connections via the cPanel hosting account
2. There are also some plugins available which help configure this
for you. I was able to successfully set up a secure connection very
easily using Auto Install Free SSL (https://wordpress.org/plugins/
auto-install-free-ssl/), which also provides video guides on how to
walk through the process.
The Auto Install Free-SSL WordPress plugin was quite easy to set up and get an
immediate HTTPS certificate
3. Another great option is to move your server behind Cloudflare.
Cloudflare is a content delivery network consisting of hundreds of
data centres around the world. They store a copy of your website
on their servers, known as caching, so visitors that browse to your
website retrieve it from Cloudflare’s servers. This reduces the
load on your servers, protects against attack traffic such as DDoS
attacks, and provides your site with an automatic SSL certificate.
To do this, create a Cloudflare account, select the free plan, and
change your DNS nameservers to the ones Cloudflare provides.
122
Cloudflare makes encryption easy and provides great security benefits for your
website
Once you have set up HTTPS on your site, it is important to know that
it has been done correctly. In security, it is often the implementation of
encrypted protocols into systems and websites where problems arise.
A poorly-implemented security solution, in which the attacker can just
get around the solution, is often just as bad as having no security at all.
You can test your website by using the SSL Labs service (https://www.
ssllabs.com/) to test your site’s certificate and configuration. This will
run a series of tests to check against common and known attacks, and
gives you a rating of how good your HTTPS connection is set up. It
also gives you a detailed breakdown of what it has found. So if you are
getting a less than desirable result, it pinpoints the reasons why and
what needs to be done to improve it. If anything needs addressing, you
will need to get technical help to review and fix the issues.
123
In Closing
If this is something you would like further help with, feel free to go over
to https://dermotdowney.com/index.php/call to book a call where we
can discuss what is needed next for your site.
When someone visits your web site, their web browser makes a request
to your server for a particular page. Your server reads and interprets
the www address (the URL) sent to it—which the visitor had either
typed or from the link they clicked—and replies with the page they
requested. An attacker can craft a malformed website address which
will instruct your web server to not only reply with the requested page,
but also take some other action—such as display the contents of the
database, export the list of registered users and passwords, or upload
malicious code which can be used against other visitors. In the chapter
on User Management, we will discuss how you can list the users on a
website by modifying a WordPress website URL.
One of the great benefits of a WAF is that the firewall rules can be
updated, which allows for new attacks to be blocked. Often called
‘virtual patching’, if a vulnerability is discovered and a website needs
time to test the patch before it can be updated, adding a new rule to the
126
WAF will block malicious attempts to exploit that vulnerability.
• Server based WAFs filter traffic on your server, but before PHP
and your database have to load up, thus freeing up server
resources.
Cloud-Based WAF
• Cloudflare (https://www.cloudflare.com/)
• Sucuri (https://sucuri.net/)
127
Server-Based WAF
• ModSecurity (https://github.com/SpiderLabs/ModSecurity)
• 7G (https://perishablepress.com/7g-firewall/)
Wordfence is one of the most popular security plugins out there, and
128
update their rules to defend against new threats. BBQ is the plugin
version of the 7G firewall mentioned above which will block against the
most common attacks your site will face.
These plugins are often updated with new rules, and offer premium
versions with improved features. If you have not used a WAF previously,
I would recommend installing one of these to start protecting your site.
• Wordfence (https://wordpress.org/plugins/wordfence/)
• BBQ (https://wordpress.org/plugins/block-bad-queries/)
Do you want help with blocking bad requests to your site? Go over to
https://dermotdowney.com/index.php/call to book a call and we can go
over what will work best for your site.
Joe runs a news website focused on Scottish local affairs and was
actively developing his site to offer more services to residents of the
Scottish Highlands region. He was aware that the more traffic you
generate, the more attacks you will attract, so he set up two factor
authentication to prevent attackers from accessing his site through the
login page. But during the set up, his session timed out and he was
logged out of his site. When he went to log back in, he found himself
being redirected back to the user login page without ever getting to his
website dashboard.
WordPress plugins give you a lot of control over the features and
behaviour of your website, and setting them up correctly sometimes
involves a bit of trial and error. Configuring a feature, seeing how
it works, and then undoing or reconfiguring that feature is part of
development of your site.
With many plugins, the worst misconfiguration problem you will probably
face will be some aspect of your website that doesn’t work properly,
and which can be resolved by logging back in and undoing what was
done. For the security plugins we discuss in this book, setting them
up incorrectly could mean locking yourself out of your site and not
being able to get back in. Knowing what to do in such a scenario gives
you the confidence to experiment and test the various security options
available, knowing that you still retain ultimate control over the site.
If you have a site that is currently live and active, it is wise to have a
second site for testing any new features or plugins. We discuss this in
130
more detail in the chapter on setting up a staging site, but it is useful to
have a second site for testing so you only make confident, rehearsed
changes to your live site.
Plugins are stored in a specific folder on your web server, and renaming
this folder has the effect of disabling the plugin. By accessing the files
and folders behind your website, you can thus disable any plugin and
reacquire access to your site.
1. Log in to your hosting account control panel, and click the link to
your File Manger.
3. Right click on the folder for the plugin you want to deactivate, select
Rename and add something after the name like ‘.DEACTIVATED’.
Changing the name in any way or adding any text will have the
same effect. You can also disable all plugins at once by renaming
the plugins folder itself.
The folder for the iThemes plugin is called better-wp-security – the old name for this
plugin
4. Now that you can log back into your website, you can go back to
the plugin menu, reactivate it, and continue making changes to its
configuration. Note that reactivating it will not remove the text you
just added; it just activates the plugin again. It is a good idea, once
you have set it up correctly, to revert it back to its original name.
132
5. Again use the File Manager to go back to your plugin directory,
right click, and rename the folder. Once again, this will disable the
plugin. So go back to your WordPress dashboard, go to the Plugin
menu, and reactivate it.
Seeing the power of the file manager should underpin the importance
of protecting the login details for your hosting account. All the security
plugins in the world will be of little use if an attacker can target your
hosting account, disable all security features, and then attack your
now undefended website.
Login to your hosting account to get familiar with the settings you
can configure
Go into your file manager and find the folders for your plugins, in
case you ever need to disable them
133
Continuous
Monitoring
Our homes are often good examples of defence in depth. Often built of
pretty solid materials to begin with, you also take steps to secure it by
keeping your windows and doors closed and locked, and only letting in
people who have your permission to come in. If all of this fails though,
and someone still manages to get in, a burglar alarm is watching’ for
a breaking window, or movement inside the house, and alerts you so
you can respond.
Secondly, if they really do want to attack you, you delay them in their
attack. Make it difficult and time consuming for them by using really
strong passwords on your user accounts and don’t reuse passwords.
Lastly, if they do succeed, you need a way of detecting them, so you
can respond quickly and deal with the problem.
Uptime Monitoring
There is an old joke that the only way to truly secure a computer is to
unplug it, but that is not true. The role of security is for the website to
exist and conduct its business without being impacted by malicious
threats. A core objective of any security model is to keep an asset, your
website in this case, up and available to visitors; security is there to
support the business objective.
Your website could be brought offline due to other factors not related
to your host though so it is good to monitor this yourself also. A bad
patch upgrade or even denial of service attack, where you are flooded
with malicious traffic, could also bring your site off the air, and getting
an early notification about this will allow you to respond quickly and
minimise the amount of traffic and visitors you lose. Sites such as
UptimeRobot (https://uptimerobot.com/) will connect to your site on
a regular basis, usually about every five minutes, to ensure it is still
running, and notify you if they find it down.
135
Google Blacklisting
The black box flight recorder plays a critical part in maintaining aircraft
safety. These two innocuous little boxes, actually coloured bright
orange or red, sit quietly in the tail of an aircraft recording all of the
data and cockpit conversations that take place during a flight. They
don’t play an active role in aircraft safety—they don’t control any flight
surfaces, engine controls, or provide information to the pilots. Ironically,
they are device no one ever hopes to need, but they have had some of
the greatest influences on the evolution of aircraft safety.
Server and website logs are the black boxes for your website; watching,
recording, and building a picture of actions taking place should it ever
be needed. When your website is online, it deals with a constant level
of attacks along with serving up content to legitimate visitors. Your logs
give you an insight into what is happening behind the scenes, allowing
you to improve performance, improve security, or go back in time to
investigate the root cause of an incident.
Syed runs an online blog, and after hiring a developer to make some
updates to his site, noticed that his affiliate income started to drop.
Going back over the activity logs, he saw that after doing the requested
work on this site, the developer also went into a selection of his posts
and changed the affiliate links to the developers own links. These are
the subtle ways in which, without having a black box to go back over,
you would be left struggling to understand and investigate why such
things have changed on your site.
137
If you are running your own server using dedicated hosting or a VPS,
you will have access to the logs on the actual server itself. Shared
hosting accounts most likely will not have direct access to these server
logs. These are very detailed, capture a lot of information, and will
need technical expertise to read and understand them. But what you
gain from them is an understanding of what is happening on your site,
allowing you to tweak its setup for improved performance or identify
possible security risks before they become a problem. You get a
forensic level of detail once you know what you are looking for and
where to look.
We will not be going into detail on how to review server logs here, but
some of the main security items you should be looking at include:
• Web server access and error logs – These show you details
such as who has been accessing your site, including search
engine crawlers, and what pages they have gone to. You can
also see login attempts which have been blocked.
Accessing and reading these logs can require some technical ability,
though there are some great tools available for visualising the web
server logs.
cPanel hosting accounts often come with the Awstats package for reviewing your
web server logs
138
Activity Logs
Activity log plugins are WordPress plugins which record any changes
or activity on your website. This includes user logins, plugin installation
and updates, and any activity performed by users on your site. These
give you insight into the workings of your website in an easy-to-read
format. The best plugins also give you the option of exporting the
activity logs to a spreadsheet, making it easier to filter, sort, and review
the activity.
But logs are not just for reviewing after an incident. The best tactic
for logs is to review them on a periodic basis, thus giving yourself a
picture of what a normal level of activity looks like. This will help identify
if something out of the ordinary is going on, and give you an early
indication of suspicious activity. The NSA themselves have stated at
security conferences that the thing they fear most is a systems admin
who reviews their logs frequently.
There are a number of activity log plugins available from the WordPress
store, many for free. Two which I like are Activity Log (https://wordpress.
org/plugins/aryo-activity-log/) and Simple History (https://wordpress.
org/plugins/simple-history/). These give you a good level of detail about
activity on your website and allow you to export it for further analysis.
If you would like help with regular reviewing of your logs, go over
to https://dermotdowney.com/index.php/call to book a call. We can
discuss how best to do this
139
End of Chapter Checklist:
Test some plugins, allow them to capture data for a few days, and
then review which one you like the best.
See what regular activity on your site looks like, so you can start to
identify unusual activity
140
Conclusion
‘Si vis pacem, para bellum’ is an old Latin proverb which translates to,
‘If you want peace, prepare for war’. It holds true for todays digital age
and for a website which is put up on the public internet.
Protecting yourself from online attack, and having your website exist
and grow on the internet, involves taking a multi-faceted approach to
your security. We mentioned early on that security is a mindset, rather
than a feature of your website that is simply turned on. It is true that
the majority of the attacks you will encounter are repetitive automated
bots, but there are also skilled, motivated and capable humans at work
out there. As well as having preventative measures in place on your
site, we have talked about how there is always the risk of an attack
being successful, and so detective and recovery measures are equally
important.
The users of your site, both contributors and visitors, also play a big
part in your security model. We discussed steps you can take to help
them choose secure passwords, limit what they can do, protect their
connections to your site, and educate them about the possibility of
phishing attacks.
141
The next step is for you to assess the level of security on your websites.
Are there any gaps in your security that need to be filled? Which sites
are the most important to focus on first, or which carry the most risk in
terms of the impact to you or your business if they get hacked an hour
from now? Have an informed discussion with your team or website
developer about how secure your sites are, and how this can be
improved and maintained.
If you need more help with any aspect of your website security I would be
happy to help. You can drop me an email at dermot@dermotdowney.com
or to book a free, no obligation session to discuss your needs feel free to
go to https://dermotdowney.com/index.php/call.
Dermot
142
About the
Author