October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

What Is a Polyglot File? How Can One File Be Valid as Multiple File Formats?

A polyglot file is one byte stream that two or more parsers accept as valid. Here is how that works, a JPG+JAR example, and why identifying such files is still an open problem.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A polyglot file is a single byte stream that two or more file-format parsers each accept as valid. The bytes never change, but each program reads them under its own format rules, so the same file can be an image to one program and executable code to another. Whether a file “is” a given format depends on which parser reads it and what that parser allows. The file name and one identification result do not settle the question.

What a polyglot file is

In the 2022 paper Toward the Detection of Polyglot Files, a polyglot is defined as a file that can be successfully interpreted as two or more types. There is one file on disk, but more than one format parser can make sense of its contents.

As an Amazon Associate I earn from qualifying purchases.

That is different from simply renaming a file. Changing photo.jpg to photo.zip alters only the label. A polyglot is a property of the bytes themselves: each of the formats it claims must accept those same bytes under that format’s rules. The label is incidental.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How one file can satisfy two formats

Each format specification defines which structures must appear, where they must sit, and what extra material a reader is willing to ignore. Parsers differ in how strictly they apply those rules. A polyglot exploits the gap between what one reader requires and what another tolerates. Three factors determine whether a given pair of formats can coexist in one file:

#1 Best Overall
  • Header and structure position. Some readers look for a signature at the start of the file, while others locate their structures by scanning from the end or by following internal offsets.
  • Tolerance for surrounding data. Some readers ignore bytes before their header or after their end-of-file structure. Those ignored regions are where another format’s data can sit without breaking the first reader.
  • Parser behavior. Two programs that both claim to support the same format may disagree about edge cases, so a file can pass one implementation and fail another.

Glasswall’s technical overview discusses image and PDF examples of this kind of format-specific tolerance. Treat those as illustrations rather than a standards reference. Not every pair of formats can be combined, and whether a particular pair works depends on the specific format rules and parser implementations involved. The 2022 paper and the sources reviewed here do not provide a complete catalogue of workable format pairs.

Worked example: a JPG and a JAR

The 2022 paper gives a concrete case: a JPG+JAR file that appears as an ordinary image when opened in an image viewer, but executes self-extracting Java code when it is supplied to the Java Runtime Environment. The same bytes produce two different outcomes because two different programs parse them.

This example changes the useful question. Asking “What is the extension?” tells you little. The more productive questions are which program will parse these bytes, which format rules it applies, and what it does with the result. The paper presents this as one example, and it does not establish that every JPG and JAR combination behaves this way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why one successful interpretation is not enough

Many file-handling pipelines work in a fixed sequence. They identify a file once, choose a processing path based on that identity, and move on. If the identification step recognizes only the image interpretation, the file may be routed to an image handler and never examined as a Java archive. The paper states that polyglots can confuse file-type identification and allow parts of a file to evade analysis.

The table below compares common identification methods by what they establish and what they leave open.

Identification method What it tells you What it cannot tell you
File extension The name a user or application assigned How any parser will read the bytes
Declared MIME type (from an upload form or server header) The type the sender or server asserted Whether the content matches that type, or whether another parser accepts it
Single signature check (magic bytes at known offsets) That a known header is present Whether other structures are valid, or whether a second format’s parser also accepts the file
Full parse by each relevant format parser Whether that specific parser accepts the file, and what it extracts How parsers not tested will behave; the 2022 paper describes accurate identification as an open problem

No single row above is sufficient on its own. A signature match is a useful starting point, not a conclusion.

Why detection remains difficult

The 2022 paper, by Luke Koch and coauthors, was published in the Proceedings of the 15th Workshop on Cyber Security Experimentation and Test on August 8, 2022. Its abstract states:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Although work has been done to identify file types using more comprehensive methods than file signatures, accurate identification of polyglot files remains an open problem.”

Best Value
Hczrc Portable Scanner, Photo Scanner for A4 Documents, Handheld Scanner for Business, Photo, Picture, Receipts, Books, JPG/PDF Format Selection, UP to 900 DPI, with 16G SD Car
  • Note: No software installation is required. You need 2 AA batteries ( not included) and a memory card ( included) to use it directly. Scan mode: Press and hold "Scan" for 2 seconds to turn on the device, and then press "Scan", the green light is on. The scanner moves to scan the file until the green light turns off automatically (or press the "Scan" key and the green light goes out). The number shown on the display increases by 1 to indicate that the scan is complete.
  • Portable Scanner scans images or pictures quickly: Store JPEG/PDF files within seconds, scan images or pictures quickly, plug and play, no need any software preinstalled. Compatible with Windows XP/7/Vista/Mac OS 10.4 or above version.
  • Lightweight and travel-friendly: Stored in Micro SD card directly, support read data on your computer or phone with USB connected. Powered by 2pcs AA batteries, Compact Design, it is convenient to carry outside.
  • 3 Image Resolution: 3 modes of resolution for your options: 300dpi/600dpi/900dpi, you can save it at the clearest way, picture and document are showed clear as it is. Freely choose your favorite resolution.File Format: JPEG/PDF format is all available, Great storage capacity as it supports 32G Micro SD card(Included 16GB Card),total meet your need for business trip or daily use.
  • Widely Used: It is applicable in bank, insurance business, real estate agency,home, office, library or outdoors. suitable for lawyer, businessmen, students, travelers and amateur archivists. Scan your important files and save them immediately, no struggling in finding a printing shop, keep it confidential.

That sentence describes the state of the field as of 2022. It is not a measured claim about every detector available today.

A 2024 arXiv preprint, On the Abuse and Detection of Polyglot Files, continues this line of work and includes attack-chain and format-pair examples. This article does not cite a detection accuracy figure. The sources reviewed do not provide one with a clear publisher, year, test set, and set of conditions, so any number would overstate what is established.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Practical implications for analysts and defenders

  • Do not treat an extension, a declared MIME type, or a single signature match as proof of a file’s complete structure.
  • When a file will be consumed by more than one program, consider each consumer’s parser rather than only the first one in the chain.
  • Record disagreement between parsers as a finding in its own right, instead of choosing the interpretation that is most convenient.
  • Check which formats a detection tool actually implements. A detector covers only the formats and parser behaviors it supports.

What the term does and does not establish

A file that two parsers accept is a polyglot, but that alone does not make it malicious. Multi-format files can have legitimate uses, and the term describes a structural property, not intent. The risk depends on the workflow: a file that is harmless in one environment may behave differently in another with a different parser, a different runtime, or different permissions. Whether any code runs, and what it does, depends on the environment in which the file is processed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In short, a polyglot is best understood as a question about parsers. For any file that matters, the useful test is not what its name says, but which programs will read it, under which rules, and with what result.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.