Skip to content

Research notes / Recovery correctness

Restoring file names: when matching hashes hide a lost entry

Published / Updated / Controlled software experiment

Correct file contents do not establish correct file identity. When a restore maps two source names to one destination name, both expected payload checks can pass if the contents are identical. One directory entry is still missing.

On this page13 sections

A passing content check can hide a collapsed namespace

Our 48 disposable copy cases included 20 deliberately colliding transformations. In 10 of those cases, both source-content checks passed through the transformed names even though only one output entry existed. This is a counterexample to a verification rule, not a measured rate of backup failure.

We created two real files per case, transformed each name in the application, and copied to a fresh directory using ordinary overwrite mode. The underlying mount preserved the original byte names in every identity control. We did not configure a case-insensitive filesystem or emulate NTFS, APFS or ext4 casefold.

Each row was run in both copy orders with equal and distinct contents, plus original-byte controls. Unicode escapes distinguish names that may look alike; the invalid-input row uses hexadecimal bytes.
FixtureTwo source namesApplication transformationOutput entries
Canonical equivalentscaf\u00e9.txt / cafe\u0301.txtNFCOne name
ASCII caseReport.txt / report.txtCase foldingOne name
Case expansionStra\u00dfe.txt / STRASSE.txtCase foldingOne name
Compatibility equivalents\u2460.txt / 1.txtNFKC, casefold, NFKCOne name
Invalid UTF-8ff 2e 74 78 74 / fe 2e 74 78 74Decode with replacementOne name
Distinct controlalpha.txt / beta.txtNFC, casefold, NFCTwo names

For distinct contents, reversing the copy order changed which payload survived each collision. For equal contents, the surviving bytes matched both expectations. Counting and comparing the original byte-name inventory detected the loss in both situations. Content deduplication does not justify dropping names: separate paths can carry separate roles even when their bytes happen to match.

Bytes, code points and normalized names are different identities

A character encoding connects text with its stored representation. Unicode code points identify positions in a codespace; encoding forms represent scalar values as code units. Neither a byte count nor a code-point count is a general count of displayed characters. [11, sections 2.4-2.6 and 2.11]

UTF-8 encodes each Unicode scalar value in one to four octets. Surrogate code points are excluded. UTF-8 has no little-endian or big-endian variant: its byte order is fixed, unlike the choice of byte order for UTF-16 code units. An encoding label and an explicit invalid-input policy belong in a recovery contract. [12, sections 3, 4 and 6]

Six fixed strings, without a byte-order mark or terminator. Hexadecimal bytes describe UTF-8; UTF-16 units are a different representation count. These are executable encoding examples, not filesystem measurements.
Code-point sequenceUTF-8 hexUTF-8 bytesScalar valuesUTF-16 units
U+004141111
U+20ACE2 82 AC311
U+1F600F0 9F 98 80412
U+00E9C3 A9211
U+0065 U+030165 CC 81322
U+2460E2 91 A0311

The precomposed U+00E9 and the sequence U+0065 U+0301 have different UTF-8 bytes but the same NFC result. Unicode normalization supplies a specified equivalence rule; it does not recover the original spelling or establish a destination filesystem's lookup policy. NFKC also maps U+2460 to U+0031, removing the circled-digit distinction. [1, sections 1.1-1.2]

Chunk boundaries matter: U+0065 and U+0301 are each already NFC, but concatenating them requires normalization again to obtain U+00E9. Independently normalized fragments are not guaranteed to form normalized text. Keep original bytes when preservation is required, and assess complete names under the actual destination contract before writing output. [1, section 1.4]

Byte chunks introduce a separate boundary: E2 82 followed by AC is valid UTF-8 for U+20AC, although neither chunk is a complete UTF-8 string. Keep one streaming decoder across transport chunks and finalize it at end of input; strict finalization must reject an unfinished sequence. Streaming decoding preserves byte-sequence state, but does not normalize the resulting text. [13, TextDecoder.decode]

The executable examples, regression tests and exact results also check rejection of selected invalid UTF-8 sequences. They exercise runtime encoding and normalization, not every Unicode conformance case, archive utility or filesystem. No additional restore experiment is claimed.

ASCII is a byte contract, not every single-byte decoder

ASCII has 128 seven-bit code positions, including controls. Its usual eight-bit representation keeps the high bit zero: hexadecimal 00 through 7F. NUL and DEL are codes in that repertoire, not printable letters. An ASCII-only check therefore does not establish whether a name is allowed by a destination format. [ASCII code table]

UTF-8 preserves those single-byte values, but also represents text outside ASCII. For example, C3 A9 encodes U+00E9 under UTF-8 and fails strict ASCII decoding. Conversely, bytes wholly within the ASCII range cannot distinguish ASCII from UTF-8 or identify their original encoding. [Unicode 17, section 2.5.3]

Constructed byte sequences decoded by Python 3.12.3, errors="strict". Values are hexadecimal; Unicode code points are shown instead of rendering controls. The exhaustive one-byte sweep accepts 128 inputs as ASCII and rejects 128. No filename API is exercised.
BytesStrict ASCIIStrict UTF-8
41U+0041U+0041
00U+0000U+0000
7FU+007FU+007F
80rejectedrejected
C3 A9rejectedU+00E9
FFrejectedrejected

There is also an API trap: WHATWG TextDecoder maps the labels ascii and us-ascii to windows-1252. Even new TextDecoder("ascii", {fatal: true}) decodes byte 80 to U+20AC; it is not an ASCII-only validator. Record the decoder API and resolved encoding alongside the label and error policy. A fatal error mode applies to the selected encoding, not to an assumed repertoire. [WHATWG label resolution]

Another API gives a third answer: Node.js buf.toString("ascii") on a Buffer instance clears the high bit, so bytes 41 and C1 both become A. This is neither strict rejection nor WHATWG decoding. In the opposite direction, Buffer.from(text, "ascii") uses the latin1 encoding behavior. A successful conversion or an ASCII-looking result therefore does not prove that the input obeyed an ASCII-only contract. The downloadable tests exhaust all 256 byte values for this masking behavior and include a non-reversible round trip. [Node Buffer contract]

Masking can also create structural characters: 80 becomes U+0000, AE becomes a dot, AF a slash and DC a backslash. Bytes 61 AF 62 contain no slash byte, yet decode to a/b. Testing only the converted output cannot establish the original ASCII byte contract. These in-memory tests do not open paths or demonstrate a filesystem vulnerability. [Node Buffer contract]

For a genuinely ASCII-only metadata field, reject bytes outside 00 through 7F before display conversion, then apply the format's separate value rules. Replacement decoding is not lossless: distinct 80 2E 74 78 74 and FF 2E 74 78 74 inputs both become U+FFFD followed by .txt under Python's ASCII replacement policy. Preserve original bytes when recovery requires a reversible name mapping.

The reproduction instructions, Python probe, codec tests, WHATWG API tests and recorded observations cover 256 one-byte inputs and bounded multi-byte examples. They do not detect unknown encodings, certify all decoder implementations or add filesystem observations to the restore experiment.

Latin-1 and Windows-1252 need different decoding contracts

ISO-8859-1 (Latin-1) and Windows-1252 are separate registered identities. Their shared letters do not make their byte mappings interchangeable. Unicode's Latin-1 mapping includes control characters; Windows-1252 adds punctuation and symbols in that area, including U+20AC at hexadecimal 80. Distinguish a graphic-character standard from a codec's complete mapping of byte values. [IANA registrations] [Latin-1 mapping] [CP1252 mapping]

All 256 one-byte inputs, tested with CPython 3.12.3 and Node v24.22.2, ICU 78.3. Accepted counts concern decoding only, not valid filenames. Code points make control characters visible.
API and labelByte 80Accepted / 256
bytes.decode
latin-1
strict
U+0080256
bytes.decode
cp1252
strict
U+20AC251
TextDecoder
latin1
fatal
U+20AC256
TextDecoder
iso-8859-1
fatal
U+20AC256
TextDecoder
windows-1252
fatal
U+20AC256
Buffer.toString
latin1
not configurable
U+0080256

Strict CPython cp1252 rejects exactly 81, 8D, 8F, 90 and 9D, the historical table's undefined positions. WHATWG's completed index instead maps them to corresponding control code points. Its fatal: true mode therefore accepts them. These are different contracts, not evidence that a decoder ignored its error policy. [CPython implementation] [WHATWG index]

Even the same runtime and label can disagree: Buffer.from([0x80]).toString("latin1") produces U+0080, while new TextDecoder("latin1", {fatal: true}).decode(Uint8Array.of(0x80)) produces U+20AC. Node documents this distinction. Record the API, label, resolved encoding and error policy with a legacy filename inventory. [Node Buffer encodings]

An encoder with the same label is not necessarily the decoder's inverse. In our separate Node v24.22.2 census, decoding through TextDecoder("latin1") with fatal: true and re-encoding through Buffer.from(text, "latin1") changes 27 of 256 possible one-byte inputs. Buffer truncates code points above U+00FF: hexadecimal 80 becomes U+20AC and then AC; 9B becomes U+203A and then 3A. Distinct inputs 22, 95 and 99 all become 22. A Buffer-only decode/encode control preserves every byte. These are in-memory conversion results, not measured filename failures. [Node encoder contract] [Complete census] [Executable probe]

A successful decode, or a round trip within the chosen codec, does not identify the intended encoding. With CPython's cp1252 decoder and errors="replace", distinct bytes 81 and 8D both become U+FFFD. Retain original bytes before interpreting or normalizing names; do not turn these recovery examples into a recommendation for legacy encodings in new interchange.

The method and source references, Python runner, Node probe, regression tests and complete mappings with runtime versions and hashes make these constructed examples reproducible. No filesystem operation, encoding detection or incident-rate estimate is involved.

Which length limit does a filename actually satisfy?

A Unicode scalar value excludes surrogate code points, but includes unassigned values and noncharacters. Scalar validity does not establish that a filename API accepts a value. In UTF-16, a supplementary scalar uses a surrogate pair; cutting that pair in half leaves ill-formed text. [14, section 3.9]

A grapheme cluster groups text using specified boundary rules. The default extended rules approximate user-perceived characters, not necessarily rendered glyphs. They differ from legacy or tailored rules. Use an explicit segmentation version and profile; do not treat a cluster count as a byte quota. [15, section 3]

Constructed strings segmented with Intl.Segmenter, locale en, granularity grapheme; Node v24.22.2, ICU 78.3, Unicode 17.0. Counts exclude a byte-order mark and terminator. These four examples are not a complete UAX #29 conformance test.
Input code pointsLength by unit
U+0065 U+03013 UTF-8 bytes; 2 scalar values; 2 UTF-16 units; 1 grapheme cluster
U+1F1F5 U+1F1F18 UTF-8 bytes; 2 scalar values; 4 UTF-16 units; 1 grapheme cluster
U+1F469 U+200D U+1F4BB11 UTF-8 bytes; 3 scalar values; 5 UTF-16 units; 1 grapheme cluster
U+0061 U+00622 UTF-8 bytes; 2 scalar values; 2 UTF-16 units; 2 grapheme clusters

For e\u0301.txt, retaining the first scalar produces only e; retaining the first cluster keeps the combining accent too. Taking the first two UTF-8 bytes instead leaves an incomplete sequence. Conversely, a followed by 100 combining acute accents forms one cluster but occupies 201 bytes. Shortening a display label and preserving a recovery identifier are different operations: keep the original name or an explicit reversible mapping.

Equal counts can hide different boundaries. Split the regional indicators U+1F1F5 | U+1F1F1 U+1F1E6 into two chunks: independent segmentation gives [P] [L A], while segmenting the complete sequence gives [P L] [A]. The letters here name indicator code points, not ASCII input. Both partitions contain 2 clusters and identical scalars. UAX #29 pairs indicators using preceding-run parity. Process complete names, or use a stateful segmenter with documented boundary handling; summing chunk counts is insufficient. [15, rules GB12-GB13]

The length probe, regression tests and recorded counts and runtime reproduce these bounded examples without normalizing input. The probe also imports the encoding helper; place both modules together to run it. Intl.Segmenter boundary determination is implementation-dependent, so matching these examples does not certify every Unicode boundary or a filesystem's name policy. [16, FindBoundary]

UTF-32 still needs a byte-order contract

UTF-32 uses one 32-bit unit per scalar value. That is not a fixed width for a displayed character. The accented spellings below still occupy different amounts of storage. [17]

Constructed strict-codec examples, excluding a BOM and terminator. Recorded with CPython 3.12.3; no filesystem observations.
Input scalarsBytes by encoding
U+00411 UTF-8; 2 UTF-16BE; 4 UTF-32BE
U+00E92 UTF-8; 2 UTF-16BE; 4 UTF-32BE
U+0065 U+03013 UTF-8; 4 UTF-16BE; 8 UTF-32BE
U+104004 UTF-8; 4 UTF-16BE; 4 UTF-32BE

The same four bytes 00 00 01 00 decode successfully as U+0100 in UTF-32BE and U+10000 in UTF-32LE. A strict decoder therefore cannot infer the intended order merely because input is valid. A checksum of the bytes would also be unchanged: it verifies neither the encoding label nor the intended name.

Generic UTF-32 recognizes an initial BOM and otherwise defaults to big-endian unless a higher-level protocol overrides it. Explicit UTF-32BE/LE already specifies the order and treats initial U+FEFF as content. Do not silently substitute a runtime's native-endian default for that contract. [14, section 3.10, D99-D101]

API choice also matters. In the recorded CPython 3.12.3 runtime, bytes.decode("utf-32") accepts the BOM-less example using native byte order, but codecs.getincrementaldecoder("utf-32") rejects the same complete unit without a BOM. The tests cover every split of that unit and of BOM-prefixed input in both byte orders. Specify the reader's BOM policy as well as the encoding label. [18]

Preserve the encoding label, BOM policy and original bytes with recovery metadata. Transcoding alone does not normalize the two accented spellings or settle destination-name equality. [1, sections 1.1-1.2] The Python probe, regression tests and recorded results use explicit-endian codecs; additional controls cover surrogate rejection, BOM handling and incomplete-stream finalization. These examples do not certify Unicode conformance or a filesystem's naming rules.

Normalization, case folding and decoding answer different questions

NFC and NFD give canonical equivalents a common representation; NFKC and NFKD also merge compatibility distinctions. A circled digit and an ordinary digit remain different under NFC but coincide under NFKC. Normalization is therefore not a universally lossless filename cleanup operation. [1]

Case folding is separate from normalization and can expand a character: Python folds the German sharp s to two ASCII s characters. Our policy labels specify the exact operation order. The label nfkc-casefold means NFKC, Python casefold, then NFKC; it is not an implementation of Unicode's separately defined NFKC_Casefold operation. [5]

Invalid UTF-8 introduces another choice. Our strict policies reject the two invalid byte names. Decoding with replacement turns both into the same replacement-character name. Python's filesystem interfaces can preserve Unix names using bytes or the filesystem encoding/error handler; an exported JSON display string is not automatically a reversible filename identifier. The observations retain hexadecimal original bytes. [6]

The destination directory, not the OS label, defines the contract

Linux ext4 documents per-directory case-insensitive lookup and name preservation on disk. Its comparison representation can differ from its stored spelling; non-strict invalid-encoding handling can fall back to opaque bytes. The documented encoding version is contextual, not a promise about every installed kernel. [2] Microsoft likewise documents directory-level case-sensitivity flags. [3]

A generic lowercase or Unicode transform cannot certify a particular target. Record the actual filesystem, directory settings, client/API behavior and Unicode rules. For a nested tree, every parent component matters. A share or application may apply its own comparison rules before the filesystem sees the name.

exFAT: a matching name hash is only a candidate

The filename itself has another, separate hash in exFAT. Its 16-bit NameHash is a lookup shortcut, not a content checksum or unique identifier. The volume's Up-case Table determines character mapping; a matching hash requires comparing the mapped names. [7, sections 7.2 and 7.6.4]

Linux v6.16 checks both hash and length before entering the name-comparison stage. Its exfat_uniname_ncmp then compares up-cased code units. Passing the cheap filter does not finish lookup. [8] [9]

Exact constructed ASCII pairs, each two letters long. Hexadecimal hashes are computed from up-cased UTF-16LE bytes, without a terminator. These are arithmetic results, not filesystem observations.
NamesLeft / right NameHashSame hashSame mapped name
AB / EA0x2029 / 0x2029yesno
AB / ab0x2029 / 0x2029yesyes
AB / AC0x2029 / 0xa029nono

AB and EA survive both hash and length filters but are different names. In contrast, AB and ab are equal under the mandatory ASCII mapping. A hash-only restore inventory would conflate these two situations. This counterexample explains why the final comparison matters; it is not a defect in the checked Linux lookup path.

Download the bounded model, tests, exact results and method. The implementation accepts only ASCII letters and rejects unsupported inputs. It neither implements a general Unicode Up-case Table nor establishes the behavior of a mounted volume or copy utility. Filename collision, lookup-hash collision and equal payload hashes must remain separate checks.

The overlooked connection is identity and access policy

Basu, Sampson, Qian and Jaeger's FAST 2023 paper studies case-sensitivity collisions in Linux copying utilities. Sections 5 and 6 generate resource-type pairs, observe filesystem operations, and compare resulting contents and metadata. Its package-script survey is a bounded usage sample, not a field incident denominator. Section 8 explains why an archive-only scan can miss pre-existing target entries or disagree with the destination's rules; concurrent path changes need separate handling. [10, sections 5, 6 and 8] The earlier preprint remains available for comparison. [4]

That work connects filename equality to metadata and authorization, not just display spelling. We do not reproduce its exploit cases or claim that today's versions retain its reported behavior. Our narrower contribution isolates a verifier that accepts equal contents after losing an entry. Combine this check with permission restoration and archive-entry selection; none substitutes for the others.

What a restore acceptance test must preserve

Failure timing adds another identity risk: a later ZIP member named ./target.bin can overwrite an earlier target.bin before CRC rejection. A detected error does not undo the collision. See the version-bound extraction failure-state experiment for complete output inventories and the distinction between isolation and commit. [Evidence]

  1. Keep original names losslessly, with an explicit encoding or byte representation. Store display labels separately.
  2. Define the intended source-to-destination mapping and verify that distinct required entries do not collapse under the actual target rules. Include pre-existing entries and parent components.
  3. Reject unsupported names or collisions before committing output, or use a documented reversible renaming plan. Do not silently normalize and overwrite.
  4. Compare the restored entry inventory and mapping, then verify type, contents, links, permissions and application behavior as required by the recovery contract.

Our fixture guard rejected all 20 colliding plans before creating an output file; the 28 noncolliding controls retained both entries. This guard uses known transforms on fixed single-component names. It is not a secure extractor, an atomic restore protocol or protection against concurrent path changes.

See the corpus definition of filename collision and the existing backup verification framework.

Reproduce the observations

Download the standard-library Python probe and raw observations. Run on a writable POSIX mount that can preserve the fixture byte names; GNU stat is required. The output path must not already exist.

python3 filename-identity.py --directory . --output filename-results.json

The recorded run used Python 3.12.3, Unicode database 15.0.0 and Linux 6.8.0-146-generic. The probe records the mount-type label reported by stat, its own SHA-256, original/output inventories and complete content-match results. The eight-policy comparison matrix is separate from the 48 materialized copy cases.

Inputs are constructed examples, not user data. No archive extractor, network share, live backup product, nested path, link, concurrent writer, permission restoration or power-loss survival was tested. The Unicode reference explains the concepts; the computation uses the recorded Python Unicode database, not the newer reference's entire character repertoire.

Primary sources

  1. Unicode UAX #15, revision 57 (Unicode 17.0): canonical and compatibility normalization. Accessed 2026-10-20.
  2. Linux kernel documentation: ext4 case-insensitive file name lookups. Accessed 2026-10-20.
  3. Microsoft Learn: per-directory case sensitivity. Accessed 2026-10-20.
  4. Basu, Sampson, Qian and Jaeger (2022): Unsafe at Any Copy, arXiv:2211.16735v1. Accessed 2026-10-20.
  5. Python 3.12: str.casefold. Accessed 2026-10-20.
  6. Python 3.12: file names, filesystem encoding and error handler. Accessed 2026-10-20.
  7. Microsoft exFAT specification: sections 7.2, 7.2.5 and 7.6.4. Accessed 2026-11-08.
  8. Linux v6.16: fs/exfat/dir.c, exfat_find_dir_entry. Accessed 2026-11-08.
  9. Linux v6.16: fs/exfat/nls.c, exfat_uniname_ncmp and exfat_utf8_to_utf16. Accessed 2026-11-08.
  10. Basu, Sampson, Qian and Jaeger: Unsafe at Any Copy, FAST 2023, pp. 183-198. Accessed 2026-11-08.
  11. Unicode 17.0: chapter 2, code points, encoding forms and schemes. Accessed 2026-11-17.
  12. RFC 3629: UTF-8 definition, byte-sequence syntax and byte-order mark. Accessed 2026-11-17.
  13. WHATWG Encoding Standard: TextDecoder.decode and fragmented input. Accessed 2026-11-17.
  14. Unicode 17.0: chapter 3, section 3.9, D76-D79 and UTF-16. Accessed 2026-11-17.
  15. Unicode Standard Annex 29 revision 47: grapheme cluster boundaries. Accessed 2026-11-17.
  16. ECMA-402: Intl.Segmenter FindBoundary and implementation-dependent segmentation. Accessed 2026-11-17.
  17. Unicode FAQ: UTF-8, UTF-16, UTF-32 and BOM. Accessed 2026-11-20.
  18. CPython 3.12.3: UTF-32 stateless and incremental decoder implementation. Accessed 2026-11-20.
  19. RFC 20: ASCII format for Network Interchange, code table and control functions. Accessed 2026-11-20.
  20. WHATWG Encoding Standard: names and labels, windows-1252 and ASCII labels. Accessed 2026-11-20.
  21. Node.js v24.22.2: Buffer, buffers and character encodings. Accessed 2026-11-20.
  22. IANA character sets: distinct ISO-8859-1 and windows-1252 registrations. Accessed 2026-11-20.
  23. Unicode: ISO/IEC 8859-1:1998 mapping, table 2.0, including control characters. Accessed 2026-11-20.
  24. Microsoft CP1252 to Unicode mapping, table 2.01, 1998-04-15. Accessed 2026-11-20.
  25. CPython 3.12.3: strict cp1252 decoder and undefined entries. Accessed 2026-11-20.
  26. WHATWG windows-1252 index, dated 2024-09-18. Accessed 2026-11-20.
  27. Node.js 24: Buffer character encodings and WHATWG compatibility warning. Accessed 2026-11-20.
  28. Hesela: ZIP alias and rejected-extraction destination-state controls. Accessed 2026-11-29.

Published by Hesela team · Published · Updated

Report a correction · Editorial standards · Reuse guidance

Change history

: first published.

: latest recorded update. A detailed change note is not available for this revision.

New-publication RSS · Correction RSS

Cite this page
Hesela team. Restoring file names: when matching hashes hide a lost entry. Hesela. 2026-11-29. https://hesela.com/analyses/filename-identity-backup-restores/