Skip to main content

New : Cipher Breaker, the codebreaking assistant, is now on Android Discover

▮ CipherChronicle

Image methods Image file

PNG metadata

An image file holds more than pixels. It also carries metadata: author, software, date, comment. Slipping a message in there is the simplest hiding place there is, and the first one anyone checks.

How does PNG metadata work?

A PNG is a series of chunks. Each carries a four-letter type: IHDR for the dimensions, IDAT for the compressed pixels, IEND for the end. Three types are meant for text:

  • tEXt: Latin-1 text;
  • zTXt: the same, compressed;
  • iTXt: international text, in UTF-8.

A text chunk holds a keyword (79 characters at most, for example Title, Author, Comment) followed by the text. Hiding a message means adding such a chunk before IEND, with the keyword of your choice.

… IDAT  IDAT  [ iTXt: Comment = "meet at midnight" ]  IEND

The pixel chunks are not touched: the image is identical, bit for bit.

What does a file processed this way look like?

Exactly like the original image. Only the file size grows, by the length of the message plus about twenty bytes.

The message does show up in the “Info” or “Properties” window of many programs, and in any tool that lists metadata (exiftool, pngcheck -t).

What are the weaknesses of this method?

Strengths

  • No change to the image: no pixel analysis can detect anything.
  • No practical size limit.
  • Standard format: any tool can read the field back.

Weaknesses

  • Readable by anyone. Metadata is meant to be read; the message sits there in the clear.
  • Stripped by most platforms. Social networks and messaging apps remove metadata, for privacy.
  • Stripped by re-saving in an image editor, depending on its settings.
  • No key. For a real secret, encrypt the text before storing it.

How do you recover a message from metadata?

List the chunks of the file. exiftool image.png or pngcheck -t image.png print every text field; strings shows them too, since they are not compressed. It is one of the very first reflexes in a steganography challenge.

What are the variants?

  • EXIF fields — in a JPEG, the same ideas apply to EXIF fields (comment, description, fake GPS coordinates).
  • Compressed text (zTXt) — the message no longer shows up with strings.
  • Split message across several fields, or hidden in an unexpected one (colour profile, software name).
  • Private chunk — an invented chunk type that common tools do not display.

In CipherChronicle

The workbench writes an iTXt chunk under the keyword of your choice (Comment by default). To decrypt, drop the received file as is and give the same keyword. In a chain, this method comes last when encrypting: it acts on the file, not on the pixels.