Commit graph

1251 commits

Author SHA1 Message Date
Matt Caswell
679d0c8655 Fixed out-of-bounds read errors in ssl3_get_key_exchange.
PR#3450

Conflicts:
	ssl/s3_clnt.c

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-15 23:30:11 +01:00
Gabor Tyukasz
03a12c1330 Fix race condition in ssl_parse_serverhello_tlsext
CVE-2014-3509
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-08-06 21:30:39 +01:00
Emilia Käsper
9fd3555305 Fix DTLS anonymous EC(DH) denial of service
CVE-2014-3510

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2014-08-06 21:30:39 +01:00
David Benjamin
67e53f73bf Fix protocol downgrade bug in case of fragmented packets
CVE-2014-3511

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Bodo Möller <bodo@openssl.org>
2014-08-06 21:30:39 +01:00
Adam Langley
2281d10a7b Remove some duplicate DTLS code.
In a couple of functions, a sequence number would be calculated twice.

Additionally, in |dtls1_process_out_of_seq_message|, we know that
|frag_len| <= |msg_hdr->msg_len| so the later tests for |frag_len <
msg_hdr->msg_len| can be more clearly written as |frag_len !=
msg_hdr->msg_len|, since that's the only remaining case.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Matt Caswell
e5861c885f Applying same fix as in dtls1_process_out_of_seq_message. A truncated DTLS fragment would cause *ok to be clear, but the return value would still be the number of bytes read.
Problem identified by Emilia Käsper, based on previous issue/patch by Adam
Langley.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Adam Langley
60be115771 Fix return code for truncated DTLS fragment.
Previously, a truncated DTLS fragment in
|dtls1_process_out_of_seq_message| would cause *ok to be cleared, but
the return value would still be the number of bytes read. This would
cause |dtls1_get_message| not to consider it an error and it would
continue processing as normal until the calling function noticed that
*ok was zero.

I can't see an exploit here because |dtls1_get_message| uses
|s->init_num| as the length, which will always be zero from what I can
see.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Adam Langley
5ee775a4a5 Fix memory leak from zero-length DTLS fragments.
The |pqueue_insert| function can fail if one attempts to insert a
duplicate sequence number. When handling a fragment of an out of
sequence message, |dtls1_process_out_of_seq_message| would not call
|dtls1_reassemble_fragment| if the fragment's length was zero. It would
then allocate a fresh fragment and attempt to insert it, but ignore the
return value, leaking the fragment.

This allows an attacker to exhaust the memory of a DTLS peer.

Fixes CVE-2014-3507

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Matt Caswell
934ca0714a Fix DTLS handshake message size checks.
In |dtls1_reassemble_fragment|, the value of
|msg_hdr->frag_off+frag_len| was being checked against the maximum
handshake message size, but then |msg_len| bytes were allocated for the
fragment buffer. This means that so long as the fragment was within the
allowed size, the pending handshake message could consume 16MB + 2MB
(for the reassembly bitmap). Approx 10 outstanding handshake messages
are allowed, meaning that an attacker could consume ~180MB per DTLS
connection.

In the non-fragmented path (in |dtls1_process_out_of_seq_message|), no
check was applied.

Fixes CVE-2014-3506

Wholly based on patch by Adam Langley with one minor amendment.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Matt Caswell
ad007e0aaf Added comment for the frag->reassembly == NULL case as per feedback from Emilia
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Adam Langley
84361b898d Avoid double free when processing DTLS packets.
The |item| variable, in both of these cases, may contain a pointer to a
|pitem| structure within |s->d1->buffered_messages|. It was being freed
in the error case while still being in |buffered_messages|. When the
error later caused the |SSL*| to be destroyed, the item would be double
freed.

Thanks to Wah-Teh Chang for spotting that the fix in 1632ef74 was
inconsistent with the other error paths (but correct).

Fixes CVE-2014-3505

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2014-08-06 21:30:39 +01:00
Dr. Stephen Henson
c3f2fc419b Fix DTLS certificate requesting code.
Use same logic when determining when to expect a client
certificate for both TLS and DTLS.

PR#3452
(cherry picked from commit c8d710dc5f)
2014-07-15 18:23:52 +01:00
Dr. Stephen Henson
ec9cb40da5 Add ECC extensions with DTLS.
PR#3449
(cherry picked from commit 2054eb771e)
2014-07-15 12:29:20 +01:00
Dr. Stephen Henson
26d60e29e3 Use more common name for GOST key exchange.
(cherry picked from commit 7aabd9c92fe6f0ea2a82869e5171dcc4518cee85)
2014-07-14 18:31:54 +01:00
Peter Mosmans
f7123634a5 Add names of GOST algorithms.
PR#3440
(cherry picked from commit 924e5eda2c)

Conflicts:

	ssl/ssl_ciph.c
2014-07-13 18:35:14 +01:00
Dr. Stephen Henson
4054d95eb9 Don't limit message sizes in ssl3_get_cert_verify.
PR#319 (reoponed version).
(cherry picked from commit 7f6e957864)

Conflicts:

	ssl/s3_srvr.c
2014-07-05 13:31:53 +01:00
Thijs Alkemade
ce20ac72b4 Make disabling last cipher work.
(cherry picked from commit 7cb472bd0d)
2014-07-02 03:33:12 +01:00
Dr. Stephen Henson
59899c4d1b Fix memory leak.
PR#2531.
2014-06-29 13:53:06 +01:00
Dr. Stephen Henson
2617a3c44d Don't disable state strings with no-ssl2
Some state strings were erronously not compiled when no-ssl2
was set.

PR#3295
(cherry picked from commit 0518a3e19e)
2014-06-28 00:56:59 +01:00
Ken Ballou
e617a506ff Remove redundant check.
PR#3174
(cherry picked from commit fd331c0bb9b557903dd2ce88398570a3327b5ef0)
2014-06-27 23:18:25 +01:00
Tomas Mraz
d9d5a12823 Don't advertise ECC ciphersuits in SSLv2 compatible client hello.
PR#3374
(cherry picked from commit 0436369fcc)
2014-06-27 16:52:10 +01:00
Miod Vallat
532ee6e056 Fix off-by-one errors in ssl_cipher_get_evp()
In the ssl_cipher_get_evp() function, fix off-by-one errors in index validation before accessing arrays.

Bug discovered and fixed by Miod Vallat from the OpenBSD team.

PR#3375
2014-06-22 23:22:49 +01:00
Matt Caswell
08db2cc9c1 Revert "Fix off-by-one errors in ssl_cipher_get_evp()"
This reverts commit 7e98378d15.

Incorrect attribution.
2014-06-22 23:22:33 +01:00
Dr. Stephen Henson
f25e4263fe Accept CCS after sending finished.
Allow CCS after finished has been sent by client: at this point
keys have been correctly set up so it is OK to accept CCS from
server. Without this renegotiation can sometimes fail.

PR#3400
(cherry picked from commit 99cd6a91fcb0931feaebbb4832681d40a66fad41)
2014-06-14 22:26:31 +01:00
Matt Caswell
2dc967ddd0 Fixed incorrect return code handling in ssl3_final_finish_mac.
Based on an original patch by Joel Sing (OpenBSD) who also originally identified the issue.
2014-06-13 15:56:19 +01:00
Matt Caswell
a357acdd3b Revert "Fixed incorrect return code handling in ssl3_final_finish_mac"
This reverts commit e05282f8b0.

Missing attribution.
2014-06-13 15:55:57 +01:00
Kurt Cancemi
7e98378d15 Fix off-by-one errors in ssl_cipher_get_evp()
In the ssl_cipher_get_evp() function, fix off-by-one errors in index validation before accessing arrays.

PR#3375
2014-06-12 21:17:30 +01:00
Ben Laurie
d663f506dc Allow the maximum value.
(Backported as a result of PR#3377 reported by Rainer Jung <rainer.jung@kippdata.de>)
2014-06-12 20:48:40 +01:00
Matt Caswell
e05282f8b0 Fixed incorrect return code handling in ssl3_final_finish_mac 2014-06-10 23:29:53 +01:00
Dr. Stephen Henson
34b087c9d0 Fix null pointer errors.
PR#3394
(cherry picked from commit 7a9d59c148)
2014-06-10 14:48:12 +01:00
Dr. Stephen Henson
9f81028969 Update strength_bits for 3DES.
Fix strength_bits to 112 for 3DES.
2014-06-09 12:09:47 +01:00
Dr. Stephen Henson
e966578d2f Make tls_session_secret_cb work with CVE-2014-0224 fix.
If application uses tls_session_secret_cb for session resumption
set the CCS_OK flag.
(cherry picked from commit 953c592572e8811b7956cc09fbd8e98037068b58)
2014-06-07 15:27:21 +01:00
Matt Caswell
ccb0398da6 Fixed Windows compilation failure 2014-06-05 20:24:36 +01:00
Dr. Stephen Henson
8250e1b232 Fix CVE-2014-3470
Check session_cert is not NULL before dereferencing it.
2014-06-03 16:30:37 +01:00
Dr. Stephen Henson
519c977c47 Fix CVE-2014-0221
Unnecessary recursion when receiving a DTLS hello request can be used to
crash a DTLS client. Fixed by handling DTLS hello request without recursion.

Thanks to Imre Rad (Search-Lab Ltd.) for discovering this issue.
2014-06-03 16:30:37 +01:00
Dr. Stephen Henson
123370fb94 Additional CVE-2014-0224 protection.
Return a fatal error if an attempt is made to use a zero length
master secret.
2014-06-03 16:30:37 +01:00
Dr. Stephen Henson
c97e457d53 Fix for CVE-2014-0224
Only accept change cipher spec when it is expected instead of at any
time. This prevents premature setting of session keys before the master
secret is determined which an attacker could use as a MITM attack.

Thanks to KIKUCHI Masashi (Lepidum Co. Ltd.) for reporting this issue
and providing the initial fix this patch is based on.
2014-06-03 16:30:37 +01:00
Dr. Stephen Henson
f4e6ed09e4 Fix for CVE-2014-0195
A buffer overrun attack can be triggered by sending invalid DTLS fragments
to an OpenSSL DTLS client or server. This is potentially exploitable to
run arbitrary code on a vulnerable client or server.

Fixed by adding consistency check for DTLS fragments.

Thanks to Jüri Aedla for reporting this issue.
2014-06-03 16:30:37 +01:00
zhu qun-ying
b79e6e3a27 Free up s->d1->buffered_app_data.q properly.
PR#3286
(cherry picked from commit 71e95000afb2227fe5cac1c79ae884338bcd8d0b)
2014-06-02 14:40:32 +01:00
Sami Farin
bffbaf92bf Typo: set i to -1 before goto.
PR#3302
(cherry picked from commit 9717f01951f976f76dd40a38d9fc7307057fa4c4)
2014-06-02 13:53:51 +01:00
Matt Caswell
5aca5d41c0 Added SSLErr call for internal error in dtls1_buffer_record 2014-06-01 21:43:51 +01:00
David Ramos
8343e6b6b2 Delays the queue insertion until after the ssl3_setup_buffers() call due to use-after-free bug. PR#3362 2014-06-01 21:42:47 +01:00
David Ramos
268ae49453 Allocate extra space when NETSCAPE_HANG_BUG defined.
Make sure there is an extra 4 bytes for server done message when
NETSCAPE_HANG_BUG is defined.

PR#3361
(cherry picked from commit 673c42b238)
2014-06-01 14:31:30 +01:00
Ben Laurie
c01a838d62 Fix signed/unsigned warning.
(cherry picked from commit 989d87cb1a)
2014-05-29 14:12:13 +01:00
Matt Caswell
44f28dd1e6 Fix for non compilation with TLS_DEBUG defined 2014-05-24 23:59:24 +01:00
Kurt Roeckx
365e872fa1 Check sk_SSL_CIPHER_num() after assigning sk. 2014-05-12 23:05:19 +01:00
Serguei E. Leontiev
f7c4fe519b Replace manual ASN1 decoder with ASN1_get_object
Replace manual ASN.1 decoder with ASN1_get object. This
will decode the tag and length properly and check against
it does not exceed the supplied buffer length.

PR#3335
(cherry picked from commit b0308dddd1cc6a8e1de803ef29ba6da25ee072c2)
2014-05-12 18:41:49 +01:00
Matt Caswell
92c2c6e88c Fixed NULL pointer dereference. See PR#3321 2014-05-12 00:48:17 +01:00
Günther Noack
12cbba0d54 Avoid out-of-bounds write in SSL_get_shared_ciphers
PR: 3317
2014-05-11 23:59:38 +01:00
Tim Hudson
0552cbcdaa safety check to ensure we dont send out beyond the users buffer 2014-05-11 13:33:57 +01:00