RWC 2022: Destroying the Dinosaurs of Steganography with METEOR.

“My Dear Cousin,
Your letter reached me in this Camp where I have been for 2 months among all sort and conditions of Prisoner of War. […]”

Unknown POW during WW1, July 10th 1918

This excerpt shows the first line of the letter sent from an unknown prisoner of war during the first world war to their cousin… or is it? This cleverly disguised letter is not to the POW’s cousin, nor is the message they are trying to send that which is written. Reading the whole letter and spotting the key that is hidden in plain sight reveals the actual message:

“Camp conditions are terrible. Very little food. Bad treatment. Much discontent. But the people have very little. If what we hear is right, they are feeling the shortage.”

The letter contains a brilliant hidden message, can you spot how that was uncovered?[3]

This is a very rudimentary use of the cryptography-adjacent field of steganography: hiding messages within text or images which seem to be written in plaintext. Such a hidden text is, in contrast to a ciphertext, called a stegotext.

Steganography: What is it and how does it work?

In general, steganography is the catch-all name for concealing messages into other pieces of media. This can be, like above, where a secret message is hidden within text, but also applies to other forms of media. More modernly we have seen text hidden in images on the internet [1], or even images hidden within other images[2]. However, as it is with cryptography so it is with steganography: While some applications are malicious many are not.

So how can we formally describe steganography?

A steganographic scheme is a triple of (probabilistic) algorithms:

  • Keygen, which on input of a security parameter generates a symmetric key.
  • Encode, which on input of a key and a plaintext message outputs a stegotext, optionally this protocol can take in consideration the message history.
  • Decode, which on input of a key and a stegotext outputs a plaintext message if the stegotext was valid or an empty string if the stegotext was invalid. Optionally this protocol can take in consideration the message history.

In addition to this the scheme can be equipped with randomness recovery. A concept mostly used in machine learning. Randomness recovery means that given a description of the distribution there exists an algorithm that recovers random coins.

To do this we need two additional algorithms which together form a Ranged Randomness Recoverable Sample Scheme (RRRSS):

  • Sample, which on input of the message history and randomness samples and outputs a sample.
  • Perfect Recovery, which on input of a message history and a sample recovers the exact randomness.

However, the observant reader may notice that this would make steganography completely broken, as the ability to perfectly recover randomness would mean that we can very simply recover the key used in the encoding algorithm, however current state of the art recovery algorithms are not able to uniquely recover the randomness and in fact present a complete set of possible randomness sequences which resulted in the given sample. This is then also the definition for the practical “Recovery” algorithm.

The formal definition of the “Recover” algorithm.[4]#

While this will allow us to formally define Meteor it might be helpful for the intuition to consider some of the challenges that steganography suffers from. In the paper there is a fair discussion about entropy bounding which was expertly addressed in the talk by Gabe Kaptchuk, who explained very clearly that there are cases in which the entropy is near zero. As an example he proposed the following quote:

“The largest carnivorous dinosaur of the Cretacerous period was the Tyrannosaurus…”

Clearly the overwhelmingly probable next word is “Rex”, with really no other option following any natural language form of the English language. This can not be mitigated in steganography, but what Meteor does is to then simply shrug and accept that no information can be encoded in this word.

A far more intuitive issue is that with the above definition each message has to be exact and does not allow for variable message lengths. This is something that Meteor dealt with very elegantly, combining the solution for this with another issue: partial recovery of the randomness.

Lets say, for the sake of exposition, that we have a model to output English text word by word taking into account all previously generated words for the text in question. Once it is time for the model to generate the next word it looks at the conditions, in regards to the message that needs to be encrypted, and uniformly distributes the words on a continuous probability scale.

Say for example that there are m such words, distributed such that \( r_0 \in [00000,00101) \), \( r_1 \in [00101, 10000) \), etc. then the algorithm generates a random five bit value and uses whichever word the value belongs to.

Now one of the big challenges is if, for example, it chooses . While in practice these distributions are much finer (32 bits or higher) the exact value of \( r_i \) can not be retrieved, however the intervals being continuous leads to a possible leakage: If \( r_1 \) is chosen, then the receiver knows (as both the sender and the receiver are aware of the distribution) that the leading bit is a 0. Similarly, if \( r_0 \) had been chosen, then the receiver knows the leading bits are 00.

This is especially problematic if the randomness is generated as a function on the hidden message, and can in fact lead to leakage of the plaintext, not just to the participants, but also to a third party observer. So how can this be solved?

One solution is that you use a pseudo-random number generator (PRG) with a shared (between sender and receiver) keyed state that generates a mask for the randomness. This would not only mask the randomness so it can not be retrieved, it also solves the problem of dynamic input length, as the authors remark – validly – that this can be seen as a stream cipher allowing the number of bits to fluctuate.

That this is a problem that is in need of solving for Meteor is simply explained by looking at the simplified diagram provided in the paper: The bits belonging to the plaintext are the leading bits of the randomness, so if this would leak then the security would be severely hampered.

A simplified overview of the encoding strategy displaying the message bits, the mask (which we will discuss in the next section) and how the next word of the stegotext are chosen.

Meteor: Formally secure steganography in 2022

First the authors of the paper, [4], define the stateful PRG intuitively described above. For this they define two algorithms:

  • PRG.Setup, which takes as input the security parameter and generates the secret state material needed to use the PRG.
  • PRG.Next, which takes as input an integer and generates a random bit-string of that length.

Using these algorithms Meteor is able to define algorithms which, for a set of random bit strings, is able to define the length of the longest shared bit prefix for the generated randomness, and an algorithm which explicitly returns the bit prefix exactly. These are called LenPrefix and Prefix respectively and the formal definition can be found in the following figures.

Formal description of the LenPrefix algorithm
Formal description of the Prefix algorithm

Meteor is instantiated with a generative model and a distribution for the RRRSS as described above. It then proceeds in three steps:

  • Keygen
  • Encode
  • Decode

To generate the symmetric key Meteor makes use of a keygen algorithm exactly as described, outputting the symmetric secret key. This is explicitly described in the following image:

However the truly ingenious part comes in the encode and decode algorithms which are used in Meteor. It is in these that both the sender and the receiver use the RRRSS scheme to recover the (masked) randomness, which they can then use to encode or decode the message. To do this both algorithms require a pre-defined accuracy, which is the number of bits that can be encoded in each iteration, to be given.

One of the main challenges in practice, the authors observe, is to ensure that both ends of the protocol remain synchronized. To obtain this the authors assume that the model’s initial state, that which primes the model, and every subsequently generated token are saved and synchronized between the parties.

The encoding algorithm, see above, then loops through three stages until the entire message has been encoded:

  1. Generate and apply the mask
  2. Sample a next output to append to the stegotext.
  3. Update the synchronized state of the algorithm

The decoding algorithm performs the exact same three-step protocol, but reverses step (1) and (2). As the decoder will know the output of each sampling stage, the Recover and Prefix algorithm then allows the receiver to recompute some leading bits of r. Then it can calculate the mask that was used and removes it, which allows it to recover the bits of the plaintext.

To see that this is correct the authors highlight that this is fully based on the correctness of the RRRSS and the PRG. While the paper goes in full detail on the security and efficiency, this is far too technical for a blogpost.

However, as the author said: “There is still much future work to be done!”, which was reflected in the answers to the questions, from for example Prof. Smart: “As a symmetric protocol, how does Meteor steganographically run key agreement?” – I for one look forwards to the developments in this particular field.

Not instead, but in addition to Cryptography

The question that may remain on your, dear reader, brain is the question that struck me when I was introduced more formally to the field of steganography: “Why do we need this?”. While the question is a natural one there are conditions in which we live that make the privilege we enjoy in this question clear.

There are governments and organisations that have severe restrictions and limitations on the freedom of speech the country’s inhabitants enjoy. An example of this can be seen in the Great Firewall as deployed by China’s CCP. As of the moment of writing many websites and communication from within to outside China is restricted and, in many cases, even attempts to circumvent these restrictions are considered breaches of the social contract or even the law.

And this is where the problem with cryptography occurs: It can well be that an (legitimately) encrypted message is caught in the firewall, causing it to be dropped from communications completely. This can have significant impact on your life or that of your family as an Expat Student found out:

Credit: Tom Mazur, Twitter

This is where Steganography comes in, allowing senders and receivers to have communication hidden within text which – using Meteor – should be indistinguishable from natural language communication within a low margin of error.

A very important factor of steganography is that the system is built on indistinguishability, so while an authoritative entity could still reject the stegotext it could not do so without also rejecting a significant portion (if not all) legitimate communication, rendering the system unworkable.

Clearly, this is not something that will remove cryptography but it can be used in addition to cryptography in situations where this is vital: There where freedoms are limited or where there is a significant fear that you – or those you communicate with – have their letters, phone calls, or emails supervised by a malicious authority, like behind a great firewall or in a WW1 prison camp.