Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- just in case this project page changes again, here is the last capture we could get.
- projects / openssl.git / commitdiff
- summary | shortlog | log | commit | commitdiff | tree
- raw | patch | inline | side by side (parent: 0d7717f)
- Add heartbeat extension bounds check.
- author Dr. Stephen Henson <[email protected]>
- Sat, 5 Apr 2014 19:51:06 -0400 (00:51 +0100)
- committer Dr. Stephen Henson <[email protected]>
- Mon, 7 Apr 2014 12:53:31 -0400 (17:53 +0100)
- A missing bounds check in the handling of the TLS heartbeat extension
- can be used to reveal up to 64k of memory to a connected client or
- server.
- Thanks for Neel Mehta of Google Security for discovering this bug and to
- Adam Langley <[email protected]> and Bodo Moeller <[email protected]> for
- preparing the fix (CVE-2014-0160)
- CHANGES patch | blob | history
- ssl/d1_both.c patch | blob | history
- ssl/t1_lib.c patch | blob | history
- diff --git a/CHANGES b/CHANGES
- index 0484456..08abe8d 100644 (file)
- --- a/CHANGES
- +++ b/CHANGES
- @@ -4,6 +4,15 @@
- Changes between 1.0.1f and 1.0.1g [xx XXX xxxx]
- + *) A missing bounds check in the handling of the TLS heartbeat extension
- + can be used to reveal up to 64k of memory to a connected client or
- + server.
- ++
- Thanks for Neel Mehta of Google Security for discovering this bug and to
- + Adam Langley <[email protected]> and Bodo Moeller <[email protected]> for
- + preparing the fix (CVE-2014-0160)
- + [Adam Langley, Bodo Moeller]
- +
- *) Fix for the attack described in the paper "Recovering OpenSSL
- ECDSA Nonces Using the FLUSH+RELOAD Cache Side-channel Attack"
- Do you need professional PDFs? Try PDFmyURL!
- by Yuval Yarom and Naomi Benger. Details can be obtained from:
- diff --git a/ssl/d1_both.c b/ssl/d1_both.c
- index 7a5596a..2e8cf68 100644 (file)
- --- a/ssl/d1_both.c
- +++ b/ssl/d1_both.c
- @@ -1459,26 +1459,36 @@ dtls1_process_heartbeat(SSL *s)
- unsigned int payload;
- unsigned int padding = 16; /* Use minimum padding */
- - /* Read type and payload length first */
- - hbtype = *p++;
- - n2s(p, payload);
- - pl = p;
- -
- if (s->msg_callback)
- s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT,
- &s->s3->rrec.data[0], s->s3->rrec.length,
- s, s->msg_callback_arg);
- + /* Read type and payload length first */
- + if (1 + 2 + 16 > s->s3->rrec.length)
- + return 0; /* silently discard */
- + hbtype = *p++;
- + n2s(p, payload);
- + if (1 + 2 + payload + 16 > s->s3->rrec.length)
- + return 0; /* silently discard per RFC 6520 sec. 4 */
- + pl = p;
- +
- if (hbtype == TLS1_HB_REQUEST)
- {
- unsigned char *buffer, *bp;
- + unsigned int write_length = 1 /* heartbeat type */ +
- + 2 /* heartbeat length */ +
- + payload + padding;
- int r;
- + if (write_length > SSL3_RT_MAX_PLAIN_LENGTH)
- + return 0;
- +
- /* Allocate memory for the response, size is 1 byte
- * message type, plus 2 bytes payload length, plus
- * payload, plus padding
- */
- - buffer = OPENSSL_malloc(1 + 2 + payload + padding);
- + buffer = OPENSSL_malloc(write_length);
- bp = buffer;
- /* Enter response type, length and copy payload */
- @@ -1489,11 +1499,11 @@ dtls1_process_heartbeat(SSL *s)
- /* Random padding */
- RAND_pseudo_bytes(bp, padding);
- Do you need professional PDFs? Try PDFmyURL!
- OpenSSL source code Atom RSS
- - r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, 3 + payload + padding);
- + r = dtls1_write_bytes(s, TLS1_RT_HEARTBEAT, buffer, write_length);
- if (r >= 0 && s->msg_callback)
- s->msg_callback(1, s->version, TLS1_RT_HEARTBEAT,
- - buffer, 3 + payload + padding,
- + buffer, write_length,
- s, s->msg_callback_arg);
- OPENSSL_free(buffer);
- diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
- index b82fada..bddffd9 100644 (file)
- --- a/ssl/t1_lib.c
- +++ b/ssl/t1_lib.c
- @@ -2588,16 +2588,20 @@ tls1_process_heartbeat(SSL *s)
- unsigned int payload;
- unsigned int padding = 16; /* Use minimum padding */
- - /* Read type and payload length first */
- - hbtype = *p++;
- - n2s(p, payload);
- - pl = p;
- -
- if (s->msg_callback)
- s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT,
- &s->s3->rrec.data[0], s->s3->rrec.length,
- s, s->msg_callback_arg);
- + /* Read type and payload length first */
- + if (1 + 2 + 16 > s->s3->rrec.length)
- + return 0; /* silently discard */
- + hbtype = *p++;
- + n2s(p, payload);
- + if (1 + 2 + payload + 16 > s->s3->rrec.length)
- + return 0; /* silently discard per RFC 6520 sec. 4 */
- + pl = p;
- +
- if (hbtype == TLS1_HB_REQUEST)
- {
- unsigned char *buffer, *bp;
Add Comment
Please, Sign In to add comment