Padding oracle attacks
1 / 23

Padding Oracle Attacks - PowerPoint PPT Presentation

  • Uploaded on

Padding Oracle Attacks. Satish B 20/08/2011. Cryptography Attack. Agenda. Cryptography Basics Padding oracle attack Exploitation Padding oracle in .NET Tools Remedy. Cryptography Basics.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Padding Oracle Attacks' - boyd

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Padding oracle attacks

Padding Oracle Attacks

Satish B



  • Cryptography Basics

  • Padding oracle attack

  • Exploitation

  • Padding oracle in .NET

  • Tools

  • Remedy

Cryptography basics
Cryptography Basics

Stream Ciphers : Key supplied to encryption algorithm to get key stream Plain text is XOR with key stream to generate cipher text

Ex: Rc4

1 0 = 1 P K = C

0 1 = 1 C P = K

Block Ciphers: Operates on fixed length group of bits or bytes (64 or 128 bit blocks) 128 bits of plain text is converted into 128 bits of cipher text Ex: AES

Cryptography basics1
Cryptography Basics

Block Cipher : Modes

ECB mode – Electronic code book mode

Encryption of the same plain text with the same key results in the same cipher text, which is a considerable threat to security.

Cryptography basics2
Cryptography Basics

CBC – cipher block chaining

Ci = Ek (Pi xor Ci-1)

Encryption of the same plain text with the same key results in different cipher text because of IV.

Each block of plaintext is XORed with the previous ciphertext block before being encrypted.

Cryptography basics3
Cryptography Basics

Each block of ciphertext is decrypted and XORed with the previous ciphertext block to obtain the plain text.

First block of ciphertext is decrypted and XORed with IV to obtain the plain text.

Cryptography basics4
Cryptography Basics

Block Ciphers – - Works on fixed size data

- Messages are in variety of length

- padding has introduced

- Final block padded before encryption

PKCS#5 standard - final block of plaintext is padded with N bytes of value N.

Padding oracle attack
Padding oracle attack

  • Initially discovered in 2002. Credits:

  • Got famous in 2010.

  • What is it ?

  • Possible to decrypt and encrypt data without key in CBC mode.

  • Typical Scenario:

    • Brian logged into

    • Server created an encryption string specific to Brian and sent to him

    • Accessing any page in the application sends the encrypted value to server

    • Server decrypts and serves the content based on decrypted value

  • Ex:

  • 8795A28ED4AAC6

Padding oracle attack1
Padding oracle attack


Client datavalue = BRIAN;12;1;





Padding oracle attack2
Padding oracle attack


Client data


Padding oracle attack3
Padding oracle attack

The application verifies whether the encrypted value is properly padded or not. When the application passed an encrypted value it responds with one of three ways:

Valid ciphertext (with proper padding) – Normal response Invalid ciphertext (improper padding) – Exception Valid ciphertext and decrypts to an invalid value – Custom error

  • Wrong padding can result in:

    • Error messages

    • Stack Traces

    • Time difference

    • Different responses

Padding oracle attack4
Padding oracle attack

oracle refers to a mechanism in cryptography that can be used to determine whether

a test has passed or failed.Pass and Fail conditions can be used to decrypt without key.

Decrypting without a keyValid cipher http://myapp/home.jsp? UID=7B216A634951170FF851D6CC68FC9537

Invalid cipherhttp://myapp/home.jsp?UID=0000000000000000F851D6CC68FC9537

Padding oracle attack5
Padding oracle attack

Invalid cipher


Padding oracle attack6
Padding oracle attack

Invalid cipherhttp://myapp/home.jsp?UID=0000000000000003F851D6CC68FC9537

Intermediary Byte ^ 0×3C == 0×01,Intermediary Byte == 0×3C ^ 0×01,Intermediary Byte == 0×3D

Padding oracle attack7
Padding oracle attack

Valid cipher


Plain text == Intermediarybyte 0×3D ^ corresponding IV byte 0F = = 02

Now crack the 7th byte and so on …

In the end it gives Intermediate value

Padding oracle attack8
Padding oracle attack

Encrypting arbitrary values without key

XOR the plaintext value with intermediary value to get IV


Padding oracle attack allows to encrypt and decrypt data without the key.

Padding oracle attack in net
Padding oracle attack in .NET

  • Where is it applicable ?

  • View state

  • Session cookies

  • Any encrypted data in hidden parameters

  • WebResource.axd - serves embedded resources

  • ScriptResource.axd - serves embedded resources and files

Padding oracle attack in net1
Padding oracle attack in .NET

valid cipher text decrypted to valid value

- proper response (200 ok)

valid cipher text decrypted to invalid value

- page not found or similar response (404)

Invalid cipher text

- padding error

If the application gives different errors in the above 3 cases, it is vulnerable and easy to exploit.


  • Padbuster

  • Poet

  • Padbusterdotnet

Padding oracle attack9
Padding oracle attack

Why Is this working?

  • CBC mode only provides confidentiality.

  • Confidentiality doe not ensure that the value is tampered or not.

  • Integrity check has to be performed.


  • Implemented integrity check by adding hash to the encrypted value

Before fix : fix:


Padding oracle attacks

For more information on exploitation and usage of tools visit my site


Questions? visit my site