fbpx
Wikipedia

Padding oracle attack

In cryptography, a padding oracle attack is an attack which uses the padding 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 underlying cryptographic primitive. The attack relies on having a "padding oracle" who freely responds to queries about whether a message is correctly padded or not. Padding oracle attacks are mostly associated with CBC mode decryption used within block ciphers. Padding modes for asymmetric algorithms such as OAEP may also be vulnerable to padding oracle attacks.[1]

Symmetric cryptography edit

In symmetric cryptography, the padding oracle attack can be applied to the CBC mode of operation, where the "oracle" (usually a server) leaks data about whether the padding of an encrypted message is correct or not. Such data can allow attackers to decrypt (and sometimes encrypt) messages through the oracle using the oracle's key, without knowing the encryption key.

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 the PKCS7 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

 
 

As depicted above, CBC decryption XORs each plaintext block with the previous block. As a result, a single-byte modification in block   will make a corresponding change to a single byte in  .

Suppose the attacker has two ciphertext blocks   and wants to decrypt the second block to get plaintext  . The attacker changes the last byte of   (creating  ) and sends   to the server. The server then returns whether or not the padding of the last decrypted block ( ) is correct (a valid PKCS#7 padding). If the padding is correct, the attacker now knows that the last byte of   is  , 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 and binary 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 of   equals  . If the padding is incorrect, the attacker can change the last byte of   to the next possible value. At most, the attacker will need to make 256 attempts to find the last byte of  , 255 attempts for every possible byte (256 possible, minus one by pigeonhole principle), plus one additional attempt to eliminate an ambiguous padding.[2]

After determining the last byte of  , the attacker can use the same technique to obtain the second-to-last byte of  . The attacker sets the last byte of   to   by setting the last byte of   to  . 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 plaintext   in no more than 256⋅16 = 4096 attempts. This is significantly faster than the   attempts required to bruteforce a 128-bit key.

Encrypting messages with Padding oracle attack (CBC-R) edit

CBC-R[3] 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 ciphertext Pi = PODecrypt( Ci ) XOR Ci−1,
  • select previous cipherblock Cx−1 freely,
  • produce valid ciphertext/plaintext pair Cx-1 = Px XOR PODecrypt( Ci ).

To generate a ciphertext that is N blocks long, attacker must perform N 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 a message authentication code or similar) before decrypting.

Attacks using padding oracles edit

The original attack was published in 2002 by Serge Vaudenay.[4] Concrete instantiations of the attack were later realised against SSL[5] and IPSec.[6][7] It was also applied to several web frameworks, including JavaServer Faces, Ruby on Rails[8] and ASP.NET[9][10][11] as well as other software, such as the Steam gaming client.[12] In 2012 it was shown to be effective against some hardened security devices.[13]

While these earlier attacks were fixed by most TLS implementors following its public announcement, a new variant, the Lucky 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 (see signal-to-noise ratio) against a certain class of machines. As of 2015, the most active area of development for attacks upon cryptographic protocols used to secure Internet traffic are downgrade attack, such as Logjam[14] and Export RSA/FREAK[15] attacks, which trick clients into using less-secure cryptographic operations provided for compatibility with legacy clients when more secure ones are available. An attack called POODLE[16] (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 in CVE-2016-2107 that the fix against Lucky Thirteen in OpenSSL introduced another padding oracle.[17][18]

References edit

  1. ^ Manger, James. "A Chosen Ciphertext Attack on RSA Optimal Asymmetric Encryption Padding (OAEP) as Standardized in PKCS #1 v2.0" (PDF). Telstra Research Laboratories.
  2. ^ Is the padding oracle attack deterministic
  3. ^ Juliano Rizzo; Thai Duong (25 May 2010). Practical Padding Oracle Attacks (PDF). USENIX WOOT 2010.
  4. ^ Serge Vaudenay (2002). Security Flaws Induced by CBC Padding Applications to SSL, IPSEC, WTLS... (PDF). EUROCRYPT 2002.
  5. ^ Brice Canvel; Alain Hiltgen; Serge Vaudenay; Martin Vuagnoux (2003), Password Interception in a SSL/TLS Channel (PDF).
  6. ^ Jean Paul Degabriele; Kenneth G. Paterson (2007), (PDF), archived from the original on 19 December 2018, retrieved 25 September 2018.
  7. ^ Jean Paul Degabriele; Kenneth G. Paterson (2010), On the (In)Security of IPsec in MAC-then-Encrypt Configurations, CiteSeerX 10.1.1.185.1534.
  8. ^ Juliano Rizzo; Thai Duong (25 May 2010). Practical Padding Oracle Attacks (PDF). USENIX WOOT 2010.
  9. ^ 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.
  10. ^ Dennis Fisher (13 September 2010). . Threat Post. Archived from the original on 13 October 2010.
  11. ^ Vlad Azarkhin (19 September 2010). . Archived from the original on 23 October 2010. Retrieved 11 October 2010.
  12. ^ "Breaking Steam Client Cryptography". Steam Database. Retrieved 1 May 2016.
  13. ^ Romain Bardou; Riccardo Focardi; Yusuke Kawamoto; Lorenzo Simionato; Graham Steel; Joe-Kai Tsay (2012), Efficient Padding Oracle Attacks on Cryptographic Hardware (PDF)
  14. ^ Matthew Green; Nadia Heninger; Paul Zimmerman; et al. (2015), Imperfect Forward Secrecy: How Diffie–Hellman Fails in Practice (PDF). For further information see https://www.weakdh.org 22 December 2019 at the Wayback Machine.
  15. ^ Matthew Green (3 March 2015). "Attack of the week: FREAK (or 'factoring the NSA for fun and profit')".; see https://www.freakattack.com 5 March 2015 at the Wayback Machine for more information.
  16. ^ Matthew Green (14 October 2014). "Attack of the week: POODLE".; for further information, see https://www.poodle.io
  17. ^ OpenSSL Security Advisory [3rd May 2016], 3 May 2016
  18. ^ Yet Another Padding Oracle in OpenSSL CBC Ciphersuites, Cloudflare, 4 May 2016

padding, oracle, attack, cryptography, padding, oracle, attack, attack, which, uses, padding, validation, cryptographic, message, decrypt, ciphertext, cryptography, variable, length, plaintext, messages, often, have, padded, expanded, compatible, with, underly. In cryptography a padding oracle attack is an attack which uses the padding 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 underlying cryptographic primitive The attack relies on having a padding oracle who freely responds to queries about whether a message is correctly padded or not Padding oracle attacks are mostly associated with CBC mode decryption used within block ciphers Padding modes for asymmetric algorithms such as OAEP may also be vulnerable to padding oracle attacks 1 Contents 1 Symmetric cryptography 1 1 Padding oracle attack on CBC encryption 1 2 Encrypting messages with Padding oracle attack CBC R 2 Attacks using padding oracles 3 ReferencesSymmetric cryptography editIn symmetric cryptography the padding oracle attack can be applied to the CBC mode of operation where the oracle usually a server leaks data about whether the padding of an encrypted message is correct or not Such data can allow attackers to decrypt and sometimes encrypt messages through the oracle using the oracle s key without knowing the encryption key 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 the PKCS7 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 nbsp The mathematical formula for CBC decryption is P i D K C i C i 1 displaystyle P i D K C i oplus C i 1 nbsp C 0 I V displaystyle C 0 IV nbsp As depicted above CBC decryption XORs each plaintext block with the previous block As a result a single byte modification in block C 1 displaystyle C 1 nbsp will make a corresponding change to a single byte in P 2 displaystyle P 2 nbsp Suppose the attacker has two ciphertext blocks C 1 C 2 displaystyle C 1 C 2 nbsp and wants to decrypt the second block to get plaintext P 2 displaystyle P 2 nbsp The attacker changes the last byte of C 1 displaystyle C 1 nbsp creating C 1 displaystyle C 1 nbsp and sends I V C 1 C 2 displaystyle IV C 1 C 2 nbsp to the server The server then returns whether or not the padding of the last decrypted block P 2 displaystyle P 2 nbsp is correct a valid PKCS 7 padding If the padding is correct the attacker now knows that the last byte of D K C 2 C 1 displaystyle D K C 2 oplus C 1 nbsp is 0 x 01 displaystyle mathrm 0x01 nbsp 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 and binary 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 of D K C 2 displaystyle D K C 2 nbsp equals C 1 0 x 01 displaystyle C 1 oplus mathrm 0x01 nbsp If the padding is incorrect the attacker can change the last byte of C 1 displaystyle C 1 nbsp to the next possible value At most the attacker will need to make 256 attempts to find the last byte of P 2 displaystyle P 2 nbsp 255 attempts for every possible byte 256 possible minus one by pigeonhole principle plus one additional attempt to eliminate an ambiguous padding 2 After determining the last byte of P 2 displaystyle P 2 nbsp the attacker can use the same technique to obtain the second to last byte of P 2 displaystyle P 2 nbsp The attacker sets the last byte of P 2 displaystyle P 2 nbsp to 0 x 02 displaystyle mathrm 0x02 nbsp by setting the last byte of C 1 displaystyle C 1 nbsp to D K C 2 0 x 02 displaystyle D K C 2 oplus mathrm 0x02 nbsp 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 plaintext P 2 displaystyle P 2 nbsp in no more than 256 16 4096 attempts This is significantly faster than the 2 128 displaystyle 2 128 nbsp attempts required to bruteforce a 128 bit key Encrypting messages with Padding oracle attack CBC R edit CBC R 3 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 ciphertext Pi PODecrypt Ci XOR Ci 1 select previous cipherblock Cx 1 freely produce valid ciphertext plaintext pair Cx 1 Px XOR PODecrypt Ci To generate a ciphertext that is N blocks long attacker must perform N 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 a message authentication code or similar before decrypting Attacks using padding oracles editThe original attack was published in 2002 by Serge Vaudenay 4 Concrete instantiations of the attack were later realised against SSL 5 and IPSec 6 7 It was also applied to several web frameworks including JavaServer Faces Ruby on Rails 8 and ASP NET 9 10 11 as well as other software such as the Steam gaming client 12 In 2012 it was shown to be effective against some hardened security devices 13 While these earlier attacks were fixed by most TLS implementors following its public announcement a new variant the Lucky 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 see signal 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 are downgrade attack such as Logjam 14 and Export RSA FREAK 15 attacks which trick clients into using less secure cryptographic operations provided for compatibility with legacy clients when more secure ones are available An attack called POODLE 16 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 in CVE 2016 2107 that the fix against Lucky Thirteen in OpenSSL introduced another padding oracle 17 18 References edit Manger James A Chosen Ciphertext Attack on RSA Optimal Asymmetric Encryption Padding OAEP as Standardized in PKCS 1 v2 0 PDF Telstra Research Laboratories Is the padding oracle attack deterministic Juliano Rizzo Thai Duong 25 May 2010 Practical Padding Oracle Attacks PDF USENIX WOOT 2010 Serge Vaudenay 2002 Security Flaws Induced by CBC Padding Applications to SSL IPSEC WTLS PDF EUROCRYPT 2002 Brice Canvel Alain Hiltgen Serge Vaudenay Martin Vuagnoux 2003 Password Interception in a SSL TLS Channel PDF Jean Paul Degabriele Kenneth G Paterson 2007 Attacking the IPsec Standards in Encryption only Configurations PDF archived from the original on 19 December 2018 retrieved 25 September 2018 Jean Paul Degabriele Kenneth G Paterson 2010 On the In Security of IPsec in MAC then Encrypt Configurations CiteSeerX 10 1 1 185 1534 Juliano Rizzo Thai Duong 25 May 2010 Practical Padding Oracle Attacks PDF USENIX WOOT 2010 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 Dennis Fisher 13 September 2010 Padding Oracle Crypto Attack Affects Millions of ASP NET Apps Threat Post Archived from the original on 13 October 2010 Vlad Azarkhin 19 September 2010 Padding Oracle ASP NET Vulnerability Explanation Archived from the original on 23 October 2010 Retrieved 11 October 2010 Breaking Steam Client Cryptography Steam Database Retrieved 1 May 2016 Romain Bardou Riccardo Focardi Yusuke Kawamoto Lorenzo Simionato Graham Steel Joe Kai Tsay 2012 Efficient Padding Oracle Attacks on Cryptographic Hardware PDF Matthew Green Nadia Heninger Paul Zimmerman et al 2015 Imperfect Forward Secrecy How Diffie Hellman Fails in Practice PDF For further information see https www weakdh org Archived 22 December 2019 at the Wayback Machine Matthew Green 3 March 2015 Attack of the week FREAK or factoring the NSA for fun and profit see https www freakattack com Archived 5 March 2015 at the Wayback Machine for more information Matthew Green 14 October 2014 Attack of the week POODLE for further information see https www poodle io OpenSSL Security Advisory 3rd May 2016 3 May 2016 Yet Another Padding Oracle in OpenSSL CBC Ciphersuites Cloudflare 4 May 2016 Retrieved from https en wikipedia org w index php title Padding oracle attack amp oldid 1088720142, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.