{
  "id": 22628830,
  "title": "Why entropy can't see XOR-obfuscated code (and what to measure instead)",
  "url": "https://urgent.news/2026/11/29/why-entropy-cant-see-xor-obfuscated-code-and-what-to-measure-instead",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-29T17:59:58.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gem3match/why-entropy-cant-see-xor-obfuscated-code-and-what-to-measure-instead-58ab"
  },
  "original_language": null,
  "account": "Traditional packer and obfuscation detectors assess entropy levels to determine if code is compressed or encrypted. The common heuristic considers entropy values above ~7.0 as \"compressed or encrypted,\" while lower values suggest normal code. However, this approach has a significant blind spot: it fails to detect XOR-obfuscated code. The more reliable metric that doesn't fail to identify XOR-obfuscation is a bijection, which maps each byte value to exactly one other byte value, preserving byte frequencies and entropy. Shannon entropy is calculated based on byte frequencies, and a bijection does not alter the counts, meaning XOR-encrypted data retains the same entropy as the original code. This property holds true for any key k, making it an exact identity rather than an approximation. Measurements of entropy and disassembly coverage reveal that XOR-obfuscated code has the same entropy as original code, but the decoder cannot form valid instructions, resulting in a coverage of 0.00%. A simple detector measuring coverage (by counting valid instruction bytes) can identify undecodable code due to XOR-obfuscation without needing any key, unpacking, or execution. Once the tool measures coverage, recovering a single-byte XOR key becomes straightforward - trying all 255 possibilities and keeping the one that produces a valid decoder. In practice, applying this technique to a real DLL restored the file to its original state, with SHA256 and SSDEEP verification confirming the authenticity. Initial tests on established PE packer detectors, entropystrip and packerscope, showed no difference in the output between original and XOR-obfuscated files, highlighting the limitations of entropy-based detection methods. However, the proposed solution addresses the issue by measuring code decoding capability rather than relying solely on entropy. This approach is not foolproof - it does not cover multi-byte XOR, block ciphers, virtualized code or malicious obfuscation, as the key search does not scale. The detector also emphasizes that failing to load a file due to reasons other than single-byte XOR, such as broken import tables or missing dependencies, will result in normal coverage readings and a false negative result.",
  "summary": "Most packer and obfuscation detectors threshold on Shannon entropy. Above ~7.0 means \"compressed or encrypted\", below means \"probably fine\". That heuristic has a blind spot big enough to drive a truck through, and it is the most common obfuscation there is. The measurement that doesn't move XOR is a bijection. It maps each byte value to exactly one other byte value, one-to-one. Shannon entropy is…",
  "summary_source": "publisher",
  "key_points": [
    "Traditional detectors fail to identify XOR-obfuscated code.",
    "Bijection mapping preserves byte frequencies, retaining entropy.",
    "Coverage measurement detects undecodable XOR-obfuscated code."
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}