Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Padding oracle attack

From Wikipedia, the free encyclopedia
Cryptography attack

In cryptography, apadding oracle attack is an attack which uses thepadding validation of a cryptographic message to decrypt the ciphertext. In cryptography, variable-length plaintext messages often have to be padded (expanded) to be compatible with the underlyingcryptographic primitive. The attack relies on having a "paddingoracle" which freely responds to queries about whether a message is correctly padded or not. The information could be directly given, or leaked through aside-channel.

The earliest well-known attack that uses a padding oracle isBleichenbacher's attack of 1998, which attacksRSA withPKCS #1 v1.5 padding.[1] The term "padding oracle" appeared in literature in 2002,[2] afterSerge Vaudenay's attack on theCBC mode decryption used within symmetricblock ciphers.[3] Variants of both attacks continue to find success more than one decade after their original publication.[1][4][5]

Asymmetric cryptography

[edit]

In 1998,Daniel Bleichenbacher published a seminal paper on what became known asBleichenbacher's attack (also known as "million message attack"). The attack uses a padding oracle againstRSA withPKCS #1 v1.5 padding, but it does not include the term. Later authors have classified his attack as a padding oracle attack.[1]

Manger (2001) reports an attack on the replacement for PKCS #1 v1.5 padding, PKCS #1 v2.0 "OAEP".[6]

Symmetric cryptography

[edit]

In symmetric cryptography, the paddingoracle attack can be applied to theCBC mode of operation. Leaked data on padding validity can allow attackers to decrypt (and sometimes encrypt) messages through the oracle using the oracle's key, without knowing the encryption key.

Compared to Bleichenbacher's attack on RSA with PKCS #1 v1.5, Vaudenay's attack on CBC is much more efficient.[1] Both attacks target crypto systems commonly used for the time: CBC is the original mode used inSecure Sockets Layer (SSL) and had continued to be supported in TLS.[4]

A number of mitigations have been performed to prevent the decryption software from acting as an oracle, but newerattacks based on timing have repeatedly revived this oracle. TLS 1.2 introduces a number ofauthenticated encryption with additional data modes that do not rely on CBC.[4]

Padding oracle attack on CBC encryption

[edit]

The standard implementation of CBC decryption in block ciphers is to decrypt all ciphertext blocks, validate the padding, remove thePKCS7 padding, and return the message's plaintext. If the server returns an "invalid padding" error instead of a generic "decryption failed" error, the attacker can use the server as a padding oracle to decrypt (and sometimes encrypt) messages.

The mathematical formula for CBC decryption is

Pi=DK(Ci)Ci1, if i{1,N}{\displaystyle P_{i}=D_{K}(C_{i})\oplus C_{i-1},{\text{ if }}i\in \{1,N\}}
P0=IVDK(C0).{\displaystyle P_{0}=IV\oplus D_{K}(C_{0}).}

As depicted above, CBC decryption XORs each plaintext block with the previous block.As a result, a single-byte modification in blockC1{\displaystyle C_{1}} will make a corresponding change to a single byte inP2{\displaystyle P_{2}}.

Suppose the attacker has two ciphertext blocksC1,C2{\displaystyle C_{1},C_{2}} and wants to decrypt the second block to get plaintextP2{\displaystyle P_{2}}.The attacker changes the last byte ofC1{\displaystyle C_{1}} (creatingC1{\displaystyle C_{1}'}) and sends(IV,C1,C2){\displaystyle (IV,C_{1}',C_{2})} to the server.The server then returns whether or not the padding of the last decrypted block (P2{\displaystyle P_{2}'}) is correct (a valid PKCS#7 padding).If the padding is correct, the attacker now knows that the last byte ofDK(C2)C1{\displaystyle D_{K}(C_{2})\oplus C_{1}'} is0x01{\displaystyle \mathrm {0x01} }, the last two bytes are 0x02, the last three bytes are 0x03, …, or the last eight bytes are 0x08. The attacker can modify the second-last byte (flip any bit) to ensure that the last byte is 0x01. (Alternatively, the attacker can flip earlier bytes andbinary search for the position to identify the padding. For example, if modifying the third-last byte is correct, but modifying the second-last byte is incorrect, then the last two bytes are known to be 0x02, allowing both of them to be decrypted.) Therefore, the last byte ofDK(C2){\displaystyle D_{K}(C_{2})} equalsC10x01{\displaystyle C_{1}'\oplus \mathrm {0x01} }.If the padding is incorrect, the attacker can change the last byte ofC1{\displaystyle C_{1}'} to the next possible value.At most, the attacker will need to make 256 attempts to find the last byte ofP2{\displaystyle P_{2}}, 255 attempts for every possible byte (256 possible, minus one bypigeonhole principle), plus one additional attempt to eliminate an ambiguous padding.[7]

After determining the last byte ofP2{\displaystyle P_{2}}, the attacker can use the same technique to obtain the second-to-last byte ofP2{\displaystyle P_{2}}.The attacker sets the last byte ofP2{\displaystyle P_{2}} to0x02{\displaystyle \mathrm {0x02} } by setting the last byte ofC1{\displaystyle C_{1}} toDK(C2)0x02{\displaystyle D_{K}(C_{2})\oplus \mathrm {0x02} }.The attacker then uses the same approach described above, this time modifying the second-to-last byte until the padding is correct (0x02, 0x02).

If a block consists of 128 bits (AES, for example), which is 16 bytes, the attacker will obtain plaintextP2{\displaystyle P_{2}} in no more than 256⋅16 = 4096 attempts. This is significantly faster than the2128{\displaystyle 2^{128}} attempts required to bruteforce a 128-bit key.

Encrypting messages with Padding oracle attack (CBC-R)

[edit]

CBC-R[8] turns a decryption oracle into an encryption oracle, and is primarily demonstrated against padding oracles.

Using padding oracle attack CBC-R can craft an initialization vector and ciphertext block for any plaintext:

  • decrypt any ciphertextPi = PODecrypt(Ci )Ci−1,
  • select previous cipherblockCx−1 freely,
  • produce valid ciphertext/plaintext pairCx-1 =Px ⊕ PODecrypt(Ci ).

To generate a ciphertext that isN blocks long, attacker must performN numbers of padding oracle attacks. These attacks are chained together so that proper plaintext is constructed in reverse order, from end of message (CN) to beginning message (C0, IV). In each step, padding oracle attack is used to construct the IV to the previous chosen ciphertext.

The CBC-R attack will not work against an encryption scheme that authenticates ciphertext (using amessage authentication code or similar) before decrypting.

Attacks using padding oracles

[edit]

The original attack against CBC was published in 2002 bySerge Vaudenay.[3] Concrete instantiations of the attack were later realised against SSL[9] and IPSec.[10][11] It was also applied to severalweb frameworks, includingJavaServer Faces,Ruby on Rails[12] andASP.NET[13][14][15] as well as other software, such as theSteam gaming client.[16] In 2012 it was shown to be effective againstPKCS 11 cryptographic tokens.[1]

While these earlier attacks were fixed by mostTLS implementors following its public announcement, a new variant, theLucky Thirteen attack, published in 2013, used a timing side-channel to re-open the vulnerability even in implementations that had previously been fixed. As of early 2014, the attack is no longer considered a threat in real-life operation, though it is still workable in theory (seesignal-to-noise ratio) against a certain class of machines. As of 2015[update], the most active area of development for attacks upon cryptographic protocols used to secure Internet traffic aredowngrade attack, such as Logjam[17] and Export RSA/FREAK[18] attacks, which trick clients into using less-secure cryptographic operations provided for compatibility with legacy clients when more secure ones are available. An attack calledPOODLE[19] (late 2014) combines both a downgrade attack (to SSL 3.0) with a padding oracle attack on the older, insecure protocol to enable compromise of the transmitted data. In May 2016 it has been revealed inCVE-2016-2107 that the fix against Lucky Thirteen in OpenSSL introduced another timing-based padding oracle.[20][21]

References

[edit]
  1. ^abcdeRomain Bardou; Riccardo Focardi; Yusuke Kawamoto; Lorenzo Simionato; Graham Steel; Joe-Kai Tsay (2012).Efficient Padding Oracle Attacks on Cryptographic Hardware.Rr-7944 (report).INRIA. p. 19.
  2. ^Black, John; Urtubia, Hector (2002).Side-Channel Attacks on Symmetric Encryption Schemes: The Case for Authenticated Encryption. USENET Security '02.
  3. ^abSerge Vaudenay (2002).Security Flaws Induced by CBC Padding Applications to SSL, IPSEC, WTLS...(PDF). EUROCRYPT 2002.Similar attack model was used by Bleichenbacher against PKCS#1 v1.5 [5] and by Manger against PKCS#1 v2.0 [13]. This paper shows that similar attacks are feasible in the symmetric key world.
  4. ^abcSullivan, Nick (12 February 2016)."Padding oracles and the decline of CBC-mode cipher suites".The Cloudflare Blog.
  5. ^Hanno Böck; Juraj Somorovsky; Craig Young."ROBOT attack: Return Of Bleichenbacher's Oracle Threat". Retrieved27 February 2018.
  6. ^Manger, James (2001)."A Chosen Ciphertext Attack on RSA Optimal Asymmetric Encryption Padding (OAEP) as Standardized in PKCS #1 v2.0"(PDF). Telstra Research Laboratories.
  7. ^Is the padding oracle attack deterministic
  8. ^Juliano Rizzo; Thai Duong (25 May 2010).Practical Padding Oracle Attacks(PDF). USENIX WOOT 2010.
  9. ^Brice Canvel; Alain Hiltgen; Serge Vaudenay; Martin Vuagnoux (2003),Password Interception in a SSL/TLS Channel(PDF).
  10. ^Jean Paul Degabriele; Kenneth G. Paterson (2007),Attacking the IPsec Standards in Encryption-only Configurations(PDF), archived fromthe original on 19 December 2018, retrieved25 September 2018.
  11. ^Jean Paul Degabriele; Kenneth G. Paterson (2010),On the (In)Security of IPsec in MAC-then-Encrypt Configurations,CiteSeerX 10.1.1.185.1534.
  12. ^Juliano Rizzo; Thai Duong (25 May 2010).Practical Padding Oracle Attacks(PDF). USENIX WOOT 2010.
  13. ^Thai Duong; Juliano Rizzo (2011).Cryptography in the Web: The Case of Cryptographic Design Flaws in ASP.NET(PDF). IEEE Symposium on Security and Privacy 2011.
  14. ^Dennis Fisher (13 September 2010)."'Padding Oracle' Crypto Attack Affects Millions of ASP.NET Apps".Threat Post. Archived fromthe original on 13 October 2010.
  15. ^Vlad Azarkhin (19 September 2010).""Padding Oracle" ASP.NET Vulnerability Explanation". Archived fromthe original on 23 October 2010. Retrieved11 October 2010.
  16. ^"Breaking Steam Client Cryptography".Steam Database. Retrieved1 May 2016.
  17. ^Matthew Green;Nadia Heninger; Paul Zimmerman; et al. (2015),Imperfect Forward Secrecy: How Diffie–Hellman Fails in Practice(PDF). For further information seehttps://www.weakdh.orgArchived 22 December 2019 at theWayback Machine.
  18. ^Matthew Green (3 March 2015)."Attack of the week: FREAK (or 'factoring the NSA for fun and profit')".; seehttps://www.freakattack.comArchived 5 March 2015 at theWayback Machine for more information.
  19. ^Matthew Green (14 October 2014)."Attack of the week: POODLE".; for further information, seehttps://www.poodle.io
  20. ^OpenSSL Security Advisory [3rd May 2016], 3 May 2016
  21. ^"Yet Another Padding Oracle in OpenSSL CBC Ciphersuites",The Cloudflare Blog, Cloudflare, 4 May 2016
Protocols and technologies
Public-key infrastructure
See also
History
Implementations
Notaries
Vulnerabilities
Theory
Cipher
Protocol
Implementation
Retrieved from "https://en.wikipedia.org/w/index.php?title=Padding_oracle_attack&oldid=1319725145"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp