How to Hide Information in Images

By  on  

If you've followed this blog, you know that I'm obsessed with figuring out every way to interact with, abuse, and convert different types of media.  Whether it's images, video, or audio, if something can be changed or exploited, I want to figure out how to do it.

I remember reading in the past about how images could be used to pass on "secret" information or even install viruses, all the while displaying as proper images in browsers; this process is called steganography.  I wanted to figure out how you could exploit an image to, at the very least, contain information not visible to the user.  Let's look at a few different methods!

Adding EXIF Data

Unbeknownst to most users sharing photos, those images have data attached to them that the photographer realizes: latitude and longitude, device, and lots of other information.  For this reason alone I wrote Get and Remove EXIF Data, a post every service that allows image uploads should read, simply to keep their users privacy.

You can set EXIF data in an image to pass on dubious information:

# Put information in the EXIF
exiftool -artist=MY_SEMI_SECRET_DATA walshcoin.gif

# Retrieve the new info from the EXIF
exiftool walshcoin.gif

The image displays just as it did before but passes information unseen to the user!

Concatenating ZIP Files and Images

This method is the scarier of the two I'll illustrate.  You can actually concatenate an animated GIF and a ZIP file and the image will display while you can also unzip the GIF!

# Concatenate a legit GIF with a secret ZIP file!
$ cat bitcoin.gif >> bitcoinsecret.gif
$ cat >> bitcoinsecret.gif

# When you unzip the file, the secret file is there!
$ unzip bitcoinsecret.gif

It's wild that you can concatenate an image and a ZIP file and the result is both extractable and displays properly in a browser!

The methods I've illustrated in the post are incredibly tame -- there are likely many other dubious ways to exploit images so that the average user doesn't know that they're vulnerable.  The ease with which you can add arbitrary information to an image should be unsettling -- the images, at face value, show no sign of modification, but the truth is that they can tell a different story to someone looking for that information!

Recent Features

  • By
    Conquering Impostor Syndrome

    Two years ago I documented my struggles with Imposter Syndrome and the response was immense.  I received messages of support and commiseration from new web developers, veteran engineers, and even persons of all experience levels in other professions.  I've even caught myself reading the post...

  • By
    9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that...

Incredible Demos

  • By
    Animated AJAX Record Deletion Using MooTools

    I'm a huge fan of WordPress' method of individual article deletion. You click the delete link, the menu item animates red, and the item disappears. Here's how to achieve that functionality with MooTools JavaScript. The PHP - Content & Header The following snippet goes at the...

  • By
    NSFW Blocker Using MooTools and CSS

    One of my guilty pleasures is scoping out the latest celebrity gossip from,, and Unfortunately, these sites occasionally post NSFW pictures which makes checking these sites on lunch a huge gamble -- a trip to HR's office could be just a click away. Since...


  1. Hi, David,

    what you are describing here is known as Steganography:

    Of course, there are packages on npm for this:

    I haven’t looked into their implementation, yet.



Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!