Score:2

Is it possible to craft a valid AES-CBC cipher-text that will decrypt (to random) with any possible key?

br flag

I am mainly looking to perform this trick for fun. I have access to an API that uses WebCrypto under the hood for encrypt and decrypt methods. I would like to hijack the decrypt method in order to create a deterministic seed.

I have read other articles, and it seems like this trick should be relatively straight-forward, as AES-CBC does not have any integrity checks (that I know of). My understanding is that if the block-padding is correct, then a standard cipher-text payload should successfully decrypt using any secret key, even if that payload decrypts into random nonsense.

In practice, this doesn't appear to work, and I am not sure why. I can brute-force my way through by starting with a payload and iv of all zeroes, and incrementing by one until I produce a valid cipher-text that can be decrypted by a given key, but that cipher-text will fail when decrypted by another key.

I would like to figure out, if possible, how to craft a cipher-text that has no known solution, but can be decrypted by any given key in order to produce a deterministic random seed.

Any help or expertise would be greatly appreciated, as I would like to show this off for an upcoming hackathon event. Thank you!

Maarten Bodewes avatar
in flag
You're failing because the PKCS#7 compatible padding will (most likely) fail. If you can try and use CTR mode instead, as it doesn't pad, or unpad.
canary avatar
ch flag
I think it's straight forward if the decryption key is fixed for every (attack) session.
canary avatar
ch flag
is it you who provides the IV to the Oracle decryption? if so, you can just try 256 IVs at most to get a valid decryption.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.