Commit Graph
4 Commits
Author SHA1 Message Date
morluto 782c274200 refactor(elf): decouple structural admission from lane policies and type MIPS limitations (#14356)
Decouple fatal ELF structural/framing checks from optional trailing
section-table range observations via an explicit sectionRanges policy
("strict" | "observe") on validateElfDeclaredRanges, keeping native
section-directory and non-MIPS32 validation strict while making
readMipsElfMetadata reachable for carved MIPS32 ELFs.

Replace untyped string[] limitations on MipsElfMetadata and
MipsElfInspection with the MipsElfLimitation discriminated union
("truncated_section_table" | "unexamined_declarations") so
GhidraMipsProfile switches on typed kinds rather than prose prefixes,
admitting carved recordless legacy MIPS32 ET_EXEC images while keeping
declared-ABI, non-ET_EXEC, PSP, and non-section-truncation limitations
fail-closed.

Closes #14343
2026-11-24 14:07:27 +00:00
morluto b6e06169cd refactor(native): isolate FAT Mach-O slice framing and consolidate Mach-O/PE/MZ gates (#14366)
* refactor(native): isolate FAT Mach-O slice framing and consolidate Mach-O/PE/MZ gates

- FAT Mach-O: Separate container-level fatal framing (header, <=128 entries, slice bounds, overlap, Mach-O container identity) from unselected-slice alignment, CPU/subtype identity, and load-command framing in binaryTarget.ts, machoContainer.ts, and BinaryTargetExecutableProbes.ts; validate alignment, thin-header identity, and readMachoSliceCommandFrames only for the selected target.universalSlice.
- PE: Align readPeMetadata and parsePeRecordStructure with peOptionalHeaderReadBytes (bounded by MAX_PE_OPTIONAL_HEADER_BYTES) instead of rejecting optionalHeaderSize > 4096 or short SizeOfOptionalHeader globally; remove mzWindowsHeaderLayoutLimitation (e_lfanew < 64) from global target opening while keeping it in peImage.ts, nativeSectionDirectory.ts, and memberClassification.ts.
- DOS MZ: Admit dos-mz targets in parseMzExecutableMetadata / BinaryTargetExecutableProbes.ts from the fixed 28-byte DosMzDeclarations while preserving strict load-image/relocation/entry attestation in GhidraDosSnapshot and GhidraLoadImageValues.
- Hopper Mach-O: Remove readMachoMagic file re-open from HopperAnalysisProfile.ts and derive macho_container from target metadata / preparedImage; in HopperMachOImage.ts validate only the selected slice's alignment, reserved field, and thin header while keeping container bounds/overlap, non-blocking regular-file checks, and SHA-256 TOCTOU verification.
- Mach-O load-command readers: Consolidate MAX_LOAD_COMMAND_BYTES, readBoundedMachoLoadCommandTableHeader, and validateMachoLoadCommandFraming in src/domain/apple/machoLoadCommands.ts and pass admitted headers into readMachoCommandNames from GhidraMachoEntryHint.ts and KunaInventoryPlacement.ts.

Closes #14344

* fix(hopper): apply selected-slice FAT contract in offset mapper
2026-11-24 14:01:46 +00:00
fe4e466ef9 fix(ghidra): admit recordless legacy MIPS32 carves missing section tables (#4532)
* fix(ghidra): admit recordless legacy MIPS32 carves missing section tables

A carved firmware image keeps its original section header table offset while
the captured file ends before it. The recordless legacy admission required a
limitation-free inspection, so these files were refused even though every
program header — the only required declaration table — had been examined and
none declares PT_MIPS_ABIFLAGS. Admit the recordless shape when every recorded
limitation is the section-table truncation itself, keep that limitation in the
profile and Evidence beside the o32 assumption, and still refuse any other
limitation. The truncation wording now lives beside its producer as an exported
prefix so admission cannot drift from the recorded fact.

Fixes #3155

* docs(ghidra): describe the recordless carve admission in the MIPS guide

The guide still said a carved recordless ELF whose section table extends past
the captured bytes is refused. State the new exception, the limitation it keeps
in the profile and Evidence, and that any other or mixed limitation still refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(elf): validate captured section headers in truncated MIPS tables

---------

Co-authored-by: akushonkamen <akushonkamen@163.com>
Co-authored-by: Jonathan Henson <jonathanwhenson@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-24 12:49:33 +00:00
morluto 686bb097f8 refactor(application): extract BinaryTargetExecutableProbes from BinaryTargetResolver (#13826) 2026-11-22 20:39:14 -05:00