When an application stores or uses information that is sensitive in some way (credit card numbers, social security numbers, health records, passwords, and so on), special measures should be taken to protect it, as it could result in severe reputational, economic, or even legal damage to the organization that is responsible for its protection and suffers a breach that compromises it.
The sixth place in OWASP Top 10 is the sensitive data exposure, and it happens when data that should be specially protected is exposed in clear-text or with weak security measures.
In this recipe, we will cover some of the best practices when handling, communicating, and storing this type of data.
.htaccess
file to prevent direct access:Order deny,allow Deny from all
httpd.conf
:<FilesMatch ".(pdf|png)> FileETag None Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </FilesMatch>
When it comes to protecting sensitive data, we need to minimize the risk of that data being leaked or traded with; that's why storing the information correctly encrypted and protecting the encryption keys is the first thing to do. If there is a possibility of not storing such data, it is the ideal option.
Passwords should be hashed with a one-way hashing algorithm before storing them in the database. So, if they are stolen, the attacker won't be able to use them immediately and if the passwords are strong and hashed with strong algorithms it won't be able to break them in a realistic time.
If we store sensitive documents or sensitive data in the document root of our server (/var/www/html/
in Apache, for example), we expose such information to be downloaded by its URL. So, it's better to store it somewhere else and make special server side codes to retrieve it when necessary and with a previous authorization check.
Also, pages such as Archive.org, WayBackMachine, or the Google cache, may pose a security problem when the cached files contain sensitive information and were not adequately protected in previous versions of the application. So, it is important to not allow the caching of that kind of documents.
3.137.223.190