In December 2012, while John McAfee was on the run in Central America, a Vice journalist posted a photo of him online. The JPEG still contained the GPS coordinates written by the phone that took it, placing him in Guatemala. Someone ran the file through an EXIF viewer within hours.

That's the classic example, and it still happens weekly in smaller ways. Files carry data about themselves, called metadata, and most people never look at it.

What's in there

Photos from phones and cameras store EXIF and XMP data. Depending on the device and settings, you'll find:

  • GPS latitude, longitude and altitude, sometimes with direction of view
  • Date and time to the second, and time zone offset
  • Camera make, model, lens, and often a body serial number on dedicated cameras
  • Software used to edit the image, and sometimes an embedded thumbnail of the original before cropping

That last one has burned people: crop a face out of a photo, and some older editors left the uncropped thumbnail inside the file.

Office documents (.docx, .xlsx, .pptx) store the author name from the software's account, the company name, the "last modified by" user, total editing time, revision counts, and potentially tracked changes and comments that were hidden but never deleted. PDFs keep the author, the producing software, creation dates, and sometimes the original filename or file path of the source document. If your Windows user folder is C:\Users\jsmith, that path can turn up.

Reading metadata with exiftool

exiftool by Phil Harvey is the standard tool. It reads nearly every format there is. Install it from your package manager (apt install libimage-exiftool-perl on Debian and Ubuntu, brew install exiftool on macOS) or get the Windows build from the official site.

exiftool photo.jpg                # everything
exiftool -a -G1 photo.jpg         # show duplicates and which group each tag is in
exiftool -gps:all photo.jpg       # just location
exiftool -r -gpslatitude ./folder # check a whole folder for GPS tags

Run it once on a photo straight off your phone. Most people are surprised.

Stripping it

To remove all metadata exiftool can write:

exiftool -all= photo.jpg

This keeps a backup as photo.jpg_original. Delete that backup, or use -overwrite_original, or you've just made a clean copy and left the dirty one beside it. To clean every JPEG in a folder:

exiftool -all= -overwrite_original -ext jpg -r ./to-send/

If you want to keep orientation so photos don't appear sideways, a common pattern is:

exiftool -all= -tagsfromfile @ -orientation -overwrite_original photo.jpg

Then verify with exiftool photo.jpg again. You'll still see basic file information (size, dimensions, encoding); that's computed from the file, not stored tags.

The PDF catch

exiftool edits PDFs by appending an incremental update. The original metadata is still in the file and can be restored. The exiftool documentation says this plainly. If you need it gone, rewrite the PDF afterwards:

exiftool -all:all= document.pdf
qpdf --linearize document.pdf clean.pdf

Or use mat2 instead.

mat2 and Metadata Cleaner

mat2 (Metadata Anonymisation Toolkit 2) handles images, PDFs, Office and LibreOffice files, audio and more. It's included in Tails, and on Linux there's a friendly graphical front end called Metadata Cleaner.

mat2 --show report.docx   # list what it found
mat2 report.docx          # writes report.cleaned.docx
mat2 --inplace photo.jpg  # overwrite the original

For PDFs, mat2 renders pages to images and rebuilds the file by default, which kills hidden layers and text selection. That's ugly but thorough. --lightweight keeps the text at the cost of being less aggressive.

On your phone

On iPhone, when you share a photo, tap "Options" at the top of the share sheet and switch off "Location". To stop recording location at all, go to Settings, Privacy & Security, Location Services, Camera, and choose "Never". On Android, the camera app has a "Location tags" or "Save location" toggle in its settings, and Google Photos has a setting to remove geo location when sharing by link. Menus vary by manufacturer, so check a test photo afterwards.

Office documents

In Microsoft Word, File, Info, "Check for Issues", "Inspect Document" runs the Document Inspector, which finds comments, revisions, hidden text and personal information. In LibreOffice, Tools, Options, LibreOffice, Security, "Remove personal information on saving". Accept or reject all tracked changes before you do either, and look for hidden sheets in spreadsheets. Honestly, if the document is sensitive, the safer route is often to copy the text into a fresh plain file or export to PDF and then clean that.

What cleaning won't fix

Metadata tools remove tags. They don't change the pixels or the words. A reflection in a window, a distinctive view, a unique typo, or a document that only six people received are all still identifying. Colour printers also add tiny yellow tracking dots that encode a serial number and print time; when The Intercept published a scanned NSA document in 2017, people pointed out the dots were visible in the scan, and the source, Reality Winner, was arrested days later (investigators had other evidence too, including access logs). Journalists who handle leaked material should read how SecureDrop works and think about publishing excerpts rather than original files.

Metadata hygiene is a small part of basic OPSEC, but it's one of the few parts you can check with a single command, so there's no excuse for skipping it.

#metadata #exif #exiftool #mat2 #document-security