* fix(pe)!: share one loader-equivalent PE header owner across static readers Resources and certificates now admit headers through readPeImage, and resources map RVAs through the shared file-backed mapping. The owner reads the optional header at fixed offsets, caps data directories at 16, and lets a PE signature at e_lfanew override a DOS relocation table. Export, import, TLS and resource directories are read at their RVA whatever Size declares. Disregarded declarations are reported in header_anomalies. BREAKING CHANGE: import and delay-import walks continue to the null descriptor past a short directory Size instead of stopping with a malformed_entry issue, and inspect-pe-resources reports an unsupported optional-header magic as unsupported_target. * fix(pe): keep valid DOS relocation tables owning e_lfanew Only a relocation table that describes no DOS load module yields e_lfanew to a PE signature; update MZ/PE conformance to the shared owner. * fix(pe)!: bound static readers by the bytes they read, not file size max_file_bytes now counts the header prefix and every positional read of headers, directory tables and their referenced ranges. The identity pass that hashes the whole file is bounded only by a fixed whole-file ceiling: 4 GiB minus one byte for the PE-only readers, whose file offsets are 32-bit, and 512 MiB for hardening and exports. An exhausted allowance is a capacity refusal with a typed parameter details.limit. BREAKING CHANGE: max_file_bytes no longer refuses a large file whose reads fit; an exhausted read allowance reports resource capacity instead of file-size, and only a file above the fixed ceiling reports file-size. * fix(pe): walk resource trees within file-backed bytes and cite TLS reads The resource walk is bounded by the file-backed run from the directory RVA rather than its Size, and a Size that ends before the bytes walked is a directory_size_below_structure anomaly. The TLS result carries structure_location for the structure read past a short Size, and Evidence cites it. * test(pe): assert a refused read never reaches the descriptor * test(pe): use a resource cycle as damage now that a short Size is read * fix(pe): read resource trees past an oversized Size and keep damaged MZ headers malformed An oversized resource Size is reported without requiring its unused bytes to map. A Windows-header candidate is malformed when the DOS module is also invalid, and the guide states that a valid DOS relocation table owns e_lfanew. * feat(pe): report image_base and IAT slot VAs in static PE results (#14263) * feat(pe): report image_base and IAT slot VAs in static PE results Every static PE result reports the optional-header image_base once as a hex VA, and import rows add iat_va beside iat_rva so a slot goes straight to xrefs. Fields name their space as rva, va or file_offset; the new fields are optional so saved Evidence still parses, and the imports service rejects an iat_va that disagrees with image_base plus iat_rva. * fix(pe): document iat_va for rebased databases and test VA rejection iat_va is relative to the file's ImageBase; a rebased provider database needs its own base plus iat_rva. Cover the service rejection of a slot VA that disagrees with image_base plus iat_rva. * chore(pe): register the forwarded whole-file ceiling and shrink refusal baselines
3.9 KiB
Binary hardening
Use inspect_binary_hardening to read compile-time and link-time hardening from
an explicit local ELF, PE, or Mach-O file. No disassembler, pwntools install, or
target execution is required. Universal Mach-O files return one image per slice.
rea inspect-binary-hardening /absolute/path/to/program --json
rea inspect-binary-hardening /absolute/path/to/program --max-file-bytes 1048576 --json
MCP accepts { "path": "/absolute/path/to/program" }. CLI paths may be relative
to the current directory; MCP paths must be absolute.
Each image has one row per property: property, state, confidence, basis,
location, note, and next_probe. States are enabled, disabled,
partial, unknown, and not_applicable. confidence is observed for a
single header or import, and derived when the state combines several fields,
such as ELF PIE or full RELRO. An image's architecture is its CPU family, or
null when REA has no family for it. machine and slice.architecture keep the
exact identity, such as arm64e.
ELF rows cover PIE (ET_DYN with PT_INTERP or DF_1_PIE), NX (PT_GNU_STACK;
a missing header is unknown and the architecture default is only noted), RELRO
(PT_GNU_RELRO plus BIND_NOW), stack protector and FORTIFY undefined dynamic
imports, CET and AArch64 BTI/PAC GNU property notes, DT_RPATH, DT_RUNPATH, and
whether a SHT_SYMTAB section is present. Only an undefined dynamic import
counts. Imports come from the table DT_SYMTAB declares. A SHT_DYNSYM section
only supplies the symbol count when DT_HASH and DT_GNU_HASH leave it open,
and only if it names the same symbol and string tables. Without that count the
import rows are unknown and give the reason. A missing __stack_chk_fail or fortify import is unknown. That
absence does not establish that the protection was left out of a static or
stripped build. A present import is a sign that some code uses the protection,
not proof that all code does. NX, RELRO, DT_RPATH, and DT_RUNPATH are
not_applicable when e_type is neither ET_EXEC nor ET_DYN, and unknown
for a linked image with no readable program headers.
PE rows read DllCharacteristics for dynamic base, high-entropy VA, NX
compatibility, force integrity, no SEH, and guard CF. cfg_instrumented is the
load-config GuardFlags linker claim when Size covers that field. An
unreadable load configuration, including a TLS failure in that parser, leaves
only cfg_instrumented unknown. Authenticode and debug rows report certificate
and debug directory presence, not signature validity or debug content. A
directory whose address and size disagree is unknown.
Mach-O rows read MH_PIE, MH_ALLOW_STACK_EXECUTION, MH_NO_HEAP_EXECUTION,
a __restrict section in an __RESTRICT segment (dyld ignores the segment
without that section), LC_CODE_SIGNATURE presence, encryption from the
existing encryption reader, the arm64e subtype, and a stack-protector import.
hardened_runtime is unknown with next_probe inspect_signature.
CodeDirectory flags stay with that tool.
The report states presence of build-time features, not exploitability.
The default read allowance is 64 MiB of reads (max_file_bytes, ceiling 512 MiB);
files up to 512 MiB are admitted whatever their size. A changed
file is refused. A malformed header, a Mach-O segment or encryption command that
fails admission, or a program, section, or segment payload declared outside the
file returns no partial report; in a universal Mach-O, one bad slice leaves the
other slices. A symbol table or
symbol name over its budget leaves the import rows unknown and keeps the
header rows. A GNU property note over its budget, or a compressed note section
that may hold one, leaves the CET and BTI/PAC rows unknown and keeps the header
rows. A dynamic-table budget still fails the ELF report.