Skip to content

False Positives

Every claim in this chapter was planted in, or harvested from, the guide's own 78 KB specimen. That is the point: you do not need a hostile image to meet false positives. A signature scan of anything produces them, because a signature is a short pattern and short patterns occur by accident.

The plain scan of the specimen showed three rows. Run the same scan with -I — "show results marked invalid" — and the table grows two more:

$ binwalk -I specimen.bin

65536         0x10000         Squashfs filesystem, ...
69632         0x11000         gzip compressed data, ...
69776         0x11090         gzip compressed data, ...
76003         0x128E3         Microsoft executable,
78144         0x13140         gzip compressed data, invalid extra flags, has original file name: "s not really a gzip stream, just its first bytes", last modified: 2031-05-11 17:44:20

(and on stderr: WARNING: gzipvalid.scan failed [IndexError]: 'string index out of range')

The three exhibits

The trap, at 78144. The first bytes of a gzip stream, planted deliberately, with junk behind them. Binwalk's gzip signature parsed the header fields — and the fields are all technically there, which is why the description can quote them: the "original file name" is the ASCII junk that followed the magic, reinterpreted as a filename; the "last modified" date of 2031 is junk bytes read as a timestamp. The validator judged the header invalid ("invalid extra flags") and the plain scan suppressed the row entirely. Two lessons in one row: descriptions quote fields whether or not the fields make sense, and a plain scan is a filtered scan — when an expected member is missing, -I is how you find out whether binwalk saw it and disbelieved it.

Even better, the validator didn't merely dislike the trap: it crashed on it, and binwalk printed the WARNING with the exception and carried on. Validators are software with edge cases, exactly like everything else in this guide. A suppressed row can mean "checked and false" or "the check itself fell over." -I plus your own inspection is the only way to tell.

The phantom executable, at 76003. Offset 0x128E3 sits inside the specimen's random-data region. It is, byte for byte, noise — and somewhere in 8 KB of noise, the few bytes that begin a "Microsoft executable" signature occurred by chance. Short magics are cheap to match, so chance matches are guaranteed on a long enough file: 411 signatures against megabytes of data is millions of lottery tickets. The longer and more structured a signature (SquashFS's superblock, with version and size fields that must agree), the more a hit means; a two-byte magic means almost nothing on its own. This row too was marked invalid and hidden by the plain scan — but on a real image, plenty of accidentals pass validation, because the accident only has to satisfy the fields the validator checks.

The plausible lies. Not false exactly — worse, true-but-misleading. The tar inside the nested gzip was described with an owner user name of "ker.txt" — a real field, really read, holding the tail of a filename because the specimen's tar was built with an empty user-name field and the bytes landed where they landed. And the genuine gzip members announce "last modified: 1970-01-01" because the specimen builder set their timestamps to zero. Headers say what headers say. A description is a transcription, and transcriptions inherit every error in the original.

The discipline

Four working rules, all earned above:

  1. A hit is a hypothesis. It graduates when something independent confirms it: the member extracts, the extracted file checks out (a checksum, a readable page, a filesystem that lists), or an entropy edge and an offset agree with a layout you know from elsewhere.
  2. Mind what the plain scan hides. Use -I whenever reality and the table disagree — an expected member absent, a region unaccounted for. Suppressed rows are still information.
  3. Weigh signatures by their structure. A match on a long, field-checked signature is evidence. A match on two magic bytes, especially inside compressed or random data, is a lead at best. (Compressed regions are full of accidental patterns, which is why scans of extracted files are more trustworthy than scans across compressed boundaries.)
  4. Verify by extraction or not at all. The specimen's real members survived carving, unpacking, and a checksum. The trap and the phantom would have failed at the first of those gates. Extraction is binwalk's built-in lie detector — when a row matters, make it pass.

Check: given any scan table, you can now say which rows are structural (long signatures, consistent fields, extractable), which are accidental (short magics inside high-entropy regions), and which aren't in the table at all until -I admits them — and you have seen all three kinds in one small file you built yourself.