Backup Files Are Good but Can Be Evil
Since we started to work with computers, we always heard the following advice: "Make backups!". Everytime you have to change something in a file or an application, first make a backup of the existing resources (code, configuration files, data). But, if not properly managed, backups can be evil and increase the surface attack of your web application. Just take an example:
You maintain a Wordpress website for your company and, before changing the configuration, you make a backup of the main configuration file.
# cd /var/www/htdocs
# cp -p wp-config.php wp-config.php.bak
Alternatively, you can also archive the directory content:
# zip -r backup.zip .
For the same reasons, you can also make a backup of the SQL databases or user files.
Now, you can edit them and if everything goes wrong, just revert to the previous version. Looks so far so good! But, often, people forget to protect the backup (which is created with the web site UID or a wrong umask - making it readable by anybody).
What am I talking about this? For a few days, I detected a lot of scans for "backup" files across multiple websites:
/db_backup.sql /db_backup.rar /db_backup.sql.tar /db_backup.tar.gz /db_backup.tar.bzip2 /db_backup.tar /db_backup.sql.bz2 /db_backup.7z /dump.tar.bz2 /db_backup.sql.7z /dump.sql /db_backup.sql.zip /dump.bz2 /db_backup.sql.rar /dump.7z /db_backup.bz2 /db_backup.sql.tar.gzip /db_backup.zip /db_backup.tar.bz2 /db_backup.tgz /db_backup.sql.tar.bzip2 /db_backup.sql.tar.bz2 /db_backup.sql.gz /db_backup.sql.tar.gz /dump.tar.bzip2 /db_backup.gz /db_backup.sql.sql /dbase.rar /dbase.zip /sql.tar.gzip /dbase.sql.tar.bz2 /dbase.sql.tar.bzip2 /sql.rar /sql.sql.tgz /sql.tar.bz2 /dbase.tar.gzip /dbase.sql.7z /sql.7z /dbase.sql.tar.gz /sql.tar.gz /dbase.sql.tgz /sql.zip /dbase.sql.rar /dbase.sql.gz /dbase.sql.zip /dbase.sql.sql /dump.tgz /sql.tgz /dbase.sql.tar /sql.sql.tar.bzip2 /sql.tar /sql.sql /sql.bz2 /db_backup.sql.tgz /sql.gz /db_backup.tar.gzip /sql.tar.bzip2 /dbase.sql.bz2 /dbase.tar.gz /dbase.sql.tar.gzip /mysql.sql /sql.sql.tar.gz /mysql.tar.gzip /sql.sql.zip /mysql.rar /mysql.bz2 /mysql.gz /mysql.sql.bz2 /mysql.sql.tar /mysql.tar.bz2 /mysql.sql.tar.bz2 /mysql.sql.7z /mysql.tgz /mysql.tar.gz /www.sql.sql /dbdump.rar /1.sql /www.sql.tgz /sql.sql.7z /dbdump.sql.tar.bz2 /sql.sql.tar.bz2 /1.sql.tar.gz /dbdump.sql.tar.bzip2 /mysql.sql.tar.bzip2 /1.sql.gz /dbdump.tar.gz /mysql.tar /dump.sql.tar.gz /1.sql.bz2 /backup.sql.gz /sql.sql.tar /backup.sql.tar.bz2 /sql.sql.gz /1.sql.tar.gzip /mysql.sql.tar.gzip /sql.sql.bz2 /dbdump.sql.tar /dump.sql.bz2 /backup.sql.zip /dump.tar.gz /dbdump.zip /1.sql.tar.bz2 /1.sql.tgz /sql.sql.rar /1.sql.7z /backup.sql.sql /dump.sql.gz /dbdump.sql.rar /backup.sql.tar.gz /sql.sql.tar.gzip /dbdump.sql.tgz /dbdump.sql.tar.gz /dbdump.sql.gz /dump.sql.tar.bzip2 /dbdump.sql.bz2 /backup.sql.bz2 /dump.tar /dbdump.sql.tar.gzip /mysql.tar.bzip2 /mysql.sql.tar.gz /1.sql.zip /mysql.7z /mysql.zip /dump.gz /dbdump.sql.zip /backup.sql.tgz /dump.sql.tar /db.sql.7z /dbdump.tgz /dump.sql.zip /db.sql.tgz /db.tar.gz /data.sql.sql /data.sql.bz2 /web.sql.tar.bzip2 /www.sql.7z /dbdump.tar.bzip2 /db.sql.zip /www.sql /backup.sql.tar.gzip /dump.sql.7z /dump.sql.tgz /backup.sql.tar /mysql.sql.gz /mysql.sql.rar /mysql.sql.zip /upload.sql /db.sql.tar.bz2 /temp.sql.tar /data.sql.7z /users.sql /users.sql.rar /db.tar.bz2 /users.sql.7z /site.sql.tar.bz2 /upload.sql.tar.bzip2 /upload.sql.tar.gz /data.sql.tar.bzip2 /home.sql /www.sql.tar /data.sql.tar.gzip /web.sql.tar.gzip /db.7z /temp.sql.gz /dbdump.sql /users.sql.tar /users.7z /db.tar.gzip /db.sql.sql /site.sql.tar.bzip2 /dbdump.tar.gzip /www.sql.tar.bz2 /users.sql.tar.gzip /temp.sql.tar.gzip /site.sql.bz2 /db.sql /db.sql.tar.bzip2 /home.sql.tar.bz2 /temp.sql.bz2 /1.sql.tar.bzip2 /users.sql.gz /web.sql.tgz /dump.sql.tar.gzip /db.gz /db.tar /db.sql.tar.gz /upload.sql.gz /home.sql.tar.gz /db.tar.bzip2 /db.zip /home.sql.tgz /www.sql.tar.bzip2 /web.sql.tar.gz /upload.sql.tar.bz2 /users.sql.zip /data.sql /dbdump.sql.7z /upload.sql.tar /dump.sql.tar.bz2 /site.sql.tar.gzip /backup.sql /web.sql.zip /data.sql.tar /backup.sql.rar /dbadmin.sql.tar.gz /db.rar /upload.sql.7z /temp.sql.zip /dbdump.7z /data.sql.tgz /users.sql.tgz /web.sql.rar /temp.sql.tgz /site.sql.7z /www.sql.tar.gz /home.sql.bz2 /db.bz2 /dbase.tar.bzip2 /temp.sql.tar.bz2 /temp.sql.tar.bzip2 /users.rar /db.tgz /dbdump.sql.sql /db.sql.gz /dbase.tar.bz2 /home.sql.rar /site.sql /dbadmin.gz /backup.sql.7z /upload.sql.tar.gzip /dbase.bz2 /data.sql.rar /db.sql.tar /users.gz /dbadmin.tgz /users.bz2 /users.sql.tar.bz2 /www.sql.gz /upload.sql.rar /dbadmin.tar.gz /users.sql.tar.bzip2 /users.tar.gzip /home.sql.zip /dbadmin.sql.bz2 /dbadmin.sql.tar /site.sql.tar.gz /mysql.sql.tgz /db.sql.rar /public_html.sql /upload.sql.bz2 /web.sql.bz2 /dbadmin.tar.bzip2 /home.sql.tar.bzip2 /upload.sql.tgz /dump.rar /web.sql.7z /users.sql.bz2 /temp.sql.tar.gz /home.sql.sql /dump.zip /dbadmin.sql.gz /temp.sql.7z /dbadmin.tar /dbadmin.sql.rar /db.sql.tar.gzip /www.sql.zip /dbadmin.sql /home.sql.tar /www.sql.rar /www.sql.bz2 /data.sql.tar.gz /web.sql.tar.bz2 /dump.tar.gzip /dbadmin.sql.tar.bz2 /dbdump.bz2 /dbdump.gz /temp.sql /web.sql /dbadmin.sql.tar.gzip /dbadmin.sql.7z /home.sql.7z /dbadmin.tar.bz2 /dbadmin.sql.zip /dbase.sql /data.sql.zip /dbadmin.sql.sql /db.sql.bz2 /users.tar /dbadmin.sql.tgz /backup.sql.tar.bzip2 /dbadmin.7z /site.sql.gz /users.tar.bz2 /dbase.tar /dbadmin.zip /temp.sql.rar /data.sql.tar.bz2 /dbadmin.sql.tar.bzip2 /dbase.tgz /dbadmin.bz2 /users.tar.gz /users.zip /users.tar.bzip2 /users.sql.tar.gz /site.sql.rar /site.sql.tgz /dbase.gz /dbdump.tar /home.sql.gz /dbdump.tar.bz2 /web.sql.tar /dbase.7z /data.sql.gz /upload.sql.zip /users.tgz /dbadmin.tar.gzip /home.sql.tar.gzip /1.sql.rar /1.sql.tar /site.sql.zip /www.sql.tar.gzip /web.sql.gz /dbadmin.rar /site.sql.tar
I also detected scans for files ending with a '.bak' extension or the '~' (the common way for many editors to make a backup of edited files).
To protect yourself against this problem:
- Do not store backup files in the root of your website.
- Delete them once the maintenance completed and that you're sure you don't need it.
- Change the owner and access rights (use a correct umask!)
- Encrypt them (zip -e)
- Just store them offline!
But of course, continue to make backups of your sensitive data...
Xavier Mertens (@xme)
ISC Handler - Freelance Security Consultant
PGP Key
Reverse-Engineering Malware: Advanced Code Analysis | Online | Greenwich Mean Time | Oct 28th - Nov 1st 2024 |
Comments
Anonymous
Jan 15th 2017
7 years ago
Anonymous
Jan 16th 2017
7 years ago
Xavier, your recommendations are solid. The only thing I would add is to make sure in your business agreements and/or due diligence, to make sure your service providers follow the same practices - and to ensure business agreements specify what happens to your data when you cease doing business with a provider.
Anonymous
Jan 17th 2017
7 years ago