Skip to content

feat(artifacts): inventory NTFS $MFT record headers offline - #9868

Closed
2SinceJuly wants to merge 40 commits into
morluto:mainfrom
2SinceJuly:feat/9867-ntfs-mft
Closed

2SinceJuly wants to merge 40 commits into
morluto:mainfrom
2SinceJuly:feat/9867-ntfs-mft

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An acquired $MFT stream had no reader, so an analyst holding one could only
treat it as an opaque file. This adds offline, read-only inventory of a
selected $MFT: every FILE record's header, flags, record extent and
update-sequence fixup result. Fixes #9867.

Problem and expected behavior

Given a captured $MFT (or a run of FILE records), the artifact inventory
had no format for it and no facts about it. Expected: inspect_artifact
recognizes the stream by the FILE signature of its first record, under any
file name, and reports the record headers and whether their fixups survived
acquisition.

Change and scope

  • src/domain/windows/ntfsMft.ts owns the FILE record bytes: header fields,
    record-size selection (declared power of two, else the 1024-byte NTFS
    default), the update-sequence array and the per-sector trailer check.
  • NtfsMftArtifactReader reads the admitted file through
    ArtifactFileSource, reports the record-count facts in formatMetadata(),
    and sets coverage to unknown with the limitations when a record's fixup does
    not verify or its array does not cover every sector.
  • ntfs-mft is a new artifact format id: classifyArtifactBytes probes the
    signature next to the other unambiguous magics, and the format descriptor
    carries the reader limitation.

Intentionally not included, per the first-step split in the issue: attributes
and $FILE_NAME decoding (so no path, hard link or timestamp is claimed), and
$UsnJrnl:$J parsing and correlation. Those are the next two steps and are
recorded as unchecked tasks in the spec.

Follows the contribution scope: reads one caller-selected local file, with no
target execution, injection, mutation, protection recovery, network access,
volume mount or live filesystem access. No maintainer scope decision needed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/windows/ntfsMft.ts
    owns the parsed record facts; artifactFormatMetadata.ts gains the
    ntfs-mft strict schema; the reader and classifyArtifactBytes consume it.
    No superseded path is removed.
  • Contribution scope fit and linked maintainer decision: within existing
    artifact-reader boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: no new tool. inspect_artifact routes the
    new format through the existing inventory path, and routing for every
    existing format is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none; the format
    is host-independent and reads bytes only.
  • Evidence, artifact, provenance, or reconstruction contract: the root
    occurrence carries the metadata; limitations flow through coverage.
  • Target selection, authority, upstream behavior, and cleanup details: the
    caller selects one regular file; nothing else is touched.
  • Generated metadata: none authored here.

Expected effects:

  • 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/domain/windows/ntfsMft.test.ts (14 tests: clean
    record, failed fixup, missing array, short array, extension and directory
    records, wrong signature mid-stream, trailing partial record, undeclared
    record size, 4 KiB record, short file, missing signature, file-size ceiling,
    chunked decoding); src/artifacts/NtfsMftArtifactReader.test.ts (2 tests:
    root-occurrence metadata and coverage when a fixup fails);
    ArtifactGraphConstruction.test.ts (classification under three file names);
    artifactFormats.test.ts (reader-format union).
  • Base reproduction or other evidence: git grep -i "mft\|usn journal" src on
    origin/main b2f3dc81f finds no parser, and ntfs-mft was not a format id.
  • User-visible CLI/MCP output: none captured in this PR.
  • Remaining proof gaps: all fixtures are synthesized. No $MFT capture from a
    Windows host has been parsed, so real record layouts, sparse MFTs and
    fragmented attribute lists are unverified — and attributes are not decoded at
    all in this step.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable. A record's
    header fields are observed; a failed fixup is reported as a failed check, not
    as a decoded attribute claim.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run check:fast — typecheck and lint pass (2/2 successful).
  • npx vitest run src/artifacts src/domain/windows — 83 files, 1435 passed, 1 skipped.
  • npm run docs:check — passes (readmeConsistency 9 tests).
  • npm run verify:test-discovery — all 3354 test files discovered exactly once.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no provider or
    target interaction.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads one selected regular
    file up to a fixed 512 MiB ceiling; no mount, no volume access, no mutation.

Author readiness

Human owner: @2SinceJuly

  • 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.

Before merge

  • 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.

Depends on #9885.

Summary

An acquired $MFT stream had no reader. This adds offline, read-only inventory of a selected $MFT: every FILE record's header, flags, record extent and update-sequence fixup result. Part of #9867.

The whole-file ceiling is ntfs.mft_max_file_bytes, seeded by REA_NTFS_MFT_MAX_FILE_BYTES (default 512 MiB, floor 48 bytes, maximum 8 GiB). Each inventory reads the accepted runtime snapshot. A file above the effective ceiling names the setting, the current value, its source (default, setting, or runtime), and the allowed range. update_analysis_settings changes it for the next operation (update_mode: "runtime", pending_restart: false). A value outside the range is rejected and leaves the current ceiling unchanged.

Still open on #9867

Header and fixup inventory is only the first step. Attributes, $FILE_NAME, $UsnJrnl:$J, correlation, and real Windows captures stay out of this PR.

Validation performed

  • npm run check:fast and oxfmt --check passed on 5ff8f4f58.
  • node scripts/verify/rea-numeric-limits.mjs passed.
  • NTFS reader and domain tests passed (19 tests).
Open in Web Open in Cursor 

An acquired $MFT stream had no reader, so an analyst holding one could only
treat it as an opaque file. Recognize the FILE signature of the first record
and inventory every record's header: sequence number, flags, used and total
bytes, base record reference and update-sequence array.

Each record's update-sequence fixups are verified against its sector
trailers. A mismatch keeps the header facts, is reported on the record and is
counted in the metadata, so a record that was not cleanly written is visible
rather than silently accepted. A missing or short array is reported as
unverified, a wrong signature stops the scan at its offset, and a trailing
partial record is reported as a byte count. Attributes, filenames and the
$UsnJrnl:$J journal are not decoded, so no path or change history is claimed.

Fixes morluto#9867
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T16:47:49.351041Z
We couldn’t complete this review. Comment @codex review to try again.
ccb45f5 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

2SinceJuly and others added 3 commits November 11, 2026 01:39
The new NTFS $MFT files were committed unformatted, so the Static checks lane
failed on format:check. Formatting only; no behaviour change.
REA_NTFS_MFT_MAX_FILE_BYTES defaults to 512 MiB, with a 48-byte floor and
an 8 GiB maximum. A file past the effective ceiling names the setting, its
source, and the range, and says to restart REA. There is no runtime override.
REA_NTFS_MFT_MAX_FILE_BYTES still seeds ntfs.mft_max_file_bytes. Each
inventory reads the accepted snapshot, and update_analysis_settings
changes the next call inside the existing floor and maximum.
Part of morluto#9881. Record every numeric REA_ limit and fail static checks when one is neither a runtime analysis setting nor a documented exception with a reason.
Part of morluto#9881. Add effect immediate or next_process and keep rea_restart_required, restart_required, and restartRequired as compatibility aliases.
Callers read update_mode to see whether update_analysis_settings can change a limit, and pending_restart only when a configured value is not active in this process.
GitHub CI tests the merge with main. Main now removes copied
authentication even when command cleanup fails, which the evaluation
command test still required to remain.
Main removes copied authentication even when command cleanup stays
incomplete, and CI tests that merge. Keep the incomplete-cleanup
diagnostics and the retained run directory, and expect auth.json to be gone.
Depends on morluto#9885. That branch replaces rea_restart_required with
update_mode and pending_restart and forbids the legacy fields.
…tions

The numeric-limit check now treats REA_WEB_BUNDLE_ENDPOINT_LITERAL_CANDIDATES as a count limit and does not count registry text as a producer.
Invalid ChangeTime settings now carry update_mode and pending_restart through the configuration error and its projection, including startup parsing. Runtime recoveries name update_analysis_settings instead of telling the caller to restart REA.
Depends on morluto#9885. The $MFT limit uses update_mode and pending_restart,
and the setting declares updateMode so the numeric-limit check accepts it.
Discovery no longer treats comments or registration-list entries as producers. The three limits moving on their own PRs must join ANALYSIS_SETTINGS; the exception registry cannot classify them.
artifact_limits and web-network budgets report update_mode parameter because update_analysis_settings cannot change them. The legacy-name scan no longer reads docs, and the 2026-11-09 Ghidra receipts are restored to the fields they recorded.
A quoted name after an identifier, call, or optional chain is a producer. Only declaration arrays and comments stay out of discovery.
Property access, element access, and helper-call arguments are producers. Comments and array literals are excluded by the tree, so a later argument such as read(environment, "REA_NEW_MAX_BYTES") stays classified.
Relative links from the limit inventory into src escape the documentation
site base. Point them at the repository files instead.
analysis_timeout_ms, max_heap_mb, and command_timeout_ms keep the source chosen by the caller, the runtime override, or the built-in default. A request value reports update_mode parameter because update_analysis_settings cannot change that call.
Main already expects copied auth.json to be removed when evaluation
cleanup stays incomplete, and the run directory to remain.
Main left describe("Ghidra bridge script processor context contract")
with no tests after moving that check to the real provider probe.
Vitest rejects the empty suite during source tests.
…all guard dependency-free

Object bindings, in-checks, and object keys that a spread can copy are producers. The architecture guard skips the TypeScript parse until typescript6 is installed, and the inventory links stay inside the published site.
The changelog and the limit migration now name runtime, restart, and parameter. parameter is the mode for a value this call supplied.
The fork credential cannot update workflow files. Leave
ghidra-bridge-sources.yml at the revision already on this branch.
This branch cannot update ghidra-bridge-sources.yml, so that workflow
still launches ReaArmContextProbe.java. Restore that script beside the
renamed probe.
A one-test suite named for the bridge script was collected with no tests in the full source run, which failed the file. The same assertion now sits directly on the file.
Keep the Ghidra bridge context assertion on the file. Main's empty suite is the collection failure.
The main merge dropped the fs import that the file-level assertion uses.
Depends on morluto#9885. Bring the allowlist, tracked-limit rules,
parameter update mode, and restored historical receipts.
@morluto

morluto commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Superseded by merged #9911, which incorporated this NTFS MFT reader with original authorship and completed public artifact admission, bounded inventory, coverage, and source-validation handling. The reader and ntfs-mft registration are present on main. Subsequent extension metadata work landed in #10006; remaining attribute/USN follow-up is tracked separately in #9914. Closing this original implementation PR to avoid merging the same capability twice.

@morluto morluto closed this Nov 11, 2026
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants