Skip to content

fix(iso9660): read a directory record whose identifier padding byte is not zero - #15020

Merged
vincentkoc merged 3 commits into
morluto:mainfrom
viniciusdsandrade:fix/15019-iso9660-identifier-padding-byte
Nov 30, 2026
Merged

vincentkoc merged 3 commits into
morluto:mainfrom
viniciusdsandrade:fix/15019-iso9660-identifier-padding-byte

Conversation

@viniciusdsandrade

@viniciusdsandrade viniciusdsandrade commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #15019

One directory record whose even-length identifier was followed by a padding byte other than 0x00 made inspect_artifact and extract_artifact refuse the whole ISO 9660 image as malformed, wherever the record sat in the walked tree. The byte takes no part in decoding: Linux isofs, libarchive, pycdlib and 7-Zip step over it without reading it, and 7-Zip notes that some discs store another value there. This PR stops checking the value. A record too short to hold the padding byte stays malformed.

Problem and expected behavior

Smallest trigger: a valid image in which the byte after one even-length identifier (for example the 8-byte AB.TXT;1) is 0x20 instead of 0x00.

On main, iso9660DirectoryRecordAt refused that record with "directory record padding byte after an even-length identifier is not zero" (src/domain/iso9660/iso9660Structures.ts:240-245 at 21cfc809b), and the walk unwraps that failure (src/artifacts/Iso9660ArtifactReader.ts:233), so the inventory ended as malformed without entries. In a Joliet tree every file and directory identifier is UCS-2 and therefore even-length, so every record there other than . and .. has this byte.

None of the common readers reads it:

  • 7-Zip keeps its zero check commented out beside the reason: // SkipZeros(padSize); followed by Skip(padSize); // it's bug in some cd's. Must be zeros (IsoIn.cpp:259-261).
  • Linux steps over it to find the system use area: if (rs->len & 1) (rs->len)++; (fs/isofs/rock.c:57-60).
  • libarchive does the same: rr_start = p + name_len + (name_len & 1 ? 0 : 1); (parse_file_info, :1898-1900).
  • pycdlib too: if self.len_fi % 2 == 0: record_offset += 1 (pycdlib/dr.py:296-297).

Expected: the record is read like any other, its file or directory is listed, and the rest of the tree is listed. A record that cannot hold the padding byte stays malformed.

Change and scope

  • src/domain/iso9660/iso9660Structures.ts: iso9660DirectoryRecordAt no longer compares the padding byte with zero. The check that the identifier and its padding byte fit the record is the one before it and is unchanged.
  • docs/guides/firmware/iso9660-images.md: the sentence that listed the zero padding byte among the malformed cases now names the fit rule and says the value is not checked.

Not included:

Contribution scope: ordinary fix within existing boundaries (static format inspection); maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: iso9660DirectoryRecordAt owns record parsing for rootRecord and for parseIso9660DirectoryExtent. No consumer reads the padding byte or the system use area that follows it (rg for identifierEnd, padded and system use over src/domain/iso9660 and src/artifacts/Iso9660ArtifactReader.ts). A descriptor's root record has a 1-byte identifier and therefore no padding byte, so descriptor parsing is unaffected.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: schemas unchanged. An image refused before for this reason is now inventoried. The padding_field failure is no longer produced.
  • Provider, bridge, target-format, or platform compatibility: images whose padding bytes are zero get the same result.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged for every decoded field.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • src/artifacts/Iso9660ArtifactReader.boundaries.test.ts: "rejects a nonzero padding byte after an even-length identifier" becomes "lists a record in the %s tree whose padding byte after an even-length identifier is not zero", for the primary tree and for the Joliet tree. Through scanCanonicalArtifactInventory, the record with the nonzero byte and the record after it are both listed with their sizes and verified hashes, and the root row's name_source confirms that the tree holding the byte is the one walked. On the base reader both cases reject as malformed at padding_field, which is what the replaced case asserted for the primary tree.
    • src/domain/iso9660/iso9660Structures.test.ts, "requires the padding byte an even-length identifier needs to fit its record", is unchanged and is the control: a record too short for the byte is still refused at identifier_length.
  • Base reproduction or other evidence: source-derived, not executed. The reference readers were read on 2026-11-28 at the commits linked above.
  • User-visible CLI/MCP output (if applicable): not captured, nothing was run.
  • Remaining proof gaps:

Boundary regressions: format assumptions. The accepted nonzero value is paired with the unchanged refusal of a record that cannot hold the byte, and the case runs in both trees because Joliet identifiers always carry the byte.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • No command was run locally. The diff was checked by reading against iso9660DirectoryRecordAt, its two callers, the ISO 9660 fixture (buildIso9660Image writes ab;1 as 4 bytes in the primary tree and 8 bytes in the Joliet tree, each followed by a padding byte) and every ISO 9660 test that names a padding check (rg over src and tests): only the replaced case depended on the value.
  • CI on this PR at d5812dd48 (run 46166326472): Static checks, Documentation, Build package, Portable tests, Native package baseline (linux x64), Build bundled Windows x64 native controls, Test shard (1/1) and CI required passed; none failed. The shard selected 3 affected files and ran 132 tests, all of which passed: src/artifacts/Iso9660ArtifactReader.boundaries.test.ts (72), src/domain/iso9660/iso9660Structures.test.ts (23) and src/domain/artifactFormatRecognition.test.ts (37).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none. No release contains the ISO 9660 reader yet (rea-agents-6.10.1 does not contain e896f6054).
  • Security, privacy, process, or containment review: none. The byte was never used to size or locate a read, and the record's bounds are still checked before it is decoded.

Author readiness

Human owner: @viniciusdsandrade

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

…s not zero

A record whose even-length identifier was followed by a nonzero padding
byte failed as malformed, and the walk ended the whole inventory on it.
The byte takes no part in decoding: Linux isofs, libarchive, pycdlib and
7-Zip step over it, and 7-Zip notes that some discs store another value
there.

The value is no longer checked. A record too short to hold the padding
byte stays malformed.
Joliet identifiers are UCS-2, so every file and directory record in
that tree has the padding byte. The case now damages the record of the
tree the reader walks and checks that tree was the one listed.
@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; accepting the unused padding value leaves record bounds intact.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; accepting the unused padding value leaves record bounds intact.

Summary

The PR lets ISO 9660 readers accept nonzero identifier padding without weakening record bounds.

  • ISO 9660 directory walks now accept nonzero identifier padding.

Reviews (2) · Last reviewed commit: "docs(iso9660): describe the unchecked id..." · Reviewed by Greptile

@viniciusdsandrade
viniciusdsandrade marked this pull request as ready for review November 28, 2026 16:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T16:49:34.635314Z d5812dd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@imSYNTAXMIND

Copy link
Copy Markdown

Independent verification of the same fix (not a duplicate PR): I arrived at the equivalent patch locally against dc31300 and ran these with the repo-pinned Node 24.22.1 (mise exec [email protected] -- …):

  • npm run test:local for src/artifacts/Iso9660ArtifactReader.test.ts, src/domain/iso9660/iso9660Structures.test.ts and src/artifacts/Iso9660ArtifactReader.boundaries.test.ts — 106 tests passed.
  • npm run check:fast, npm run format:check, npm run docs:check — all passed.
  • git diff --check — clean.

That adds local runtime evidence to the CI results recorded in the PR body. The fixtures are still synthetic; I did not test a real xorriso-produced image.

One optional addition from my local patch: a parser-level regression in src/domain/iso9660/iso9660Structures.test.ts that decodes a 38-byte record with identifier_length = 4, identifier AB;1 and a 0x20 padding byte, asserting the identifier is still AB;1. The existing "requires the padding byte an even-length identifier needs to fit its record" test stays as the control for the fit rule. Happy to leave that out if you prefer the reader-level cases as the single regression point.

@vincentkoc
vincentkoc merged commit 72b74f0 into morluto:main Nov 30, 2026
42 checks passed
@vincentkoc

Copy link
Copy Markdown
Collaborator

thanks! merged after a clean review and green CI. nonzero identifier padding is accepted; missing padding is still rejected.

vincentkoc added a commit to xu91102/rea that referenced this pull request Nov 30, 2026
* commit '4ccc685dd5ed028bc625fdd8760539ce5a492d8d': (228 commits)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020)
  fix(windows): report the ACE count a private DACL check observed (morluto#14450)
  fix(artifacts): read Ogg Opus channel mapping tables (morluto#14975)
  ...
vincentkoc added a commit to liziye627-design/rea that referenced this pull request Nov 30, 2026
* commit 'e18ed55bac14191010efe91ba61489cab1d2ba55': (137 commits)
  fix(artifacts): report macOS package bundle release versions (morluto#14860)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020)
  fix(windows): report the ACE count a private DACL check observed (morluto#14450)
  ...
vincentkoc added a commit to viniciusdsandrade/rea that referenced this pull request Nov 30, 2026
* commit '76cb6645be39cf3844f7a8bb4568b02d8a713595': (95 commits)
  fix(macos-pkg): retain cpio hard-link contents (morluto#15157)
  fix(artifacts): report macOS package bundle release versions (morluto#14860)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] inspect_artifact refuses a whole ISO 9660 image when a directory record's padding byte is not zero

3 participants