Skip to content

feat(native): report binary hardening for ELF, PE and Mach-O - #8524

Merged
gensokyo-dev merged 22 commits into
morluto:mainfrom
mvanhorn:fix/binary-hardening-inspection
Nov 5, 2026
Merged

gensokyo-dev merged 22 commits into
morluto:mainfrom
mvanhorn:fix/binary-hardening-inspection

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

REA can report ELF mitigations today only through caller-supplied pwntools on Linux x64, and it has no equivalent for PE or Mach-O. MH_PIE and DllCharacteristics are not read anywhere. Checking one binary's hardening means installing a separate tool per format.

This adds inspect_binary_hardening and rea inspect-binary-hardening, a built-in read of headers, program tables and imports. It works on any host, reports each universal Mach-O slice separately, and never runs the target. No issue is linked. This is a proposed new read-only tool.

Problem and expected behavior

Use case: an analyst triaging a binary wants one answer for PIE, NX, RELRO, stack protector, and the format's other mitigations, with evidence for each row.

Observable outcome:

  • Each image returns one row per property with a state of enabled, disabled, partial, unknown or not_applicable, a confidence, a basis sentence and a file location.
  • ELF, PE and Mach-O share the same report shape. Universal Mach-O files return one image per slice.
  • A missing marker is not reported as disabled. No __stack_chk_fail import in a static or stripped image leaves stack_protector unknown, because the absence does not establish that canaries are off.
  • A malformed header, a declared PT_LOAD, PT_INTERP or section past EOF, an empty or unterminated PT_INTERP, a truncated Mach-O command, a Mach-O segment that fails size, section count or file range admission, or signature data outside the slice returns no partial report, so rows that look complete cannot come from a damaged image. Debug-only ELF files whose PT_LOAD sizes exceed the file may be reported as malformed. That is from reading the code, not a run.
  • ELF imports come from DT_SYMTAB and DT_STRTAB. SHT_DYNSYM only supplies a count when it agrees with those tables, and without DT_SYMTAB the import rows are unknown.

Change and scope

Readers live in src/native/hardening/, one each for ELF, PE and Mach-O, with BinaryHardeningProvider.ts above them. src/domain/native/binaryHardening.ts owns the report and its allowances. The tool is registered in the existing binary diagnostics group.

These changes reach existing owners:

  • src/domain/elfHashSymbolCount.ts moves ELF hash-table symbol counting out of src/flutter/DartElf.ts so both readers share one bounded walk. An empty DT_GNU_HASH now returns an indeterminate count instead of symoffset, because undefined imports can extend past it. DartElf reports that as a failure instead of reading a short table.
  • src/domain/peOptionalHeader.ts and src/domain/binaryTarget.ts expose PE fields that hardening needs.
  • src/native/metadata/ and src/native/elf/ElfNoteParser.ts expose section and note facts.
  • src/domain/elfProgramHeader.ts gains a shared admitElfLoadSegment, used by ElfImage and the hardening reader.
  • src/domain/apple/machoLoadCommands.ts and src/artifacts/apple/MachoLoadCommandReader.ts share readMachoLinkeditDataCommand.
  • src/domain/apple/machoSegmentHeader.ts gains admitMachoSegmentCommand, and readMachoImage now shares that admission with the same messages and check order.

GNU property notes are found by owner and type, not section name, so a renamed SHT_NOTE cannot hide CET flags. Overlapping note tables that leave uncovered bytes make the row unknown. Sectionless ELF reads validate the complete span against file-backed mappings, and hash reads resolve their mapping once.

Not included: running the target, kernel or runtime mitigation state, source fortification analysis, or a score. native.hardening on the audit tool can point here later, but this PR does not depend on it.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: new src/native/hardening/ readers over existing native metadata owners.
  • Contribution scope fit and linked maintainer decision: read-only static inspection of a local file, with no execution, injection, mutation or protection recovery. Not applicable as a required decision. Whether REA wants this tool is for maintainers to judge, and I have not assumed approval.
  • CLI and MCP/tool-catalog contract: additive. New inspect_binary_hardening tool and inspect-binary-hardening command. Catalog, README and localized README counts are updated.
  • Provider, bridge, target-format, or platform compatibility: no provider or bridge is needed. ELF, PE and Mach-O on any host.
  • Evidence, artifact, provenance, or reconstruction contract: new Evidence with artifact identity, per-row confidence and locations. DartElf keeps its contract except for the empty DT_GNU_HASH case above.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): operates on a selected local path through the stable artifact read. No retained resources.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): additive tool count and one package.json verifier script. No build output is committed.

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: parser, provider and domain tests under src/native/hardening/ and src/domain/, DartElf tests, CLI acceptance tests and MCP boundary tests.
  • Base reproduction or other evidence: npm run verify:binary-hardening compiles real ELF targets with zig and inspects them without running them, reads macOS system binaries and checks a PE fixture. docs/verification/binary-hardening-2026-10-31.md holds the record.
  • User-visible CLI/MCP output (if applicable): reduced from rea inspect-binary-hardening ... --json on this commit. The demo below is a rendered walkthrough of these results, not a screen recording.
pie_full (zig cc -target x86_64-linux-gnu -fPIE -pie -Wl,-z,relro,-z,now)
pie              enabled   derived   e_type is ET_DYN and DF_1_PIE is set.
relro            enabled   derived   PT_GNU_RELRO is present and BIND_NOW is set.
nx               enabled   observed  PT_GNU_STACK p_flags does not include PF_X.
stack_protector  unknown   observed  No __stack_chk_fail symbol was found ...

nopie_lazy (zig cc -target x86_64-linux-gnu -no-pie -Wl,-z,norelro)
pie              disabled  observed  e_type is ET_EXEC.
relro            disabled  observed  PT_GNU_RELRO is absent.

/bin/ls (universal, 3 slices)
pie, code_signature_present, stack_protector  enabled on every slice
arm64e                                        enabled on arm64 slices, not_applicable on x86_64
hardened_runtime                              unknown on every slice
  • Remaining proof gaps: macOS host only. readelf was not available, so ELF rows were not compared with it. The compilers here did not emit an ELF with an undefined dynamic __stack_chk_fail or an executable PT_GNU_STACK, so stack_protector enabled and NX disabled on ELF are covered by fixtures. PE rows come from a built fixture, not a Windows toolchain. hardened_runtime stays unknown from this reader; inspect_signature owns that fact. docs/verification/binary-hardening-2026-10-31.md predates a later verifier change (readelf --wide, link order, emitted format checks), and those Linux paths have not been run: readelf, GNU ld, and Linux gcc and clang are absent on this macOS host. Separately, zig-built x86_64 and aarch64 ELFs with real undefined __stack_chk_fail and __memcpy_chk reported enabled.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

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.

Demo

demo

Validation performed

Run on this commit on macOS with Node 24.22.1 and npm 11.16.0:

  • npm run test:local on the changed source tests: 231 passed, plus 517 on the MachoImage consumers.
  • npm run test:focused on the changed acceptance and boundary tests: 177 passed.
  • npm run verify:binary-hardening: passed.
  • typecheck, lint, lint:typed (0 errors), format:check, metadata:check, verify:architecture-guards, verify:test-discovery, knip:production and docs:check: passed.
  • npm run check stops at knip on one unused exported type at src/process/DarwinHelperCache.ts:465. This PR does not touch that file, and it failed the same way on main in this environment.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for hardening, which is additive. DartElf now fails rather than reading symoffset entries on an empty DT_GNU_HASH.
  • Real decompiler provider, browser, or OS coverage: none needed. Real ELF builds and macOS system binaries on macOS only.
  • Package or release metadata impact: one new package.json script. No new runtime dependency.
  • Security, privacy, process, or containment review: the target is parsed and never executed. Table entries, note counts, load declarations and hash walks are bounded, and untrusted offsets are validated before use.

Author readiness

Human owner: @mvanhorn

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

AI was used for assistance.

Documents inspect_binary_hardening and its CLI equivalent, including
per-property states, supporting evidence, read budgets, and one report
per Mach-O slice. Explains that missing protection imports remain
unknown, signature presence does not establish validity, and hardened
runtime requires inspect_signature. Adds hardening links throughout the
documentation. The supplied diff also removes the advanced CodeQL
workflow and configuration, along with snapshot-binding mismatch
guidance.
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T06:02:38.557243Z
We couldn’t complete this review. Comment @codex review to try again.
401b6e7 New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The reviewed changes appear safe to merge; the local-symbol false positive is fixed.

Summary

Adds inspect_binary_hardening and inspect-binary-hardening for static ELF, PE and per-slice Mach-O reports.

  • A local binary can now produce one evidence-backed hardening report.
  • ELF files now show hardening findings from their headers and imports.
  • PE files now show hardening findings from their flags and load configuration.
  • Mach-O reports now show hardening findings separately for each slice.
  • Existing binary readers now share checks for declared sections and segments.
  • ELF symbol counts no longer treat an empty GNU hash as complete.

Reviews (19) · Last reviewed commit: "fix(native): ignore STB_LOCAL undefined ..." · Reviewed by Greptile

Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/MachoHardening.ts Resolved
Comment thread src/native/hardening/MachoHardening.ts Resolved
Comment thread scripts/verify-binary-hardening.mjs Resolved
Comment thread scripts/verify-binary-hardening.mjs Resolved
Comment thread scripts/verify-binary-hardening.mjs Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 628dd00064

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/MachoHardening.ts Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved
…dening rows

Run the shared range checks for ELF, read imports from the dynamic tables
rather than section metadata, and keep an unresolved symbol count apart from
an absent table. Check every Mach-O command before building rows and retain
only the offsets the rows need.

Make the verifier's readelf output wide, check the emitted format before
parsing Mach-O, and place the sources before the libraries in the link.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac82932e07

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/MachoHardening.ts Resolved
A segment with a section count its cmdsize cannot hold passed the hardening
reader and could enable restrict_segment. Move the size, section count and
file range checks to a shared admission that readMachoImage and the hardening
reader both use, and pin the ELF load-size case with a regression test.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c4959ac11

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/MachoHardening.ts Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved
…ty ELF interpreters

Segment admission never checked each section's payload range, so a
file-backed section past the slice still produced rows. Decode sections with
the section header owner and mark the slice malformed when a payload leaves
it; zero-fill and empty sections own no file bytes and are exempt.

admitInterp accepted a NUL first byte in a longer extent, which counted an
empty interpreter as PIE evidence. It now requires a nonempty path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KuWHGvzJkrhCqjtEHUwqyH

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bd079f589

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/PeHardening.ts Resolved
Use the IMAGE_GUARD_CF_INSTRUMENTED flag that guardFlagRecord already
decodes instead of masking the raw GuardFlags word a second time.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12c6226434

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved
The hardening reader mapped DT_STRTAB, DT_SYMTAB and hash tables through
the one PT_LOAD containing the table's first address. A second PT_LOAD
starting inside the table could map the rest of it from other file bytes
and the reader still reported parsed import evidence.

Cap each mapping at the next PT_LOAD that starts inside it, reject a
requested range that crosses that boundary, and stop hash reads at the
same limit, matching the conflicting-mapping refusal in readElfSymbols.
The hardening reader dropped any note table whose bytes another table
already covered. A covering SHT_NOTE can hold a non-GNU note whose
descriptor is itself a complete GNU property note, while PT_NOTE names
that inner note directly. Walking only the outer stream missed the GNU
marker and reported CET disabled.

Drop an alias only when it starts and ends on boundaries of admitted
tables, which are note boundaries of the walked streams. Any other
covered alias leaves the feature rows unknown, as a partial overlap
already does.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: afe6f7cf04

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/MachoHardening.ts Resolved
The Mach-O stack protector scan returned as soon as it found an
undefined ___stack_chk_fail, so a later undefined symbol whose n_strx
lay outside the string table was never checked. The same damaged table
parsed or failed as malformed depending only on record order.

Keep the match and finish the bounded record walk. Records after the
match are only checked against the string table bounds, so their names
are not read or charged to the scan budget. The ELF reader already
admits its whole symbol table before matching names.
The hardening reader treated every PT_LOAD that starts inside a table,
or that also contains the table's address, as a conflicting mapping.
A load with the same address-to-file translation names the same file
bytes, so tables it overlaps still have one interpretation, and the
canonical ElfLoadMap already merges such spans.

Treat equivalent loads as one interpretation. A load with a different
translation, or the zero-filled tail of an equivalent load, still ends
the usable range, so a remapped table is still rejected.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e1c82adc4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/ElfHardening.ts Resolved
… unknown

A section and a program header that share endpoints were treated as one
note stream even when their effective note alignments differed. Walking the
same bytes at 4 and 8 can frame different notes, so dropping the second table
could hide a GNU property word and report CET or BTI as disabled.

Require matching effective alignment at both endpoints, and no alignment
change inside the covered span, before treating a table as an alias.
Otherwise mark the feature rows unknown. The fixture's .note.gnu.property
section now declares the class's note alignment, as toolchains emit it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f07dcdb88

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/native/hardening/MachoHardening.ts Resolved
Comment thread src/native/hardening/MachoHardening.ts Resolved
Move the Mach-O fixed uint32 command layouts out of MachoCommandNames
into domain/apple/machoLoadCommands so there is one owner of those
offsets. MachoCommandNames and the hardening reader now both decode
through it; the hardening reader keeps its own bounds and import policy.
A common definition sets N_UNDF|N_EXT like an import but stores its
allocation size in n_value. An object holding only
`int __stack_chk_fail;` therefore reported stack_protector: enabled.

Require a zero n_value before an undefined external counts as an
import, for both nlist widths.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a7e0c13a2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/apple/machoLoadCommands.ts Resolved
Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread scripts/verify-binary-hardening.mjs Resolved
The binary hardening verifier started its probes and compiler drivers with
raw spawnSync, which bypassed the src/process/ supervision that AGENTS.md
requires. Every launch now goes through createVerifierCommands, and the
temporary root is removed only after the owner closes cleanly.
@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.

Comment thread scripts/verify-binary-hardening.mjs Resolved
SIGINT or SIGTERM ended Node before withVerifierCleanup ran, so detached
compiler trees and the temporary root could outlive the verifier. The
verifier now turns those signals into an abort that every owned command
receives, so cleanup closes the owner and removes the root before exit.
@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.

Comment thread scripts/verify-binary-hardening.mjs Resolved
… a command

Only the owned commands read the interruption signal, so a SIGINT or
SIGTERM during the final cleanup or between commands was recorded and
then dropped, and the verifier exited 0. After cleanup settles, the
verifier now throws the interruption reason. A failure the operation or
its cleanup already raised still leaves first and is not replaced.
@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.

Resolve the docs/index.md guide table conflict by keeping main's rows,
including the new wxapkg link, and re-adding the Binary hardening link.
@morluto

morluto commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Hey @mvanhorn, thanks for the PR! This addition looks good to me. What's left: it has merge conflicts with main in docs/index.md (merging main into the branch is fine) and the Static checks and Portable tests checks are failing (failing jobs: Build package, Documentation and Source tests). There are 2 unresolved review threads from Codex, all on outdated lines, so if they're already addressed, resolving them should be all that's needed. Happy to get this in once that's sorted out.

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

Comment thread src/native/hardening/ElfHardening.ts Resolved
Comment thread src/native/hardening/MachoHardening.ts Resolved
The hardening reader turned every malformed status from the shared
encryption reader into an unknown `encrypted` row, so a short
LC_ENCRYPTION_INFO_64 or an encrypted range past the slice still left the
slice parsed with a full report.

Only two conflicting encryption commands stay an unknown row now. Any other
encryption defect fails the slice like other structural command failures.
@mvanhorn

mvanhorn commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged main in eaabca0, which clears the docs/index.md conflict, and CI is green on that head, including Static checks, Portable tests, Build package, Documentation and Source tests. Ready for another look whenever you have a moment.

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

A local undefined __stack_chk_fail or __memcpy_chk is never resolved
against another object, so it does not establish an external import.
Skip STB_LOCAL bindings when reading protector signs, and give the
fixture's positive symbols STB_GLOBAL binding.
@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.

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified head 401b6e76c combined with current main ec3410998 on Linux x64, Node 24.22.1 / npm 11.16.0. No additional production changes were needed.

The two remaining review findings are already addressed: readCommandFacts frames all Mach-O commands but retains only restriction/signature offsets and one symbol-table command; ELF undefined-import scanning consumes readElfSymbol (including its binding and section facts), rather than re-decoding the layout. The obsolete retained-command array and parallel ELF symbol decoder are absent.

Executed verification:

  • 253 tests passed across 12 source files covering hardening, shared ELF/Mach-O/PE parsers and consumers.
  • 171 tests passed across public CLI/MCP, filesystem and stable-reader boundaries (4 files).
  • The real compiler/readelf verifier passed all 10 ELF variants: PIE/non-PIE, full/partial/no RELRO, stack protector, executable stack, build ID, dynamic linking and two dependencies. Native Mach-O tooling is unavailable on this Linux host; PE coverage here is fixture-based.
  • Public CLI against /usr/bin/ls (SHA-256 cb30d69b24245bf2ecdc9e7f53bbad19159999970b6d82c0c00c7d32d9e37aa4) returned 10 evidence-bearing rows in 4,457 bytes, matching the inspected ELF facts: PIE/NX, partial RELRO and imported stack-protector/fortify markers. Elapsed 1.744s, user/system CPU 1.789/0.159s, sampled peak process-family RSS 208 MiB (200ms samples; includes startup; not a before/after speed or token claim).
  • Single-thread syntax lint of all 54 changed TS/MJS files passed (0 errors, 91 warnings).

Resource limitation: the full check:fast invocation was stopped at the explicit 4 GiB process-family RSS guard (sample 4.10 GiB), before OOM. It is not a full local static-check pass; focused lint passed after inspecting the stopped task. Build plus boundary verification peaked at 2.12 GiB. Existing head CI remains the full-suite evidence. No Windows or real macOS run was performed here.

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated verification under the user-authorized gensokyo-dev account: reviewed the shared parser ownership and bounded fact collection; 253 source and 171 public/boundary tests plus 10 real compiler/readelf variants passed. The package.json change only adds the opt-in hardening verifier command; no dependency or install-hook change. Full verification and local resource-stop limitations are recorded in my preceding review. This is an agent review, not an author human-readiness attestation.

@gensokyo-dev
gensokyo-dev merged commit 560674e into morluto:main Nov 5, 2026
49 checks passed
@gensokyo-dev

Copy link
Copy Markdown
Collaborator

Measurement correction (no production change): the earlier profiler recorded final RUSAGE_CHILDREN totals without subtracting their initial value. When a shell exec-replaces its last command, those counters can contain earlier commands. A bounded control reproduced this inheritance. Treat the previous raw CPU values as accounting observations, not attributable task CPU; elapsed and sampled RSS are unaffected. Corrected reruns subtract the initial counters and retain the same two-CPU affinity / 4-GiB sampled family guard.

  • 8524-cpu-corrected: 1.967s elapsed; 1.522/0.172s command-process-family user/system CPU delta; 207.7 MiB sampled family RSS; exit 0, no guard stop.

The hardening rerun again inspected the unchanged system /usr/bin/ls. These are warm-filesystem verification runs with fresh engine sessions where applicable, not a cold/warm benchmark or speedup claim. The 200ms RSS sampler can miss peaks and counts shared pages per process; CPU excludes profiler overhead. No additional target code was executed.

@mvanhorn

mvanhorn commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@gensokyo-dev thanks for merging this - glad REA can now report PIE, NX and RELRO across ELF, PE and Mach-O with inspect_binary_hardening instead of needing a separate tool per format.

@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants