Photo by Alvaro Calvo on Unsplash

Base64 is Malleable!

--

First, let’s start with some basics.

Base64 is a way of representing binary data in the form of text, and is used for exchanging encryption keys, ciphertext, file attachments in emails, and so on. It can also be used to create a thumbprint for a data object, and in representing a digital signature. It is thus important that it gives us a reliable result. And what is malleable in coding? Well, it is where we operate on something, and for it to change it result. For example, if we add five to a value, and then subtract by five, we should get the original value. If not, our code is malleable.

A bit of magic

Let’s take a Base64 encoded string, and decode it to a byte array and print the answer. Next, we will take this byte array and convert it back into a Base64 string and print it. And — as if by magic — the value for the Base64 string generated differs from the original.

So let’s try with a range of values from a byte value of “0000 0000” (0x00) to “1111 1111” (0xFF) [here]:

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.