Bitzu

CPSA ยท Web application assessment: injection, sessions and code

Protecting data in transit and at rest

Client- and server-side encryption of data, and when encryption is misused.

Key points

  • In transit: TLS; client-side JavaScript encryption is no substitute, as an attacker can alter the script or replay the ciphertext.
  • At rest: data the app reads back is encrypted with a managed key kept apart from the data.
  • Passwords: never encrypted; salted, deliberately slow hash (Argon2id first choice).
  • Misuse: keys hard-coded in scripts or beside the data, encoding sold as encryption, fast unsalted password hashes.

Source: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html

Practice questions

Single choice

How should an application store user passwords?

  1. Encrypted with AES so they can be shown to support staff
  2. Base64-encoded in the user table
  3. As a salted, slow hash such as Argon2id
  4. In plaintext inside an access-controlled table
Show answer

Answer: C. As a salted, slow hash such as Argon2id

Passwords need a one-way, salted, deliberately slow hash so a stolen database cannot be reversed cheaply. Reversible encryption, Base64 and plaintext all expose passwords if the data or key leaks.

Select all that apply

Which of these are misuses of cryptography that a tester should report?

  1. The encryption key is hard-coded in downloadable JavaScript
  2. Card data is encrypted but the key sits in the same table
  3. Sensitive values are Base64-encoded and described as encrypted
  4. Passwords are hashed with Argon2id and a unique salt
  5. All pages are served over HTTPS
Show answer

Answer: A. The encryption key is hard-coded in downloadable JavaScript, B. Card data is encrypted but the key sits in the same table, C. Sensitive values are Base64-encoded and described as encrypted

A hard-coded key in client script is public, a key stored next to its ciphertext offers no separation, and Base64 is reversible encoding, not encryption. Argon2id for passwords and site-wide HTTPS are correct practice.

True or false

True or false: encrypting stored passwords with AES is just as good as hashing them, as long as the key is secret.

Show answer

Answer: False

False. Encryption is reversible, so one leaked key exposes every password, whereas a salted slow hash cannot be reversed and forces per-password cracking.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More CPSA topics in this module