{"push_id":744783969,"size":1,"distinct_size":1,"ref":"refs/heads/release/2.3","head":"338f11821fa7ce95c768b0cc074f3af7346b19fa","before":"57576475f5d6e5dd9cdb64fa0edcf283ce4a05c9","commits":[{"sha":"338f11821fa7ce95c768b0cc074f3af7346b19fa","author":{"email":"80facfc4657f5ce127b055e847f97345ac717798@fox-it.com","name":"Steffan Karger"},"message":"Fix overflow check in openvpn_decrypt()\n\nSebastian Krahmer from the SuSE security team reported that the buffer\noverflow check in openvpn_decrypt() was too strict according to the\ncipher update function contract:\n\n\"The amount of data written depends on the block alignment of the\nencrypted data: as a result the amount of data written may be anything\nfrom zero bytes to (inl + cipher_block_size - 1) so outl should contain\nsufficient room.\"\n\nThis stems from the way CBC mode works, which caches input and 'flushes'\nit block-wise to the output buffer.  We do allocate enough space for this\nextra block in the output buffer for CBC mode, but not for CFB/OFB modes.\n\nThis patch:\n * updates the overflow check to also verify that the extra block required\n   according to the function contract is available.\n * uses buf_inc_len() to double-check for overflows during en/decryption.\n * also reserves the extra block for non-CBC cipher modes.\n\nIn practice, I could not find a way in which this would fail. The plaintext\nis never longer than the ciphertext, and the implementations of CBC/OFB/CBC\nfor AES and BF in both OpenSSL and PolarSSL/mbed TLS do not use the buffer\nbeyond the plaintext length when decrypting.  However, some funky OpenSSL\nengine I did not check *might* use the buffer space required by the\nfunction contract.  So we should still make sure we have enough room\nanyway.\n\nv2 - always ASSERT() on buf_inc_len().  It is a double-check so should\n     really not fail, but if it fails there has been a buffer overflow.\n     At that point the best thing we can do is assert out. (The primary\n     check *is* handled gracefully, and just drops the packet.)\n\nSigned-off-by: Steffan Karger <steffan.karger@fox-it.com>\nAcked-by: Arne Schwabe <arne@rfc2549.org>\nMessage-Id: <1438165826-32762-1-git-send-email-steffan.karger@fox-it.com>\nURL: http://article.gmane.org/gmane.network.openvpn.devel/9974\nSigned-off-by: Gert Doering <gert@greenie.muc.de>\n(cherry picked from commit cc377dec820f9e6e7e72981013eb3857aa6ea5ce)","distinct":true,"url":"https://api.github.com/repos/OpenVPN/openvpn/commits/338f11821fa7ce95c768b0cc074f3af7346b19fa"}]}