码迷,mamicode.com
首页 > 其他好文 > 详细

【SSL】POODLE 漏洞细节分析

时间:2015-07-28 17:36:11      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

0x01 TLS使用中的降级 

To work with legacy servers, many TLS clients implement a downgrade dance: in a first handshake attempt, offer the highest protocol version supported by the client? if this handshake fails, retry (possibly repeatedly) with earlier protocol versions. Unlike proper protocol version negotiation (if the client offers TLS 1.2, the server may respond with, say, TLS 1.0), this downgrade can also be triggered by network glitches, or by active attackers. So if an attacker that controls the network between the client and the server interferes with any attempted handshake offering TLS 1.0 or later, such clients will readily confine themselves to SSL 3.0.

 

0x02  SSL 3.0的脆弱性与POODLE攻击过程

 

The most severe problem of CBC encryption in SSL 3.0 is that its block cipher padding is not deterministic, and not covered by the MAC (Message Authentication Code): thus, the integrity of padding cannot be fully verified when decrypting. Padding by 1 to L bytes (where L is the block size in bytes) is used to obtain an integral number of blocks before performing blockwise CBC (cipher­block chaining) encryption. The weakness is the easiest to exploit if there’s an entire block of padding, which (before encryption) consists of L­1 arbitrary bytes followed by a single byte of value L­1. To process an incoming ciphertext record C1 ... Cn also given an initialization vector C0 (where each Ci is one block), the recipient first determines P1 ... Pn as Pi = DK (Ci ) ⊕ Ci­1 (where DK denotes block­cipher decryption using per­connection key K), then checks and removes the padding at the end, and finally checks and removes a MAC. Now observe that if there’s a full block of padding and an attacker replaces Cn by any earlier ciphertext block Ci from the same encrypted stream, the ciphertext will still be accepted if DK (Ci ) ⊕ Cn­1 happens to have L­1 as its final byte, but will in all likelihood be rejected otherwise, giving rise to a padding oracle attack [tls­cbc].

技术分享 

 

In the web setting, this SSL 3.0 weakness can be exploited by a man­in­the middle attacker to decrypt “secure” HTTP cookies, using techniques from the BEAST attack [BEAST]. To launch the POODLE attack (Padding Oracle On Downgraded Legacy Encryption), run a JavaScript agent on evil.com (or on http://example.com) to get the victim’s browser to send cookie­bearing HTTPS requests to https://example.com, and intercept and modify the SSL records sent by the browser in such a way that there’s a non­negligible chance that example.com will accept the modified record. If the modified record is accepted, the attacker can decrypt one byte of the cookies. Assume that each block C has 16 bytes, C[0] ... C[15]. (Eight­byte blocks can be handled similarly.) Also assume, for now, that the size of the cookies is known. (Later we will show how to start the attack if it isn’t.) The MAC size in SSL 3.0 CBC cipher suites is typically 20 bytes, so below the CBC layer, an encrypted POST request will look as follows:

POST /path Cookie: name=value...\r\n\r\nbody ‖ 20­byte MAC ‖ padding

这里的path和body是攻击者可以控制的,而且假设cookie的长度已经知道(后面有不知道的进一步实现细节),这里就可以多次发送Ci 替换Cn 的包进行尝试(每次的key都不一样),直到满足P‘n[15]=15(256次以内),这时候就可以通过公式求出一个字节,接下来可以控制长度进行进一步的破解。 

The attacker controls both the request path and the request body, and thus can induce requests such that the following two conditions hold:

● The padding fills an entire block (encrypted into Cn ).

● The cookies’ first as­of­yet unknown byte appears as the final byte in an earlier block (encrypted into Ci ).

The attacker then replaces Cn by Ci and forwards this modified SSL record to the server. Usually, the server will reject this record, and the attacker will simply try again with a new request. Occasionally (on average, once in 256 requests), the server will accept the modified record, and the attacker will conclude that DK (Ci )[15] ⊕ Cn­1 [15] = 15, and thus that Pi [15] = 15 ⊕ Cn­1 [15] ⊕ Ci­1 [15]. This reveals the cookies’ first previously unknown byte. The attacker proceeds to the next byte by changing the sizes of request path and body simultaneously such that the request size stays the same but the position of the headers is shifted , continuing until it has decrypted as much of the cookies as desired. 1 The expected overall effort is 256 SSL 3.0 requests per byte. As the padding hides the exact size of the payload, the cookies’ size is not immediately apparent, but inducing requests GET /, GET /A, GET /AA, ... allows the attacker to observe at which point the block boundary gets crossed: after at most 16 such requests, this will reveal the padding size, and thus the size of the cookies.

在cookies长度不确定的情况下,可以通过控制增加客户端的path长度并对比密文Ciphertext长度,基本在16个请求以内就可以确定其实际长度。

 

 实现可以参考:https://github.com/thomaspatzke/POODLEAttack

【SSL】POODLE 漏洞细节分析

标签:

原文地址:http://www.cnblogs.com/windcarp/p/4682933.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!