Stripes

CryptoUtil should validate its input

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None

Description

It appears that CryptoUtil will gladly accept any Base64-encoded value, decode it, decrypt with a Cipher and return the bytes as a String. This allows Stripes to end up using garbage input, which might cause trouble. When decrypting, CryptoUtil should take measures to ensure it is dealing with values that were encrypted with the same session key.

Activity

Hide
Ben Gunter added a comment - 13/Dec/07 10:39 AM

A magic number is prefixed to the result before encryption and checked for upon decryption. In testing this, I also found that most of the time when a bogus value is fed in to decrypt it results in a BadPaddingException so I added a try/catch to catch that and IllegalBlockSizeException. Those cases plus the case of a bogus input that happens to decrypt properly are logged as a warning and null is returned.

Show
Ben Gunter added a comment - 13/Dec/07 10:39 AM A magic number is prefixed to the result before encryption and checked for upon decryption. In testing this, I also found that most of the time when a bogus value is fed in to decrypt it results in a BadPaddingException so I added a try/catch to catch that and IllegalBlockSizeException. Those cases plus the case of a bogus input that happens to decrypt properly are logged as a warning and null is returned.

People

Vote (0)
Watch (0)

Dates

  • Created:
    13/Dec/07 10:00 AM
    Updated:
    04/Jan/11 3:10 PM
    Resolved:
    13/Dec/07 10:39 AM