We recently checked a company website and found a complete copy of it sitting in the public web folder as a zip file. Inside was the settings file containing the database password. Anyone who guessed the filename could have downloaded it.
Every core file on the website was clean. A malware scan would have given it a clean bill of health.
When a company website gets infected, it's rarely because someone discovered a clever, previously unknown way to break into it. More often, someone left a door open without realising it.
Outdated software, forgotten copies of the website, publicly accessible backups, admin passwords leaked from someone's laptop, or a developer who stopped working with the company but still has access.
These are the sorts of things we find when we look inside websites. Here's what they mean for your business and how we go about checking them.
Why the owner usually doesn't notice
The fact that your website looks normal doesn't necessarily mean it is.
Injected code is typically designed to behave differently depending on who's visiting the website. Search engines might see spam pages or links. Visitors arriving through ads might be redirected somewhere else. Meanwhile, the business owner types the website address directly into their browser and sees exactly what they expect to see.
That's why "The website looks fine to me" tells you very little about whether the site has been infected.
The open doors we find
Everything below comes from client websites we've reviewed in the last few weeks. None of these findings involves particularly sophisticated techniques.
Old copies of the site in the public folder. While scoping upgrades for eleven older client sites, we found that 14,482 of their 40,016 PHP files (36%) belonged to unused copies of websites and backup folders. These included a WordPress installation from years ago in a folder called "backup", a previous version of a CMS and a forgotten test copy.
Nobody is updating that code. Unless access to those folders is restricted, the old software remains accessible from the internet, just like the current website.
Backups you can download. The zip file mentioned earlier wasn't the only one. Sitting next to it was an even older backup of the previous website. On another site, we found a page displaying the server's full configuration, a mail test script and a collection of old zip archives. All of them were sitting in the public web folder.
Secrets written into code. One website contained a script with a cloud provider's access key and secret written directly into the code. The script accepted text from any visitor and passed it to a paid cloud service, without any restriction on how often it could be used.
At best, someone else gets to use the service while you pay the bill. If the access key has permissions beyond what the script actually needs, the consequences are worse.
Software nobody supports any more. During the same reviews, we found content management systems that had been unsupported for years. One had stopped receiving support from its maker in 2022, yet its admin page was still accessible to anyone on the internet.
Most of the older websites we reviewed were also running PHP versions that no longer receive security fixes. PHP 7.2, which is still common on older websites, reached end of life on 30 November 2020.
Too many ways in. One website had eight FTP logins, five of which had access to the entire site. Two-factor login wasn't enabled on the hosting control panel either. Former developers who retain access after their work has finished are another part of the same problem.
Forms that trust everyone. We found contact forms without server-side spam checks and a careers page where there was no check on the type of file being uploaded.
Admin logins that have already leaked. During a separate dark web check, we found a company's website admin login in an infostealer log. Malware on a staff computer had captured the credentials as they were typed.
Combine that with an admin page that's accessible to anyone on the internet, and the attacker doesn't need to break into the website. They simply log in.
How we check a site properly
Rather than running attack tools against a live website, we work from inside the hosting account with read-only access.
For a WordPress website, this is what the process looks like:
- Compare every core and plugin file with the official copy. WordPress publishes checksums for its own files, and
wp core verify-checksumsis the standard tool for checking them. There is a complication, though. Websites uploaded from a Windows PC can have different line endings, causing a direct comparison to flag perfectly clean files as modified. We normalise the line endings before comparing them. - Check theme and custom code separately. Without an official copy to compare against, we check this code for known malware patterns and read through sections where something doesn't look right.
- Look for PHP where it shouldn't be. We pay particular attention to the uploads folder, which should only contain images and documents.
- List everything in the web root that isn't the website itself. That includes zip archives, SQL files, old website folders and test scripts.
- Establish who has access. We list hosting logins, FTP accounts and admin users, and check whether each person still works with the company.
Remember the website with the downloadable backup? Every core and plugin file matched the official copies, and there was no code in the uploads folder.
The serious security finding was the zip file containing the database password. A malware scan alone would never have reported it.
If your site has already been cleaned
Getting a website cleaned is not the same as establishing how it became infected. A clean-up removes what's there, but unless the original point of entry is addressed, the same problem tends to come back.
If you've recently had your website cleaned, here's what you should follow up on:
- Change every password after the clean-up date. This includes the hosting control panel, FTP accounts, WordPress admin accounts and the database. Share the new passwords by phone, not email.
- Remove access for anyone who no longer works on the website. That includes former developers.
- Check every other website on the same hosting account. An infection on one website can spread to the others.
- Request the web server, FTP and control panel logs covering the weeks before the infection was discovered. If your hosting provider manages the server, make the request in writing and do it soon. Logs aren't kept forever.
- Get a list of PHP files that have changed since the date things went wrong.
- Establish who controls your DNS. If you decide to put a web application firewall in front of the website later, this is where the change needs to be made.
Check this in your own company this week
- Ask whoever manages your website which PHP and CMS versions it's running. Find out whether both are still supported. You can check the PHP version against php.net's supported versions.
- Ask for a listing of the web root. Anything ending in .zip or .sql, or any folder called "backup", "old", "test" or "new", should have a good reason for being there.
- Get a list of everyone with an admin, FTP or hosting login. Remove access for anyone who has left and enable two-factor login for those who still need it.
- Search Google for
site:yourdomain.com. Look through the results for pages your company didn't write, content in languages you don't publish in or products your business doesn't sell.
Want us to look inside your site?
We check websites from inside the hosting account, using read-only access. We explain what we find, which findings leave your website exposed and which don't.
This is part of our website services and security work. If you'd like us to check your company's website, talk to us.