ECB Oracle
Last updated
Last updated
An oracle is a type of tool or service that can provide information about a cryptographic algorithm, often with the goal of breaking it.
Most of the time, an attacker might use a chosen plaintext attack to submit carefully-crafted plaintexts to the encryption function and observe the resulting ciphertexts in order to build a dictionary of plaintext/ciphertext pairs that can be used to decrypt other blocks.
Some elements are required to exploit an oracle :
Ability to submit plaintext messages
Ability to observe ciphertexts
Ability to repeat these actions
As explained , AES using ECB mode will always produce the same ciphertext for the exact same plaintext input.
So the attacker can list every single possibility for each block and then break the cipher.
As AES cipher block of size 16 bytes. there is 340282366920938463463374607431768211456 ( ) possibilities.
What if the attacker can inject some data directly into the targeted cipher message such as :
The user can inject as many byte as he want.
Furthermore, AES will always encrypt blocks of size 16. If the input block is shorter than 16 bytes, then it will be padded, typically using .
By injecting enough data, the last block can be known :
The attacker can inject this block as plaintext input + enough padding to make the plaintext match the block size and then compare his injected block and the last one.
Using this behavior, if the user add 1 byte to the input, the last block will be :
Just has the last block, the user can manipulate him input in order to know exactly what there is as second block :
Once the first or the last block is fully decrypted, it's possible to start again with the direct next block such as sending enough data to obtain the following block :
Where SECRETDATABLOCK1
is the first decrypted block so ECRETDATABLOCK1
are the last 15 bytes of the first block and X
is the first byte of the next block.
To obtain this block the user may send 16 bytes ( block used to bruteforce the targeted byte ) + 15 bytes to have :
Then, when the second block is obtain, it's possible to continue till the obtention of the entire secret value.