CH4: Cryptographic Failures
Sensitive Data, whether at Rest or in Transit, must be protected. Cryptography is the process of protecting information by encrypting it, so that only those for whom the information is intended can read and process it. Applications should be designed to still be secure even if cryptographic controls fail. We can achieve this by applying Defence in Depth. This chapter explains the root cause for sensitive data exposure; namely, Cryptographic Failures. Different attack vectors are presented, and prevention measures and techniques are outlined.
Learning Outcomes
Lab Activity: TBA
In this practical activity, you will ...
Coming Soon »Cryptography 101
Cryptography is the process of protecting information through the use of mathematical algorithms, so that only those for whom the information is intended can read and process it. Cryptography is closely related to the disciplines of cryptology and cryptanalysis. So, let us start with some definitions:
Hashing
Hashing is a process that involves the use of a one-way mathematical function that is relatively easy to compute but significantly difficult to reverse. The input to the hash function is of arbitrary length but the output is always of fixed length. Values returned by a hash function are called Message Digest or simply hash values.
Hashing Properties
A Hash Function is computationally hard to reverse. That is why it is conisdered a one-way function. This property is called Pre-Image Resistance. Because of this property, Hashing is used for storing passwords. If an intruder was able to access password records, they will only see a hashed version of the password, not the clear text. The intruder won't be able to logon with the hash since it will be re-computed and will result in a completelty different digest. Moreover, the intruder won't be able to retrieve the cleartext version because of the Pre-Image Resistance property.
It is very hard to find two different inputs of any length that result in the same hash (i.e., message digest). This property is called Collision Resistance. Since a hash function is a compressing function with fixed hash length, it is impossible for a hash function not to have collisions. This property of collision resistance only confirms that these collisions should be hard to find. Because of this property, Hashing is used for checking the integrity data. Data integrity check is the most common application of the hash functions. The Hash Function is used to generate checksums on data files, and this provides assurance to the user about correctness of the data.
References
Cryptographic Failures
In the 2017 version of the OWASP Top 10 list, the Cryptographic Failures flaw was known as Sensitive Data Exposure, and was in the third place (i.e., it moved up a spot). Sensitive Data Exposure is more of a symptom rather than a root cause, and that is why OWASP shifted the focus to be on failures related to cryptography. Since cryptography is a measure used to protect data, failures in it lead to exposure [2].
Cryptographic Failures (A02:2021)
Prevention
Attack Vectors
Scenario #1 -Application Logic: An application encrypts data when stored in the database. When data is retrieved, the application automatically decrypts it. An attacker can use a SQL injection attack to retrieve the data in clear text.
Scenario #2 -Weak Encryption: An application does not enforce TLS allowing an attacker to downgrade a connection from HTTPS to HTTP. The attacker then steals a session cookie and hijacks the user's session.
Scenario #3 -No Salting: An application stores passwords in the database without salting them. An attacker uses a file upload flaw to retrieve the passwords and with the help of a Rainbow Table, crack the passwords.
References
Ads by Google
Chapter 4 Summary
Chapter 4 Revision Questions