aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/message_encryptor.rb
diff options
context:
space:
mode:
authorMichael Coyne <mikeycgto@gmail.com>2017-05-15 08:45:14 +0000
committerMichael Coyne <mikeycgto@gmail.com>2017-05-15 08:54:39 +0000
commit71fb6def5f07233e4fdf628e02981e4add5c6b8b (patch)
tree88b1144823baced8660d34d6f1f5652afb97167c /activesupport/lib/active_support/message_encryptor.rb
parent4734d23c74fb4193aafe7cb04256bb745680d97f (diff)
downloadrails-71fb6def5f07233e4fdf628e02981e4add5c6b8b.tar.gz
rails-71fb6def5f07233e4fdf628e02981e4add5c6b8b.tar.bz2
rails-71fb6def5f07233e4fdf628e02981e4add5c6b8b.zip
Fix for AEAD auth_tag check in MessageEncryptor
When MessageEncryptor tries to +decrypt_and_verify+ ciphertexts generated in a different mode (such CBC-HMAC), the +auth_tag+ may be +nil+ and must explicitly check for it. See the discussion here: https://github.com/rails/rails/pull/28132#discussion_r116388462
Diffstat (limited to 'activesupport/lib/active_support/message_encryptor.rb')
-rw-r--r--activesupport/lib/active_support/message_encryptor.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb
index 0671469788..9589dba3ca 100644
--- a/activesupport/lib/active_support/message_encryptor.rb
+++ b/activesupport/lib/active_support/message_encryptor.rb
@@ -110,7 +110,7 @@ module ActiveSupport
# Currently the OpenSSL bindings do not raise an error if auth_tag is
# truncated, which would allow an attacker to easily forge it. See
# https://github.com/ruby/openssl/issues/63
- raise InvalidMessage if aead_mode? && auth_tag.bytes.length != 16
+ raise InvalidMessage if aead_mode? && (auth_tag.nil? || auth_tag.bytes.length != 16)
cipher.decrypt
cipher.key = @secret