CS2107 Padding Oracle Attack

Brian Yen
16 Sept 202115:38

Summary

TLDRThis video script offers an in-depth exploration of the padding oracle attack, a complex cryptographic exploit. It breaks down the attack into its core components: the XOR operation, block ciphers in CBC mode, padding standards like PKCS#7, and the oracle mechanism. The script explains how attackers can exploit the oracle's feedback to decrypt ciphertext and recover plaintext, despite not knowing the encryption key. The tutorial uses clear examples and diagrams to illustrate the step-by-step process of the attack, emphasizing the significance of understanding each component's role in the exploit.

Takeaways

  • 🔐 The padding oracle attack allows an attacker to retrieve the original plaintext from ciphertext without knowing the encryption key.
  • 🧩 The attack involves understanding the XOR operation, which is fundamental to how block ciphers function, especially in CBC mode.
  • 🔄 The XOR operation's property where knowing any two of three involved entities (two operands and the result) can reveal the third is crucial for the attack.
  • 🗜️ Block ciphers in CBC mode decrypt data by XORing the decrypted block with the previous ciphertext block to get the plaintext block.
  • 📐 Padding standards like PKCS#7 are necessary when the input data size isn't a multiple of the block size, ensuring complete blocks for encryption.
  • 👁️‍🗨️ The padding oracle is a component that checks if the decrypted plaintext has valid padding, without revealing sensitive decryption details.
  • 🔄 The attack manipulates the ciphertext input to the padding oracle to gradually determine the plaintext byte by byte through XOR operations.
  • 🔍 An exhaustive search is used to find the correct ciphertext block values that will result in valid padding when decrypted.
  • 🔄 By keeping one ciphertext block constant and altering the previous one, attackers can isolate and determine the plaintext bytes step by step.
  • ⚠️ The attack highlights the risks of disclosing whether padding is valid, as this information can be exploited to reconstruct the plaintext.

Q & A

  • What is a padding oracle attack?

    -A padding oracle attack is a form of cryptographic attack that allows an attacker to retrieve the original plaintext from a ciphertext by exploiting the way a system handles decryption and padding errors.

  • Why is the XOR operation significant in the context of a padding oracle attack?

    -The XOR operation is significant because it is a bitwise operation that is used both in the decryption process and in manipulating ciphertext to influence the decrypted plaintext. Its properties allow attackers to determine unknown values by comparing known outputs.

  • How does the block cipher decryption process work in CBC mode?

    -In CBC (Cipher Block Chaining) mode, each decrypted ciphertext block is XORed with the previous ciphertext block to retrieve the plaintext block. This process is repeated for each block to reconstruct the original plaintext.

  • What is the role of the padding standard in a padding oracle attack?

    -The padding standard, such as PKCS#7, defines how padding is added to plaintext that is not an exact multiple of the block size. In a padding oracle attack, the attacker manipulates the ciphertext to determine the padding and, consequently, the plaintext.

  • What does the padding oracle do in the context of an attack?

    -The padding oracle is a component that checks if the decrypted plaintext has valid padding according to the padding standard. It responds with a 'yes' or 'no' without revealing the actual plaintext or the decryption key.

  • How does an attacker use the responses from the padding oracle?

    -An attacker uses the 'yes' or 'no' responses from the padding oracle to iteratively determine the bytes of the plaintext by manipulating the ciphertext and observing whether the decrypted padding is valid.

  • What is the purpose of the exhaustive search method mentioned in the script?

    -The exhaustive search method is used by the attacker to try all possible byte values (0 to 255) to find the correct value that will cause the padding oracle to respond with 'yes,' indicating valid padding and allowing the recovery of a byte of the plaintext.

  • How does the attacker manipulate the ciphertext to affect the decrypted plaintext?

    -The attacker manipulates the ciphertext by changing specific bytes while keeping others constant, aiming to create a desired valid padding pattern in the decrypted plaintext that will be reflected in the padding oracle's response.

  • What is the significance of the deterministic nature of the block cipher decryption algorithm in a padding oracle attack?

    -The deterministic nature of the block cipher decryption algorithm ensures that the same ciphertext input will always produce the same intermediate state, allowing the attacker to make precise manipulations and predictions about the plaintext.

  • How does the attacker move from finding the last byte of plaintext to the second last byte in the attack?

    -After finding the last byte of plaintext, the attacker modifies the ciphertext to target the second last byte of the plaintext, using the knowledge of the previous plaintext byte and the properties of the XOR operation to iteratively uncover more of the plaintext.

Outlines

00:00

🔐 Introduction to Padding Oracle Attack

The paragraph introduces the concept of the padding oracle attack, a method used by attackers to retrieve the original plaintext from ciphertext. It emphasizes the complexity of the attack due to the multiple components involved and the XOR operations used. The video aims to simplify the understanding of the attack mechanics. The attack is set within a specific context involving four main parts: the XOR operation, a block cipher using Cipher Block Chaining (CBC) mode, the padding standard, and an oracle. The paragraph discusses the XOR operation in detail, explaining its bit-by-bit nature and its property of being reversible when any two of the three involved entities (two operands and one result) are known.

05:00

🔑 Block Cipher and CBC Mode

This section delves into the workings of block ciphers, particularly focusing on the decryption process. It explains how block ciphers process ciphertext in fixed-size blocks and how decryption is performed. The paragraph introduces Cipher Block Chaining (CBC) mode, where each decrypted block is XORed with the previous ciphertext block to obtain the plaintext. The paragraph uses a diagram to illustrate the decryption process in CBC mode, highlighting how the process is repeated for each block. It also touches on the necessity of padding when the input size is not a multiple of the block size, setting the stage for the padding standard discussion in the next paragraph.

10:02

🔠 Padding Standard and Oracle

The paragraph discusses the padding standard, specifically PKCS#7, which is used to handle scenarios where the plaintext does not fill an entire block. It explains how padding is added to complete the last block according to a specific pattern. The paragraph then introduces the concept of an oracle, which is a mechanism that can answer whether the decrypted plaintext has valid padding without revealing sensitive information. The padding oracle is highlighted as a key component of the attack, as it performs decryption and can be manipulated by the attacker to extract information about the plaintext.

15:04

🕵️‍♂️ Padding Oracle Attack Process

This paragraph explains the process of the padding oracle attack, focusing on how an attacker can manipulate the ciphertext to learn about the plaintext. It details the attacker's strategy of changing the ciphertext in a way that the padding oracle responds positively, indicating valid padding. The paragraph describes how the attacker can iteratively determine the plaintext byte by byte by forcing the decrypted plaintext to have a desired valid padding. It outlines the steps involved in the attack, including the use of XOR operations to deduce the original plaintext from the ciphertext. The paragraph concludes by emphasizing the significance of the padding oracle's role in the attack and the information it inadvertently reveals.

Mindmap

Keywords

💡Padding Oracle Attack

The Padding Oracle Attack is a cryptographic attack that exploits the way a system handles errors in the padding of a block cipher. In the context of the video, this attack allows an attacker to decrypt a ciphertext without knowing the encryption key by observing the system's response to incorrect padding. The video emphasizes that this attack is particularly dangerous because it can reveal the original plaintext from just the ciphertext alone, given the right conditions and an 'oracle' that can be queried about the validity of the padding.

💡XOR Operation

The XOR (Exclusive OR) operation is a binary operation that takes two binary inputs and returns true if exactly one of the inputs is true. In the video, XOR is crucial for understanding the mechanics of the Padding Oracle Attack because it is used in the decryption process of block ciphers. The video explains that XOR operations are done bit by bit, affecting only the specific byte being manipulated, which is key to the attack's methodology.

💡Block Cipher

A block cipher is a symmetric key cipher that encrypts plaintext in blocks, typically 64 or 128 bits long. The video discusses how block ciphers operate, particularly in Cipher Block Chaining (CBC) mode, where each block of ciphertext is XORed with the previous block before decryption. The Padding Oracle Attack relies on the deterministic nature of the block cipher's decryption process to infer information about the plaintext.

💡Cipher Block Chaining (CBC) Mode

CBC mode is a mode of operation for block ciphers that uses an initialization vector (IV) and the previous ciphertext block to encrypt the current plaintext block. In the video, the decryption process in CBC mode is highlighted, where the decrypted ciphertext block is XORed with the previous ciphertext block to obtain the plaintext. This process is integral to the Padding Oracle Attack, as it allows the attacker to manipulate the plaintext by altering the ciphertext.

💡Padding Standard

Padding standards are used to fill the last block of plaintext with additional bytes to match the block size required by the block cipher. The video specifically mentions PKCS#7, a padding scheme where the padding bytes indicate the number of padding bytes added. The Padding Oracle Attack exploits the knowledge of the padding scheme to guess the plaintext byte by byte.

💡Oracle

In the context of the Padding Oracle Attack, an 'oracle' is a component of the system that can be queried to check if the decrypted plaintext has valid padding. The video explains that the oracle does not reveal any sensitive information like the encryption key but provides a 'yes' or 'no' response based on the validity of the padding. This binary response is the key to the attack, as it allows the attacker to iteratively guess the plaintext.

💡Deterministic Algorithm

A deterministic algorithm is one that, given the same input, will always produce the same output. The video points out that the block cipher decryption algorithm is deterministic, which is a critical property exploited in the Padding Oracle Attack. If the ciphertext (input) remains unchanged, the intermediate state produced by the decryption algorithm will also remain the same, allowing the attacker to make educated guesses about the plaintext.

💡Exhaustive Search

Exhaustive search, as mentioned in the video, is a method where all possible values are tried until the correct one is found. In the context of the Padding Oracle Attack, the attacker uses exhaustive search to determine the correct byte values in the ciphertext that will result in valid padding when decrypted. The video illustrates how this is done by changing one byte at a time and querying the oracle.

💡Valid Padding

Valid padding refers to the correct application of a padding scheme to the plaintext before encryption. In the video, the concept of valid padding is central to the Padding Oracle Attack. The attacker aims to manipulate the ciphertext in such a way that when decrypted, the plaintext appears to have valid padding according to the padding standard, which signals to the attacker that they have guessed a correct plaintext byte.

💡Man-in-the-Middle (MitM)

Although not explicitly mentioned in the provided transcript, the concept of a Man-in-the-Middle attack is related to the Padding Oracle Attack in that both involve an attacker intercepting and manipulating data. In a MitM attack, the attacker sits between the sender and receiver, potentially altering messages. The Padding Oracle Attack could be seen as a form of MitM where the attacker manipulates the ciphertext to interact with the decryption system and extract information.

Highlights

Padding oracle attack allows an attacker to retrieve the original plaintext from just the ciphertext.

The attack involves understanding the XOR operation, block cipher, padding standard, and an oracle.

XOR operations are bit-wise and can be used to manipulate specific bytes without affecting others.

The XOR operation has a unique property where any two of three entities can be used to retrieve the third.

Block ciphers decrypt ciphertext in blocks, using a fixed-size algorithm.

In CBC mode, the decrypted ciphertext block is XORed with the previous ciphertext block to retrieve plaintext.

Padding standards like PKCS#7 are used to handle inputs that aren't a multiple of the block size.

The padding oracle is a mechanism that checks if the decrypted plaintext has valid padding.

The padding oracle performs decryption but only reveals whether the padding is valid, not the key or algorithm.

The attack process involves manipulating the ciphertext to force the plaintext to have a desired valid padding.

By keeping one ciphertext block unchanged and manipulating another, attackers can deduce the plaintext byte by byte.

The attack leverages the deterministic nature of the block cipher decryption algorithm.

An exhaustive search is used to find the value of a byte that makes the plaintext padding valid.

The attack methodically works from the last byte of the plaintext to the first, using the padding oracle's feedback.

The padding oracle attack illustrates how revealing padding validity can inadvertently leak information.

The video aims to provide an intuitive understanding of the padding oracle attack's mechanics.

Transcripts

play00:00

hey everyone in cs 107 one of the more

play00:03

interesting attacks covered is the

play00:04

padding oracle attack it's not

play00:06

particularly easy to wrap your head

play00:08

around the attack at first simply

play00:09

because there are quite a few moving

play00:11

parts and the xor operations involved

play00:12

don't exactly lend themselves to quick

play00:14

and easy interpretation this video aims

play00:17

to provide an intuitive understanding

play00:18

and explanation for the mechanics behind

play00:20

the attack the padding oracle attack

play00:22

really isn't that unapproachable once

play00:24

you break it down the first part of this

play00:25

video will be dealing with the context

play00:27

and setup of the attack while the second

play00:29

half will delve into the mechanics

play00:30

behind the attack now let's begin what

play00:33

exactly is the padding oracle attack

play00:35

well it provides a way for an attacker

play00:36

to retrieve the original plaintext from

play00:38

just the ciphertext alone but this is a

play00:40

rather generic definition a lot of

play00:42

attacks aim to do this instead what

play00:44

really defines a padding oracle attack

play00:46

is the context in which it is set up and

play00:48

there are four main parts in this

play00:49

context the xor operation a block cipher

play00:52

using cipher block training or cbc mode

play00:54

the padding standard and as well and

play00:56

last but not least an oracle

play00:58

let's go through each of these parts in

play00:59

turn firstly the xor operation now i'm

play01:02

sure most of you will be familiar with

play01:03

the xo operation it's a very simple bit

play01:05

operation that computers do all the time

play01:08

i provided the xor table in the top

play01:09

right hand corner over here for your

play01:10

reference but there are two things about

play01:12

the xor operation that are pertinent to

play01:14

our discussion today the first is the

play01:16

fact that xor operations are done bit by

play01:18

bit by by what i mean by this is that if

play01:21

you xor two sequences of bytes as shown

play01:23

in this diagram over here the output

play01:25

obtained is determined by comparing the

play01:27

bytes in each lane

play01:28

now this might seem like a very obvious

play01:30

thing in the most of you but the point

play01:31

i'm driving towards is the fact that if

play01:33

i change one of the operand bytes say

play01:35

the one right over here

play01:37

only the bytes in this particular lane

play01:39

will be affected

play01:40

all the other lanes remain unaffected so

play01:42

this means that when we want to

play01:43

manipulate bytes in an xor operation we

play01:45

only need to focus our attention on the

play01:47

particular lane of interest

play01:49

the xor operation also has another

play01:51

peculiar property well firstly it's a

play01:53

binary operation so it takes two

play01:55

operands and returns one result so let's

play01:57

say we have a xo of b giving us c that's

play02:00

a total of two plus one equals three

play02:02

entities involved correct well the thing

play02:04

about the xo operation is that if you

play02:06

take any two of these three entities and

play02:09

you xor them you'll always get back the

play02:11

third entity if you don't believe me you

play02:13

can try it out for yourself

play02:14

in this case we can take b x or to c to

play02:17

give us back a we can also take a x or c

play02:20

to give us back b this peculiar property

play02:23

of the xor operation is repeatedly used

play02:26

when we understand when we try to

play02:27

understand and analyze the padding

play02:29

oracle attack

play02:31

next up we have the block cipher let's

play02:33

focus on how block ciphers perform

play02:35

decryption the encryption process is

play02:37

just the reverse of the decryption

play02:38

process so i won't be spending much time

play02:40

on that

play02:41

block ciphers take a ciphertext as input

play02:43

and it will break up this input into

play02:45

blocks of a certain fixed size in my

play02:47

diagram over here i broke up the

play02:48

ciphertext into eight byte blocks where

play02:50

each of these little squares over here

play02:52

represents one byte

play02:54

then the block cipher proceeds to run a

play02:55

decryption algorithm on each of these

play02:57

blocks

play02:58

the output plain text blocks can then be

play03:00

concatenated to retrieve the original

play03:02

plaintext now block ciphers have

play03:05

different modes of operation

play03:06

one mode of operation that we're

play03:08

interested in is the cvc mode or cipher

play03:10

block chaining mode

play03:12

during the decryption process in cbc

play03:14

mode the decrypted cipher text block

play03:16

will also be xor with the previous

play03:18

ciphertext block in order to retrieve

play03:20

the plaintext block now this is quite a

play03:22

mouthful so i personally prefer to just

play03:24

trace through the diagram it's quite

play03:25

easy to understand such diagrams if you

play03:27

interpret all of these arrows it's kind

play03:29

of like pipes for which all of these

play03:31

bytes can flow through if we focus our

play03:33

attention on ciphertext block number two

play03:35

over here which i've drawn to be eight

play03:36

bytes long and i'm representing it in

play03:38

red

play03:39

it will first be put through the block

play03:41

cipher decryption algorithm let's treat

play03:43

this algorithm as a black box the actual

play03:45

algorithm and the implementation of it

play03:47

does not matter do not matter for the

play03:49

purposes of our discussion

play03:51

after putting it through the

play03:53

this particular black box we get an

play03:55

output of eight bytes as well

play03:57

note that this output will almost

play03:59

certainly be different from the initial

play04:00

ciphertext plot so i've drawn them in

play04:02

different colors in this case blue

play04:04

then we'll be taking the previous

play04:06

ciphertext block the one illustrated in

play04:08

green over here and we'll be performing

play04:10

an xor operation giving us the plain

play04:12

text block drawn here in yellow

play04:15

now the same decryption process is

play04:16

repeated for each and every single

play04:18

ciphertext block so when we perform an

play04:20

analysis we can simply focus our

play04:22

attention to just this portion over here

play04:25

because this entire portion is simply

play04:27

repeated again and again and again for

play04:29

all of the remaining blocks

play04:31

next up we have the padding standard

play04:33

since we're using a block cipher what

play04:35

happens when our input can be nicely cut

play04:37

out into these same size blocks in other

play04:39

words what happens when our input size

play04:41

isn't an integer multiple of the block

play04:43

size such as this case here where we

play04:45

only have six bytes in the last portion

play04:48

which isn't enough to make an eight byte

play04:49

block

play04:50

the solution is very simple we can

play04:52

simply add bytes at the end padding it

play04:55

until we have enough bytes to form a

play04:56

full block in this case we'll just be

play04:58

adding two bytes but the question

play05:00

remains what should these two added

play05:02

bytes be we can't possibly fill them up

play05:04

with random bytes right this is where

play05:06

the padding standard comes in and there

play05:08

are many different padding standards out

play05:09

in existence but we'll focus on pkcs

play05:12

number seven and the idea behind pkcs

play05:14

number seven is actually very simple if

play05:16

you have to pack one byte you'll pair it

play05:18

with zero one if you have to pad two

play05:20

bytes you pair it with zero two zero two

play05:23

if you had the pad three bytes you

play05:24

paired it with 030303

play05:26

and so on i hope you get the idea

play05:28

if the last block is full meaning it has

play05:30

in our case a full 8 bytes then we have

play05:33

to add an extra block of all zeros

play05:36

finally we come to the last part of the

play05:37

context the padding oracle now this is

play05:40

the most interesting mechanism involved

play05:42

but actually an oracle is very very

play05:44

simple it's just a black box that

play05:46

answers a certain question you give it

play05:48

some input and

play05:49

then oracle will answer yes or no

play05:51

depending on the question that it's

play05:52

designed to answer

play05:54

in our case we're going to use a padding

play05:56

oracle where we give the oracle some

play05:58

ciphertext input and it will answer the

play06:00

question on whether or not the decrypted

play06:02

plain text has valid padding according

play06:04

to the padding standard adopted in our

play06:07

case we'll be using pkcs number seven as

play06:09

was mentioned two slides ago

play06:11

note this means that the padding oracle

play06:13

actually performs decryption so it will

play06:15

know the secret key and which encryption

play06:17

algorithm to use it's just that it

play06:19

doesn't reveal this key or anything else

play06:21

that is sensitive it only reveals

play06:23

whether or not the decrypted plain text

play06:25

has valid padding nevertheless it is

play06:27

important to recognize that a padding

play06:28

oracle itself is capable of and will

play06:31

perform decryption of the input cipher

play06:33

text

play06:35

so after all of this we now have a good

play06:37

understanding of the context of the

play06:38

attack but how does the attack actually

play06:41

happen

play06:42

let's focus our attention to a single

play06:43

unit of the decryption process we've

play06:45

seen this diagram before but let's first

play06:48

agree on some notation

play06:50

we want to obtain the plain text

play06:51

corresponding to this ciphertext block

play06:53

let's call this c2

play06:55

c2 will be put through the block cipher

play06:57

decryption algorithm generating some

play06:59

kind of output let's call this output at

play07:01

intermediate state and label it i2

play07:04

we need the previous ciphertext block as

play07:06

well let's call this c1 now c1 will be

play07:09

x1 with i2 to give us the plain text

play07:11

block let's call that p2

play07:14

now for a very important fact

play07:16

since this block cipher is a

play07:18

deterministic algorithm

play07:20

if we do not change c2

play07:22

this means that i2 will also remain the

play07:25

same

play07:26

in other words if we keep c2 we don't

play07:29

ever change it that means i2 will also

play07:31

be the same

play07:33

since we have the notation nailed down

play07:34

now let's move forward and try to think

play07:36

like an attacker the intuition behind

play07:38

the panic oracle attack is reviewed when

play07:39

you ask yourself a couple of questions

play07:41

and make a couple of observations

play07:43

firstly a yes from the panic oracle is

play07:46

more helpful than a note because we

play07:48

actually know the format of the last few

play07:49

bytes of the plain text if it has a

play07:51

valid padding it could be 0 1 it could

play07:53

be 0 2 0 2 or it could be 0 3 0 3 03 etc

play07:57

we still have a couple of options but

play07:58

it's a very limited subset if it's a no

play08:02

those last few bytes could literally be

play08:03

anything else

play08:05

next as an attacker we already have our

play08:07

hands on the ciphertext plots we can

play08:09

also control what ciphertext is provided

play08:11

as input to the padding oracle

play08:14

most importantly we can change what

play08:17

ciphertext we input to the padding

play08:18

oracle

play08:19

lastly by changing this ciphertext input

play08:21

we can also change the decrypted

play08:23

plaintext that the patent oracle seeds

play08:25

so here's the key insight we need to try

play08:28

and introduce some kind of change so

play08:30

that the padding oracle tells us the

play08:32

decrypted plaintext has valid padding in

play08:35

other words we can try to force the

play08:36

plaintext decrypted by the parent oracle

play08:38

to have some kind of desired valid

play08:41

padding by manipulating the ciphertext

play08:43

we provide as input to the padding

play08:45

oracle

play08:46

before we continue i want to emphasize

play08:48

that we are dealing with two distinct

play08:50

scenarios here the first is our original

play08:52

decryption scenario over here we're

play08:54

dealing with the original ciphertext

play08:56

blocks and we never introduced any

play08:58

changes but the thing is we're stuck

play09:00

because we don't know the key for the

play09:02

cipher text but for the block cipher

play09:03

decryption algorithm over here so we

play09:05

can't find the plain text

play09:07

the second scenario we're dealing with

play09:09

is the padding oracle scenario which as

play09:11

we've mentioned a couple of slides ago

play09:13

is fully capable of performing

play09:15

decryption on the input ciphertext

play09:18

we want to introduce some kind of change

play09:20

in this padding oracle scenario over

play09:21

here

play09:23

but what kind of change should we

play09:24

introduce so here is the clock sodium

play09:26

type we are going to change c1

play09:28

and we are going to leave c2 unchanged

play09:30

as compared to the original decryption

play09:32

scenario

play09:33

and as i mentioned just now if we if we

play09:36

leave c2 unchanged and since the block

play09:38

cipher decryption algorithm is

play09:39

deterministic this means that i2 will

play09:42

also remain unchanged as well as

play09:44

compared to the original decryption

play09:46

scenario on the right hand side over

play09:47

here

play09:48

so let's focus our attention on the

play09:50

padding oracle scenario first

play09:52

for starters let's try and force the

play09:54

very last byte of the plain text to be 0

play09:56

1. we want and the thing is this is

play09:58

valid padding

play10:00

and in the original scenario the plain

play10:02

text wouldn't have been decrypted to

play10:03

become 0 1 but we're trying to force the

play10:06

plaintext decrypted to have a 0 1

play10:09

as its last byte

play10:11

and we're going to achieve this by

play10:13

introducing some kind of change to c1

play10:15

while keeping c2 unchanged

play10:17

so let's label the last part of i2 as x1

play10:20

remember we kept c2 in its original form

play10:23

when providing the ciphertext blocks as

play10:25

input to the panning oracle since c2

play10:27

remains unchanged that means that x1

play10:29

remains unchanged as well but it's just

play10:31

that we don't know its value

play10:34

then we're going to try and change c1 we

play10:36

only need to change the last part of c1

play10:38

since we're only trying to change the

play10:39

last part of the plane text to become

play10:40

zero one so let's call this last part of

play10:43

c1

play10:44

t1

play10:46

but thing is what should we change this

play10:49

value of t1 to

play10:51

this is where an exhaustive search comes

play10:52

in and you have to recognize that t1 is

play10:55

only one byte long so it can only take

play10:57

on values from 0 to 255 or 0 0 to ff for

play11:01

those of you who prefer hexadecimals

play11:03

instead

play11:04

so we only need a simple for loop

play11:07

looping through and searching through 0

play11:09

to 255 for the last few for the last

play11:12

fight

play11:13

and when the padding oracle finally

play11:14

outputs cs then we'll know what value t1

play11:17

needs to be

play11:18

at this point in time we'll know the

play11:20

value of t1

play11:22

we also know the value of the last part

play11:24

of p2 because we're forcing it to become

play11:26

0 1.

play11:28

and then we know that this is an xo

play11:30

operation as i mentioned just now for an

play11:32

excel operation if you know two of the

play11:34

entities

play11:35

you can simply xor them together to

play11:37

retrieve the last entity

play11:39

therefore we can now find out the value

play11:41

of x1 initially we didn't know this it's

play11:43

an unknown value but now through this

play11:45

process we're able to find out the value

play11:47

of x1 we just need the x or t1 together

play11:50

with the value 0 1.

play11:52

now let's sort back to our original

play11:54

scenario where we didn't change the

play11:55

cipher text

play11:57

our aim is to find the last byte of the

play11:59

original plain text

play12:01

the one indicator and purple right over

play12:02

here

play12:03

we have our hands on all of the cypher

play12:05

text blocks so that means we know the

play12:07

last fight of the original ciphertext

play12:09

block c1

play12:11

on the previous slide we also found the

play12:14

last byte of the intermediate state x1

play12:17

of the intermediate state i2 and this

play12:19

particular last fight will be x1

play12:22

once again we have an xor operation over

play12:24

here we know x1 our c1 as well as x1

play12:27

over here so we can just x all these two

play12:30

things together to get us p1 and just

play12:33

like that we found the last byte of the

play12:35

plain text

play12:36

from now onwards we just need to repeat

play12:38

this process for the rest of the bytes

play12:40

moving from right to left

play12:41

just to make things clear i'll go

play12:43

through how to obtain the second last

play12:45

bite of the plain text as well

play12:48

back to the original sorry back to the

play12:50

padding oracle scenario we now want to

play12:52

force the plain text to have 0 2 0 2 for

play12:55

the padding which is valid padding

play12:57

according to the pkcs number 7 standard

play12:59

once again we're going to keep c2

play13:01

unchanged and make changes to c1 we're

play13:04

only concerned with the last two bytes

play13:06

of the intermediate state let's label

play13:08

them as x1 and x2

play13:10

we already found the value of x1

play13:12

as was covered in the previous two

play13:14

slides for x2 we don't know its exact

play13:16

value but we know that since we didn't

play13:18

change c2 that means i2 remains

play13:20

unchanged as well so x2 will also remain

play13:23

unchanged otherwise in other words it's

play13:25

unknown its value is unknown but we know

play13:28

that it's unchanged

play13:30

let's also label the last two bytes of

play13:32

c2 of c1 as t2 and t1 respectively

play13:36

let's focus our attention on just the

play13:38

xor operation involving all of these

play13:41

last two bytes

play13:43

over in this diagram over here

play13:45

since we have both x1 and 02

play13:49

we can easily find the value of t1 by

play13:52

xoring x1 and 02

play13:54

so just like that we know the value of

play13:56

t1 now the question is what should t2 be

play13:59

this is where similar to what was

play14:00

covered two slides ago we have to

play14:02

conduct an exhaustive search

play14:04

t2 can only take on values from 0 to 255

play14:06

we just do a simple for loop and the

play14:08

moment the padding oracle outputs yes

play14:10

we'll know what the value of t2 should

play14:12

be

play14:12

now we know the value of t2 we also know

play14:15

the value 0 2 over here

play14:18

we have two entities so we can simply x

play14:20

or 0 2 with t2 to obtain the value of x2

play14:26

now back to the original decryption

play14:28

context we already know the last byte of

play14:31

the plaintext but we're not interested

play14:33

in the last bytes of this ciphertext

play14:35

block or the intermediate state

play14:38

we are interested in finding out the

play14:39

second last byte of the plain text so do

play14:41

you have our hands on the original

play14:43

ciphertext blocks we know the second

play14:45

last byte of c1

play14:47

over here

play14:49

we also found on the previous slide the

play14:51

value of the second last byte of i2

play14:53

which is x2 we found the value of x2 on

play14:56

the previous slide once again this is an

play14:59

xo operation so in order to retrieve the

play15:01

second last part of the plain text over

play15:03

here we simply need to x or c2 with x2

play15:08

and just like that through these past

play15:10

couple of times we have managed to find

play15:11

out the last two bytes of the original

play15:13

plain text in order to find out the rest

play15:15

of the bytes

play15:16

of the plain text we just need to repeat

play15:18

this process for the rest of the blocks

play15:20

i hope you guys get the idea by now

play15:22

ultimately the padding oracle attack is

play15:24

meant to illustrate the idea that

play15:25

something as innocuous as revealing

play15:27

whether the padding is valid when abused

play15:29

in the right context can reveal a lot of

play15:31

information

play15:33

i hope you found this video helpful

play15:34

thank you

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
Padding OracleCybersecurityCryptographyEncryptionBlock CipherCBC ModeXOR OperationsDecryptionPKCS7 PaddingHacking Techniques
¿Necesitas un resumen en inglés?