summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2016-11-26apps/speed.c: Fix crash when config loading failsOpenSSL_1_0_1-stableVitezslav Cizek
Move rsa_key initialization in front of load_config(). If loading the config fails, rsa_key isn't initialized and may cause invalid free() in the end: cleanup. Remove superfluous memset. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit c003851783ed05e3fd5296786e1f8f6a63dc4f31)
2016-11-25modes/ctr128.c: fix false carry in counter increment procedure.Andy Polyakov
GH issue #1916 affects only big-endian platforms. TLS is not affected, because TLS fragment is never big enough. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 76f572ed0469a277d92378848250b7a9705d3071)
2016-11-04Missed a mention of RTRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1849) (cherry picked from commit 1e62cc12f35408508594be254f40bf9b65d2a3a9)
2016-11-02Secure our notification email.Richard Levitte
Forks will have to define their own Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1821) (cherry picked from commit 5e28b1c1e048eef600dc49820934a5e1531186d4)
2016-11-01Fix grammar-o in CONTRIBUTINGBenjamin Kaduk
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1625) (cherry picked from commit e4d94269a5a41594852dc60716500580f1d47cef)
2016-10-25Fix leak of secrecy in ecdh_compute_key()Dr. Matthias St. Pierre
A temporary buffer containing g^xy was not cleared in ecdh_compute_key() before freeing it, so the shared secret was leaked in memory. Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 0e4690165b4beb6777b747b0aeb1646a301f41d9)
2016-10-14Degrade 3DES to MEDIUM in SSL2Vitezslav Cizek
The SWEET32 fix moved 3DES from HIGH to MEDIUM, but omitted SSL2. CLA: trivial Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1683) (cherry picked from commit 6d69dc56de8f0535be9ccabea7a8d4e61c04c2f1)
2016-10-13RT is put out to pastureRich Salz
Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1702) (cherry picked from commit 7954dced19a7e59e7055eab95a981fa943c7d100)
2016-09-22Prepare for 1.0.1v-devMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22Prepare for 1.0.1u releaseOpenSSL_1_0_1uMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22Updates CHANGES and NEWS for new releaseMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22Avoid KCI attack for GOSTDmitry Belyavsky
Russian GOST ciphersuites are vulnerable to the KCI attack because they use long-term keys to establish the connection when ssl client authorization is on. This change brings the GOST implementation into line with the latest specs in order to avoid the attack. It should not break backwards compatibility. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-22Fix OCSP Status Request extension unbounded memory growthMatt Caswell
A malicious client can send an excessively large OCSP Status Request extension. If that client continually requests renegotiation, sending a large OCSP Status Request extension each time, then there will be unbounded memory growth on the server. This will eventually lead to a Denial Of Service attack through memory exhaustion. Servers with a default configuration are vulnerable even if they do not support OCSP. Builds using the "no-ocsp" build time option are not affected. I have also checked other extensions to see if they suffer from a similar problem but I could not find any other issues. CVE-2016-6304 Issue reported by Shi Lei. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-21update default dependency optionsDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-21Make message buffer slightly larger than message.Dr. Stephen Henson
Grow TLS/DTLS 16 bytes more than strictly necessary as a precaution against OOB reads. In most cases this will have no effect because the message buffer will be large enough already. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 006a788c84e541c8920dd2ad85fb62b52185c519)
2016-09-21Use SSL3_HM_HEADER_LENGTH instead of 4.Dr. Stephen Henson
Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit bc9563f83d28342b5ec0073ec12d9e581e4f3317)
2016-09-21Remove unnecessary check.Dr. Stephen Henson
The overflow check will never be triggered because the the n2l3 result is always less than 2^24. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 709ec8b3848e2ac201b86f49c5561debb8572ccd)
2016-09-21Fix small OOB reads.Dr. Stephen Henson
In ssl3_get_client_certificate, ssl3_get_server_certificate and ssl3_get_certificate_request check we have enough room before reading a length. Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting these bugs. CVE-2016-6306 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit ff553f837172ecb2b5c8eca257ec3c5619a4b299)
2016-08-26Fix SSL_export_keying_material() for DTLS1_BAD_VERDavid Woodhouse
Commit d8e8590e ("Fix missing return value checks in SCTP") made the DTLS handshake fail, even for non-SCTP connections, if SSL_export_keying_material() fails. Which it does, for DTLS1_BAD_VER. Apply the trivial fix to make it succeed, since there's no real reason why it shouldn't even though we never need it. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit c8a18468caef4d62778381be0acdadc8a88d6e51)
2016-08-24Avoid overflow in MDC2_Update()Dr. Stephen Henson
Thanks to Shi Lei for reporting this issue. CVE-2016-6303 Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 55d83bf7c10c7b205fffa23fa7c3977491e56c07)
2016-08-24SWEET32 (CVE-2016-2183): Move DES from HIGH to MEDIUMRich Salz
Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 0fff5065884d5ac61123a604bbcee30a53c808ff)
2016-08-23Sanity check ticket length.Dr. Stephen Henson
If a ticket callback changes the HMAC digest to SHA512 the existing sanity checks are not sufficient and an attacker could perform a DoS attack with a malformed ticket. Add additional checks based on HMAC size. Thanks to Shi Lei for reporting this bug. CVE-2016-6302 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit baaabfd8fdcec04a691695fad9a664bea43202b6)
2016-08-22Fix overflow check in BN_bn2dec()Kazuki Yamaguchi
Fix an off by one error in the overflow check added by 07bed46f332fc ("Check for errors in BN_bn2dec()"). Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 099e2968ed3c7d256cda048995626664082b1b30)
2016-08-22Prevent DTLS Finished message injectionMatt Caswell
Follow on from CVE-2016-2179 The investigation and analysis of CVE-2016-2179 highlighted a related flaw. This commit fixes a security "near miss" in the buffered message handling code. Ultimately this is not currently believed to be exploitable due to the reasons outlined below, and therefore there is no CVE for this on its own. The issue this commit fixes is a MITM attack where the attacker can inject a Finished message into the handshake. In the description below it is assumed that the attacker injects the Finished message for the server to receive it. The attack could work equally well the other way around (i.e where the client receives the injected Finished message). The MITM requires the following capabilities: - The ability to manipulate the MTU that the client selects such that it is small enough for the client to fragment Finished messages. - The ability to selectively drop and modify records sent from the client - The ability to inject its own records and send them to the server The MITM forces the client to select a small MTU such that the client will fragment the Finished message. Ideally for the attacker the first fragment will contain all but the last byte of the Finished message, with the second fragment containing the final byte. During the handshake and prior to the client sending the CCS the MITM injects a plaintext Finished message fragment to the server containing all but the final byte of the Finished message. The message sequence number should be the one expected to be used for the real Finished message. OpenSSL will recognise that the received fragment is for the future and will buffer it for later use. After the client sends the CCS it then sends its own Finished message in two fragments. The MITM causes the first of these fragments to be dropped. The OpenSSL server will then receive the second of the fragments and reassemble the complete Finished message consisting of the MITM fragment and the final byte from the real client. The advantage to the attacker in injecting a Finished message is that this provides the capability to modify other handshake messages (e.g. the ClientHello) undetected. A difficulty for the attacker is knowing in advance what impact any of those changes might have on the final byte of the handshake hash that is going to be sent in the "real" Finished message. In the worst case for the attacker this means that only 1 in 256 of such injection attempts will succeed. It may be possible in some situations for the attacker to improve this such that all attempts succeed. For example if the handshake includes client authentication then the final message flight sent by the client will include a Certificate. Certificates are ASN.1 objects where the signed portion is DER encoded. The non-signed portion could be BER encoded and so the attacker could re-encode the certificate such that the hash for the whole handshake comes to a different value. The certificate re-encoding would not be detectable because only the non-signed portion is changed. As this is the final flight of messages sent from the client the attacker knows what the complete hanshake hash value will be that the client will send - and therefore knows what the final byte will be. Through a process of trial and error the attacker can re-encode the certificate until the modified handhshake also has a hash with the same final byte. This means that when the Finished message is verified by the server it will be correct in all cases. In practice the MITM would need to be able to perform the same attack against both the client and the server. If the attack is only performed against the server (say) then the server will not detect the modified handshake, but the client will and will abort the connection. Fortunately, although OpenSSL is vulnerable to Finished message injection, it is not vulnerable if *both* client and server are OpenSSL. The reason is that OpenSSL has a hard "floor" for a minimum MTU size that it will never go below. This minimum means that a Finished message will never be sent in a fragmented form and therefore the MITM does not have one of its pre-requisites. Therefore this could only be exploited if using OpenSSL and some other DTLS peer that had its own and separate Finished message injection flaw. The fix is to ensure buffered messages are cleared on epoch change. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-22Fix DTLS buffered message DoS attackMatt Caswell
DTLS can handle out of order record delivery. Additionally since handshake messages can be bigger than will fit into a single packet, the messages can be fragmented across multiple records (as with normal TLS). That means that the messages can arrive mixed up, and we have to reassemble them. We keep a queue of buffered messages that are "from the future", i.e. messages we're not ready to deal with yet but have arrived early. The messages held there may not be full yet - they could be one or more fragments that are still in the process of being reassembled. The code assumes that we will eventually complete the reassembly and when that occurs the complete message is removed from the queue at the point that we need to use it. However, DTLS is also tolerant of packet loss. To get around that DTLS messages can be retransmitted. If we receive a full (non-fragmented) message from the peer after previously having received a fragment of that message, then we ignore the message in the queue and just use the non-fragmented version. At that point the queued message will never get removed. Additionally the peer could send "future" messages that we never get to in order to complete the handshake. Each message has a sequence number (starting from 0). We will accept a message fragment for the current message sequence number, or for any sequence up to 10 into the future. However if the Finished message has a sequence number of 2, anything greater than that in the queue is just left there. So, in those two ways we can end up with "orphaned" data in the queue that will never get removed - except when the connection is closed. At that point all the queues are flushed. An attacker could seek to exploit this by filling up the queues with lots of large messages that are never going to be used in order to attempt a DoS by memory exhaustion. I will assume that we are only concerned with servers here. It does not seem reasonable to be concerned about a memory exhaustion attack on a client. They are unlikely to process enough connections for this to be an issue. A "long" handshake with many messages might be 5 messages long (in the incoming direction), e.g. ClientHello, Certificate, ClientKeyExchange, CertificateVerify, Finished. So this would be message sequence numbers 0 to 4. Additionally we can buffer up to 10 messages in the future. Therefore the maximum number of messages that an attacker could send that could get orphaned would typically be 15. The maximum size that a DTLS message is allowed to be is defined by max_cert_list, which by default is 100k. Therefore the maximum amount of "orphaned" memory per connection is 1500k. Message sequence numbers get reset after the Finished message, so renegotiation will not extend the maximum number of messages that can be orphaned per connection. As noted above, the queues do get cleared when the connection is closed. Therefore in order to mount an effective attack, an attacker would have to open many simultaneous connections. Issue reported by Quan Luo. CVE-2016-2179 Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-20Fix off by 1 in ASN1_STRING_set()Kurt Roeckx
Reviewed-by: Rich Salz <rsalz@openssl.org> MR: #3176 (cherry picked from commit a73be798ced572a988d455d961a2387f6eccb549)
2016-08-19RT3940: For now, just document the issue.Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit 2a9afa4046592d44af84644cd89fe1a0d6d46889)
2016-08-19Update function error codeMatt Caswell
A function error code needed updating due to merge issues. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-19Fix DTLS replay protectionMatt Caswell
The DTLS implementation provides some protection against replay attacks in accordance with RFC6347 section 4.1.2.6. A sliding "window" of valid record sequence numbers is maintained with the "right" hand edge of the window set to the highest sequence number we have received so far. Records that arrive that are off the "left" hand edge of the window are rejected. Records within the window are checked against a list of records received so far. If we already received it then we also reject the new record. If we have not already received the record, or the sequence number is off the right hand edge of the window then we verify the MAC of the record. If MAC verification fails then we discard the record. Otherwise we mark the record as received. If the sequence number was off the right hand edge of the window, then we slide the window along so that the right hand edge is in line with the newly received sequence number. Records may arrive for future epochs, i.e. a record from after a CCS being sent, can arrive before the CCS does if the packets get re-ordered. As we have not yet received the CCS we are not yet in a position to decrypt or validate the MAC of those records. OpenSSL places those records on an unprocessed records queue. It additionally updates the window immediately, even though we have not yet verified the MAC. This will only occur if currently in a handshake/renegotiation. This could be exploited by an attacker by sending a record for the next epoch (which does not have to decrypt or have a valid MAC), with a very large sequence number. This means the right hand edge of the window is moved very far to the right, and all subsequent legitimate packets are dropped causing a denial of service. A similar effect can be achieved during the initial handshake. In this case there is no MAC key negotiated yet. Therefore an attacker can send a message for the current epoch with a very large sequence number. The code will process the record as normal. If the hanshake message sequence number (as opposed to the record sequence number that we have been talking about so far) is in the future then the injected message is bufferred to be handled later, but the window is still updated. Therefore all subsequent legitimate handshake records are dropped. This aspect is not considered a security issue because there are many ways for an attacker to disrupt the initial handshake and prevent it from completing successfully (e.g. injection of a handshake message will cause the Finished MAC to fail and the handshake to be aborted). This issue comes about as a result of trying to do replay protection, but having no integrity mechanism in place yet. Does it even make sense to have replay protection in epoch 0? That issue isn't addressed here though. This addressed an OCAP Audit issue. CVE-2016-2181 Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-19Fix DTLS unprocessed records bugMatt Caswell
During a DTLS handshake we may get records destined for the next epoch arrive before we have processed the CCS. In that case we can't decrypt or verify the record yet, so we buffer it for later use. When we do receive the CCS we work through the queue of unprocessed records and process them. Unfortunately the act of processing wipes out any existing packet data that we were still working through. This includes any records from the new epoch that were in the same packet as the CCS. We should only process the buffered records if we've not got any data left. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-16make update to have PEM_R_HEADER_TOO_LONG definedRichard Levitte
(cherry picked from commit a1be17a72f6e0fe98275dc113cddd799bf55df44) Conflicts: crypto/pem/pem_err.c Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Stephen Henson <steve@openssl.org>
2016-08-16Limit reads in do_b2i_bio()Dr. Stephen Henson
Apply a limit to the maximum blob length which can be read in do_d2i_bio() to avoid excessive allocation. Thanks to Shi Lei for reporting this. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 66bcba145740e4f1210499ba6e5033035a2a4647)
2016-08-16Check for errors in BN_bn2dec()Dr. Stephen Henson
If an oversize BIGNUM is presented to BN_bn2dec() it can cause BN_div_word() to fail and not reduce the value of 't' resulting in OOB writes to the bn_data buffer and eventually crashing. Fix by checking return value of BN_div_word() and checking writes don't overflow buffer. Thanks to Shi Lei for reporting this bug. CVE-2016-2182 Reviewed-by: Tim Hudson <tjh@openssl.org> (cherry picked from commit 07bed46f332fce8c1d157689a2cdf915a982ae34) Conflicts: crypto/bn/bn_print.c
2016-08-16Check for errors in a2d_ASN1_OBJECT()Dr. Stephen Henson
Check for error return in BN_div_word(). Reviewed-by: Tim Hudson <tjh@openssl.org> (cherry picked from commit 8b9afbc0fc7f8be0049d389d34d9416fa377e2aa)
2016-08-05Sanity check input length in OPENSSL_uni2asc().Dr. Stephen Henson
Thanks to Hanno Böck for reporting this bug. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 39a43280316f1b9c45be5ac5b04f4f5c3f923686) Conflicts: crypto/pkcs12/p12_utl.c
2016-08-05Leak fixes.Dr. Stephen Henson
Fix error path leaks in a2i_ASN1_STRING(), a2i_ASN1_INTEGER() and a2i_ASN1_ENUMERATED(). Thanks to Shi Lei for reporting these issues. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit e1be1dce7722ee40ced16b1b91d5e1b9fce13d08)
2016-08-04Return error when trying to print invalid ASN1 integerKurt Roeckx
GH: #1322 Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Stephen Henson <steve@openssl.org> (cherry picked from commit 32baafb2f6fb2a424824df08232d86765f554880)
2016-08-04Limit recursion depth in old d2i_ASN1_bytes functionDr. Stephen Henson
Thanks to Shi Lei for reporting this bug. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 81f69e5b69b8e87ca5d7080ab643ebda7808542c)
2016-08-04Check for overflows in i2d_ASN1_SET()Dr. Stephen Henson
Thanks to Shi Lei for reporting this issue. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit af601b83198771a4ad54ac0f415964b90aab4b5f)
2016-08-03Calculate sequence length properly.Dr. Stephen Henson
Use correct length in old ASN.1 indefinite length sequence decoder (only used by SSL_SESSION). This bug was discovered by Hanno Böck using libfuzzer. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 436dead2e2a157fa501a7538a77b6078391b477f)
2016-08-03include <limits.h>Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 134ab5139a8d41455a81d9fcc31b3edb8a4b2f5c)
2016-08-02Check for overflows in ASN1_object_size().Dr. Stephen Henson
Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit e9f17097e9fbba3e7664cd67e54eebf2bd438863)
2016-08-02Check for overlows and error return from ASN1_object_size()Dr. Stephen Henson
Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit 56f9953c846204cb3251ab27605e403c7444fd72)
2016-07-22Fix OOB read in TS_OBJ_print_bio().Dr. Stephen Henson
TS_OBJ_print_bio() misuses OBJ_txt2obj: it should print the result as a null terminated buffer. The length value returned is the total length the complete text reprsentation would need not the amount of data written. CVE-2016-2180 Thanks to Shi Lei for reporting this bug. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 0ed26acce328ec16a3aa635f1ca37365e8c7403a)
2016-06-30Convert memset calls to OPENSSL_cleanseMatt Caswell
Ensure things really do get cleared when we intend them to. Addresses an OCAP Audit issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit cb5ebf961333896776fbce10ef88c2af7bec8aea)
2016-06-30Allow proxy certs to be present when verifying a chainRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 6ad8c48291622a6ccc51489b9a230c9a05ca5614)
2016-06-30Fix proxy certificate pathlength verificationRichard Levitte
While travelling up the certificate chain, the internal proxy_path_length must be updated with the pCPathLengthConstraint value, or verification will not work properly. This corresponds to RFC 3820, 4.1.4 (a). Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 30aeb3128199c15760a785d88a4eda9e156d5af6)
2016-06-30Check that the subject name in a proxy cert complies to RFC 3820Richard Levitte
The subject name MUST be the same as the issuer name, with a single CN entry added. RT#1852 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 338fb1688fbfb7efe0bdd475b01791a6de5ef94b)
2016-06-27Change usage of RAND_pseudo_bytes to RAND_bytesMatt Caswell
RAND_pseudo_bytes() allows random data to be returned even in low entropy conditions. Sometimes this is ok. Many times it is not. For the avoidance of any doubt, replace existing usage of RAND_pseudo_bytes() with RAND_bytes(). Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-06-07More fix DSA, preserve BN_FLG_CONSTTIMEMatt Caswell
The previous "fix" still left "k" exposed to constant time problems in the later BN_mod_inverse() call. Ensure both k and kq have the BN_FLG_CONSTTIME flag set at the earliest opportunity after creation. CVE-2016-2178 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit b7d0f2834e139a20560d64c73e2565e93715ce2b)