Commit Graph
745 Commits
Author SHA1 Message Date
morluto 9a85100b59 perf(process): fix expectedSize EOF probing in readBoundedFileBytes and eliminate 2x buffer copies (#13494)
* perf(process): fix expectedSize EOF probing in readBoundedFileBytes and eliminate 2x buffer copies (#13492)

* fix(setup): bound skill snapshots to the admitted file size
2026-11-22 18:23:12 +00:00
morluto 8da89da5e4 perf(elf): fuse dynamic symbol hardening predicates into single-pass scan with __ prefix pre-filter (#13513)
* perf(elf): fuse dynamic symbol hardening predicates into single-pass scan with __ prefix pre-filter (#13509)

* fix(elf): share symbol decoding and preserve short fortify imports
2026-11-22 13:11:47 -05:00
morluto 0a88a24d7a perf(native/sqlite/apple): eliminate double full-payload Zod re-validation and owned JSON deep-cloning (#13516)
perf(native/sqlite/apple): eliminate double full-payload Zod re-validation and owned JSON deep-cloning (#13511)
2026-11-22 12:57:41 -05:00
morluto 230105c681 perf(pe): compute ILT pefile cap in O(1) and eliminate BigInt allocation in IAT walk (#13484) 2026-11-22 11:49:45 -05:00
morluto 366dbc20bf perf(elf): fuse initializer section scans into one pass and eliminate symbol-map cloning (#13476)
perf(elf): fuse initializer section scans into one pass and eliminate symbol-map cloning (#13475)
2026-11-22 16:46:08 +00:00
morluto 6c6005ca9a perf(adapters/server): use ownedJsonValueSchema for freshly constructed internal results (#13459)
* perf(adapters/server): use ownedJsonValueSchema for freshly constructed internal results

* fix(server): keep defensive jsonValueSchema copy in jsonValueResult for shared session limits
2026-11-22 16:12:03 +00:00
morluto bb81b0a88d fix(elf): establish direct initializer slot mappings (#13452) 2026-11-22 15:57:43 +00:00
morluto 87180a86d9 test(go): consolidate native pointer mapping coverage (#13449) 2026-11-22 10:27:55 -05:00
morluto 2e1144b0ca fix(elf): bound dynamic version tables to mapped bytes (#13446) 2026-11-22 15:22:08 +00:00
morluto c7f89cd8b5 fix(elf): report proven version and dynamic symbol facts (#13441)
* fix(elf): use proven version and dynamic symbol facts

* perf(elf): avoid flattening versions for other retained views

* test(elf): consolidate dependency transport and budget coverage
2026-11-22 15:05:37 +00:00
morluto 7fc333ffa0 fix(elf): retain authenticated debug-link evidence on interruption (#13437)
* fix(elf): retain authenticated debug-link evidence on interruption

* test(elf): refresh debug-link lifecycle coverage references
2026-11-22 14:59:04 +00:00
morluto 0f771abed0 fix(apple): traverse deep Objective-C protocol graphs iteratively (#13431)
* fix(apple): traverse deep Objective-C protocol graphs iteratively

* test(apple): consolidate dispatch slice and ivar coverage
2026-11-22 14:07:55 +00:00
morluto 18f5b7b4db perf(pcap/pwntools): eliminate redundant parsing, linear scans, and quadratic allocations (#13359)
* perf(pcap/pwntools): eliminate redundant parsing, linear scans, and quadratic allocations

* fix(pcap/pwntools): address review threads on DNS reconciliation, request target cache bound, and dead helpers
2026-11-22 08:04:19 -05:00
morluto 79887f7a3b perf(native): eliminate hot allocations in ELF/DWARF readers and enlarge signature copy chunks (#13318) 2026-11-22 03:42:58 -05:00
hhang 9ffaca5447 fix(native): preserve bundle provenance in partial reports 2026-11-22 15:41:50 +08:00
hhang e35780d042 fix(native): refresh bundle provenance on reopen 2026-11-22 15:41:50 +08:00
hhang b8995f8148 feat(native): retain Apple bundle executable provenance 2026-11-22 15:41:50 +08:00
morluto ac4f655858 perf(native): pre-screen IL2CPP slots and reuse ObjC/PE indices (#13314) 2026-11-22 03:51:45 +00:00
morluto b38a49656a perf(native): maintain owner index for ObjC dispatch implementations instead of O(C*M) filtering (#13269) 2026-11-22 02:06:31 +00:00
morluto 204434e087 test(native): isolate Objective-C ivar alignment coverage (#13205) 2026-11-21 15:36:31 -05:00
RRFZ ce3506e298 fix(elf): clear the ARM Thumb bit before naming unwind ranges (#9692)
An ARM STT_FUNC or STT_GNU_IFUNC value for Thumb code is the code
address with bit 0 set (AAELF32 symbol values), while an FDE initial
location is the even code address. inspect_elf_unwind_ranges matched
symbol values to FDE starts exactly, so a Thumb function described by an
.eh_frame FDE lost its name: the range was named by a local label or
mapping symbol from .symtab, or had no name when only .dynsym was left.
On ARM EABI such FDEs come mostly from hand-written assembly with .cfi
directives; compiled code unwinds through .ARM.exidx.

Clear bit 0 of ARM function and IFUNC symbol values before the lookup, as
the ELF initializer and Android JNI readers already do. Mapping symbols
and other machines keep their values.
2026-11-21 21:32:08 +01:00
fengqiaoquandAnankequ 3dcd6b62e8 test(native): retain per-ivar alignment facts in mixed lists (#3424)
fix(apple): decode the ivar WORD_ALIGN sentinel as 8-byte alignment

Co-authored-by: Anankequ <2983852214@qq.com>
2026-11-21 21:24:28 +01:00
Dayan KijegeandClaude Opus 5.5 d955cd0d60 fix(elf): do not count SPARC register declarations as imports
On SPARC, symbol type 13 is STT_SPARC_REGISTER. An undefined entry of
that type declares use of the global register named by st_value and
may have an empty name (SPARC V9 ABI); it is not an import.
inspect-elf-dependencies listed each one as an unnamed import, recorded
a name_unreadable issue for its empty name, and marked coverage
partial. JNA's sunos-sparcv9 libjnidispatch.so (shipped in Eclipse
Installer) declares %g2 and %g3 this way and reported 47 imports, two
of them unnamed, with partial coverage.

parseImports now skips undefined type-13 entries when e_machine is
EM_SPARC, EM_SPARC32PLUS or EM_SPARCV9. Elsewhere type 13 is a
different processor-specific type and keeps today's row.

Validation (macOS arm64, Node 24.22.1):
- New parser regressions for machines 2, 18 and 43 (big-endian, 32-
  and 64-bit) fail before this change; a non-SPARC control keeps the
  unnamed row and partial coverage.
- ElfDependencyParser, ElfDependenciesProvider and ElfDependenciesView:
  79 passed. Format, typecheck, lint and architecture guards pass.
- Real file: libjnidispatch.so now reports 45 imports, complete
  coverage and no issues, matching the 45 named undefined dynamic
  symbols llvm-nm lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:24:17 +01:00
XiaoBinGan 985fa2fac9 fix(pe): keep pefile's unrounded raw offset for a sub-page section
`createPefileReadCompatibility` models pefile's section reads so an import hash is published only
when both readers see the same bytes. Its layout gate rejected any section whose
`PointerToRawData` was not 512-aligned — but pefile 2024.8.26's `get_PointerToRawData_adj()` skips
that rounding when `SectionAlignment < 0x1000` and `PointerToRawData == VirtualAddress`, the
`LdrpWx86FormatVirtualImage` layout ntoskrnl-era drivers use.

The gate already modelled the sub-page case two lines above (`SectionAlignment < 0x1000 ?
FileAlignment : SectionAlignment`), then rejected it against an absolute 512 rule — and
`docs/pe-imports.md` scopes the withhold to an incomplete table or a different row sequence, not to
a file offset.

Measured on a minimal image with `SectionAlignment = FileAlignment = 0x80` and `.idata` at RVA 0x300
== file offset 0x300:

| | before | after |
| --- | --- | --- |
| coverage | `complete` | `complete` |
| issues | `[]` | `[]` |
| `imphash.md5` | `null` | `92cef6cc91a85825f3c8a0516517c66f` |

The withheld hash is the only thing that differed: both readers were already reading the same bytes.

The exception is exact rather than approximate — a section with the same sub-page alignment whose
`PointerToRawData` differs from its `VirtualAddress` still withholds, because pefile does round it
there. That case is the second new test.

pefile's current `master` broadened the condition to every sub-page image; this matches the
2024.8.26 revision the module documents, which is the narrower and safer rule.

`tests/fixtures/binaryDiagnostics/peImports.ts` takes an optional `layout`, so the shared builder
produces the geometry instead of a test hand-encoding a second image. Its default is unchanged —
`SectionAlignment`/`FileAlignment` are written only when supplied, so every existing fixture keeps
its exact bytes.

`src/native/pe` — 265 passing. Restoring the absolute 512 rule fails the sub-page case.
2026-11-21 21:08:49 +01:00
Brahma Reddy f03cce9c01 fix(native): label XML plists that file calls data as xml (#12910)
`file -b` reports `data` for an XML plist containing a control character
or NUL byte, which CoreFoundation still reads. plistSourceFormat only
probed the source for markup when `file` reported text, so these sources
were labelled `unknown` and skipped REA's XML reader. When that reader
would have refused them, the result also lacked the limitation that says
the value came from plutil's conversion. Two plists shipped with macOS
27.2.1 are affected.

Probe the source prefix for any description that does not name binary,
XML or JSON. Such XML now takes the same route as XML that `file`
recognizes: REA's reader decodes it directly, or #12251's plutil fallback
records REA's refusal reason. OpenStep and other non-markup sources stay
`unknown`.
2026-11-21 20:00:31 +01:00
Lewis WangandClaude Opus 5.5 7a11884c08 fix(native): require dyld's __restrict section before reporting a restricted Mach-O (#13024)
dyld treats an image as restricted only when a __RESTRICT segment holds a
section named __restrict. inspect_binary_hardening reported restrict_segment
enabled for any segment named __RESTRICT, so a binary linked with
`-sectcreate __RESTRICT __other` was reported restricted although dyld still
honours DYLD_* variables for it.

The segment reader that already walks every section header now also returns
the first __restrict section. The row is enabled only for that section and
points at its name; a __RESTRICT segment without it is disabled with a basis
that names the missing section and points at the segment name.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 19:56:51 +01:00
gensokyo-devandgensokyo-dev 6543a3c1a1 refactor(pe): decode certificate BMP and UTF-32 strings through BinaryReader
BMPString and UniversalString decoding read code units with raw Buffer
reads after their length-multiple checks. Read them through the
pe-certificate-table BinaryReader instead.

Refs #11865

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-21 19:52:16 +01:00
gensokyo-devandgensokyo-dev 0ae58b4a1f refactor(apple): read dispatch relative displacements through the shared readers
The Objective-C method and Swift relative-pointer decoders read 32-bit
displacements straight from the image bytes, beside the checked u32 and
pointer readers. The shared dispatch readers now provide i32 through the
image BinaryReader and both facets use it, so they no longer take the raw
image bytes.

Refs #11865

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-21 19:52:16 +01:00
gensokyo-devandgensokyo-dev add4faf2ad refactor(elf): read GNU property words through BinaryReader
readGnuPropertyWords decoded property type, size and feature words with
endian-selected raw Buffer reads. Every read already sits behind the
record length checks, so the shared reader returns the same values.

Refs #11865

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-21 19:52:16 +01:00
gensokyo-devandgensokyo-dev 3af56cc7d5 refactor(native): compose LLDB resolver cleanup through the shared owner
The resolver retry built a multi-marker ProviderCleanupError and bound
the markers by hand; providerCleanupErrorFromFailures builds the same
composite, including the distinct resource list.

Refs #11859

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-21 19:34:01 +01:00
morluto a63690ad3b test(native-ui): consolidate deadline and interruption coverage (#12850) 2026-11-20 14:35:21 +00:00
morluto 3dacda36f2 test(elf): consolidate debug-link candidate coverage (#12851) 2026-11-20 14:27:36 +00:00
morluto 8f762f9bc8 test(native): consolidate signature target cancellation coverage (#12791)
test(native): consolidate signature cancellation coverage
2026-11-20 12:37:05 +00:00
morlutoandCursor Agent be14c9d475 test: own temporary directories through createTestTempDirectory in src/ tests (#12725)
Give per-test temporary directories to the shared helper so Vitest removes
them after the case. Keep directories whose lifetime is the assertion, or
that are shared from beforeAll, on their existing cleanup.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-20 04:10:06 +00:00
74bdfd2ec2 test: assert structured recovery facts instead of recovery wording in src tests (#12721)
* test: assert structured recovery facts instead of recovery wording in src tests

Replace recovery-sentence locks with the structured fields that already
carry those facts, and own Batch 4 temporary directories through
createTestTempDirectory.

* test(hopper): keep recovery order that retry_action does not carry

retry_action names restart or unknown. It does not say to read
provider_operation_health before retrying, or to close_binary before
opening and retrying. Those order checks stay.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-19 23:05:20 -05:00
morluto e1e24543e4 test: prove retained facts and remove preinstall source greps 2026-11-19 22:12:19 -05:00
8c7977f174 fix(native)!: require separate inspection for plists outside bundles (#9754)
* fix(native): record inspected plist bytes and refuse files outside the bundle

An open app session keeps the executable as the Evidence subject for
inspect_plist, same as the other bundle-resource tools, but the result had
no digest of the plist bytes and any absolute path was sealed under that
subject. Record source_sha256 for the bytes read, and refuse a selection
that resolves outside the opened bundle.

Fixes #9479

* fix(native)!: scope plist selection to the opened bundle

BREAKING CHANGE: To inspect a plist outside an opened app bundle or resource root, open the plist as a separate target.

* fix(native): report plist snapshot filesystem effects

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 21:35:17 -05:00
morluto ea26a4a46c fix(elf): retain mapped leading GNU symbol version slots (#12685)
* fix(elf): retain mapped leading GNU symbol version slots

* fix(elf): report short version tables during admission
2026-11-20 02:19:55 +00:00
morluto ed96765d11 refactor(macho): share unsigned dispatch metadata reads (#12668) 2026-11-20 02:17:09 +00:00
morluto 68604b7e95 fix(elf): distinguish exhausted string tables from capped scans (#12693)
fix(elf): distinguish exact string-table ends from scan limits
2026-11-20 02:15:34 +00:00
morluto acd967c58a fix(elf): report the enforced kernel build config parser limit (#12679) 2026-11-20 02:02:48 +00:00
morluto 0fcbfe83dc fix(elf): retain readable build IDs beside compressed notes (#12674) 2026-11-20 02:02:45 +00:00
morluto c6f86cce57 fix(elf): preserve dynamic string diagnostic provenance (#12678)
* fix(elf): preserve DT_NEEDED diagnostic source offsets

* fix(elf): distinguish missing dynamic strings from invalid indices
2026-11-20 02:01:09 +00:00
morluto 2c7c858c5a refactor(native): share mapped ELF and FAT scalar readers (#12631) 2026-11-20 01:59:55 +00:00
morluto 46943787cb fix(macho): require exact legacy minimum-version command size (#12666) 2026-11-20 01:47:07 +00:00
morluto 273f048a55 fix(windows): report the enforced shortcut parser limit (#12661) 2026-11-20 01:38:27 +00:00
morluto 484bdc183a fix(elf): preserve truncated kernel config evidence at the inflate limit (#12653) 2026-11-20 01:36:11 +00:00
morluto 6596d294b9 refactor(macho): share selected fixup and magic field reads (#12637)
* refactor(macho): share selected fixup and magic field reads

* fix(macho): retain legacy weak and lazy bind streams
2026-11-20 01:34:45 +00:00
3cfe8480c5 fix(elf): decode a 32-bit prpsinfo whose ABI gives pr_uid 32 bits (#10189)
* fix(elf): decode a 32-bit prpsinfo whose ABI gives pr_uid 32 bits

`decodeCorePrpsinfo` assumed every ELFCLASS32 core carries the i386/ARM `struct elf_prpsinfo`:
16-bit `pr_uid`/`pr_gid` and a 124-byte descriptor.

`pr_uid` is `__kernel_uid_t`, and its width is an ABI property, not an ELF-class one. Only
`arch/x86/include/uapi/asm/posix_types_32.h` and its ARM/m68k/sparc counterparts narrow it to
`unsigned short`; everything else takes `asm-generic/posix_types.h`'s `unsigned int`, so MIPS o32,
PowerPC-32, s390 and `compat_elf_prpsinfo` (`include/asm-generic/compat.h`:
`typedef u32 __compat_uid_t`) write a 128-byte struct with every member after `pr_flag` four bytes
later.

Reading a 128-byte descriptor with the 124-byte offsets published wrong values rather than null.
Measured through `parseElfNotes`, with `uid 70000, gid 80000, pid 4242, fname mips-proc`:

    before: {"pid":80000,"ppid":4242,"pgrp":1,"sid":4242,"uid":4464,"gid":1,
             "filename":"\u{10}","psargs":""}
    after:  {"pid":4242,"ppid":1,"pgrp":4242,"sid":4242,"uid":70000,"gid":80000,
             "filename":"mips-proc","psargs":"./mips-proc --serve"}

`pid` came out of the middle of `gid` and the two text fields came from the wrong offsets
entirely.

The kernel writes `sizeof(*psinfo)` as the descriptor — `fs/binfmt_elf.c`:
`fill_note(&info->psinfo, PRPSINFO, sizeof(*psinfo), psinfo)` — so the declared length already
carries the distinction and no machine table is needed. The 32-bit id width is now
`descriptor.length >= 128 ? 4 : 2`, and `pr_pid`/`pr_fname`/`pr_psargs` are derived from it. The
124-byte and 136-byte decodes are unchanged; the second new case pins that.

`src/native/elf` and `src/domain/native` — 535 passing. Forcing the 16-bit layout fails the new case.

* test(elf): produce the 32-bit prpsinfo layout from the shared note builder

Review finding: the regression hand-encoded a second NT_PRPSINFO layout while `corePrpsinfoNote` is
the repository's producer for this format, so nothing else could represent the MIPS/PowerPC/s390
ABI and the two encodings could drift.

`corePrpsinfoNote` takes `idWidth: 2 | 4` now. It allocates 124 or 128 bytes from it, writes
`pr_uid`/`pr_gid` at that width, and derives `pr_pid` through `pr_psargs` from `8 + idWidth * 2`
instead of the fixed 12/28/44 offsets. The option is ignored for a 64-bit image, whose layout is
fixed at 136.

Both new cases build their descriptor through the producer, so the test no longer carries offsets
the fixture does not know about.

* test(elf): drop the duplicate 124-byte prpsinfo case

The previous commit's rewrite left the original hand-built 124-byte block in place, so the same
regression ran twice — once through `corePrpsinfoNote`, once with the offsets written out again.
Keeping both is exactly the drift the shared producer was supposed to end.

* fix(elf): preserve SuperH PRPSINFO decoding

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: wunianze666-netizen <wunianze666@gmail.com>
2026-11-20 01:23:27 +00:00
morluto a37fee0543 refactor(elf): project unwind limits from parser failures (#12644) 2026-11-20 01:19:20 +00:00