This is part 6 of a series of posts on the OWASP Top 10 Proactive Development Controls.
Regulations – and good business practices – demand that you protect private and confidential customer and employee information such as PII and financial data, as well as critical information about the system itself: system configuration data and especially secrets. Exposing sensitive information is a serious and common problem, 6th place on the OWASP Top 10 risk list.
Protecting data and privacy is mostly about encryption: encrypting data in transit, at rest, and during processing.
Encrypting Data in Transit – Using TLS properly
For web apps and mobile apps, encrypting data in transit means using SSL/TLS.
Using SSL isn’t hard. Making sure that it is setup and used correctly takes more work. OWASP’s Transport Layer Protection Cheat Sheet explains how SSL and TLS work and rules that you should follow when using them.
And OWASP has another Cheat Sheet on Certificate Pinning that focuses on how you can prevent man-in-the-middle attacks when using SSL/TLS.
Encrypting Data at Rest
The first rule of crypto is: Never try to write your own encryption algorithm. The other rules and guidelines for encrypting data correctly are explained in another Cheat Sheet from OWASP which covers the different crypto algorithms that you should use and when, and the steps that you need to follow to use them.
Even if you use a standard crypto algorithm, properly setting up and managing keys and other steps can still be hard to do right. Libraries like Google KeyCzar or Jasypt will take care of these details for you.
Extra care needs to be taken with safely storing (salting and hashing) passwords – something that I already touched on an earlier post in this series on Authentication. The OWASP Password Storage Cheat Sheet walks you through how to do this.
Implement Protection in Process
The last problem to look out for is exposing sensitive data during processing. Be careful not to store this data unencrypted in temporary files and don’t include it in logs. You may even have to watch out when storing it in memory.
In the next post we’ll go through security and logging.
|Reference:||10 things you can do as a developer to make your app secure: #6 Protect Data and Privacy from our JCG partner Jim Bird at the Building Real Software blog.|