diff options
author | Shugo Maeda <shugo@ruby-lang.org> | 2021-05-11 10:31:27 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-07-07 19:08:18 +0900 |
commit | e2ac25d0eb66de99f098d6669cf4f06796aa6256 (patch) | |
tree | f302700f02791d309bbbf695573e6b0705ceb91c /lib/net/imap.rb | |
parent | fc71da2673b4cef08749a6756c3fe2ca214820b7 (diff) |
Fix StartTLS stripping vulnerability
This fixes CVE-2021-32066.
Reported by Alexandr Savca in <https://hackerone.com/reports/1178562>.
Diffstat (limited to 'lib/net/imap.rb')
-rw-r--r-- | lib/net/imap.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 505b4c8950..d45304f289 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -1218,12 +1218,14 @@ module Net end resp = @tagged_responses.delete(tag) case resp.name + when /\A(?:OK)\z/ni + return resp when /\A(?:NO)\z/ni raise NoResponseError, resp when /\A(?:BAD)\z/ni raise BadResponseError, resp else - return resp + raise UnknownResponseError, resp end end @@ -3719,6 +3721,10 @@ module Net class ByeResponseError < ResponseError end + # Error raised upon an unknown response from the server. + class UnknownResponseError < ResponseError + end + RESPONSE_ERRORS = Hash.new(ResponseError) RESPONSE_ERRORS["NO"] = NoResponseError RESPONSE_ERRORS["BAD"] = BadResponseError |