fix: correct native inventories and bridge error classification (#503)

* fix(hopper): preserve normalized inventory addresses

* test(hopper): isolate real inventory verification

* fix(native): preserve otool addresses and section alignment

* fix: preserve address spaces in call path evidence

* fix(hopper): distinguish request validation from provider faults

* fix(native): retain tool inventory facts and reject failed signatures
This commit is contained in:
morluto
2026-10-04 17:25:09 +08:00
committed by GitHub
parent 4fbc501121
commit 405732a7f5
34 changed files with 1009 additions and 161 deletions
+4 -3
View File
@@ -1,3 +1,4 @@
imports:
0x100001100 libSystem.B.dylib _malloc
0x100001108 libobjc.A.dylib _objc_msgSend weak
/usr/lib/libobjc.A.dylib [arm64e]:
-imports:
__Block_copy (from libSystem)
_objc_bp_assist_cfg_np [weak-import] (from libSystem)
+43
View File
@@ -0,0 +1,43 @@
# Apple native inventory captures
These outputs were captured from the installed Apple tools on macOS arm64.
The executable's filename in tool output is replaced with `fixture`. Import
hexadecimal indexes are binding ordinals, while the export table contains image
offsets. The absolute export is not relative to the image base. `nm` also reports
each exported name, exercising the merge that must preserve richer dyld facts.
Generate the executable locally; do not check its binary into the repository:
```sh
cat > /tmp/rea-inventory.c <<'C'
#include <stdio.h>
__attribute__((weak)) int fixture_weak(void) { return 2; }
int fixture_export(void) { return 1; }
__asm__(".globl _fixture_absolute\n.set _fixture_absolute, 0x42");
int main(void) { puts("fixture"); return fixture_export() + fixture_weak(); }
C
xcrun clang /tmp/rea-inventory.c -o /tmp/rea-inventory
xcrun file -b /tmp/rea-inventory
xcrun lipo -detailed_info /tmp/rea-inventory
xcrun otool -l /tmp/rea-inventory
xcrun nm -gjU /tmp/rea-inventory
xcrun dyld_info -imports /tmp/rea-inventory
xcrun dyld_info -exports /tmp/rea-inventory
xcrun dwarfdump --uuid /tmp/rea-inventory
xcrun vtool -show-build /tmp/rea-inventory
```
Addresses, UUIDs and build versions may vary with the installed toolchain; the
checked-in captures are the golden input. The test checks the virtual addresses
corresponding to those captured offsets and image base.
`../dyld-imports.txt` contains verbatim header and representative ordinary/weak
import rows from `xcrun dyld_info -imports /usr/lib/libobjc.A.dylib`.
`library-reexports.txt` contains the header and one reexport row from
`xcrun dyld_info -exports /usr/lib/libc++.1.dylib`. These are separate library
captures used to check their respective row formats.
`codesign-missing.txt` is stderr from `codesign -d --verbose=4` on a nonexistent
path (exit 1). `codesign-unsigned.txt` is stderr from the same command on a copy
of the fixture after `codesign --remove-signature` (exit 1). Only the latter is
an observation that the artifact is unsigned.
@@ -0,0 +1 @@
/tmp/does-not-exist-rea-types: No such file or directory
@@ -0,0 +1 @@
/tmp/rea-native-types/unsigned: code object is not signed at all
@@ -0,0 +1 @@
UUID: DD511BAA-DF23-31EA-A44A-0E09FC69C471 (arm64) fixture
@@ -0,0 +1,8 @@
fixture [arm64]:
-exports:
offset symbol
0x00000000 __mh_execute_header
0x00000042 _fixture_absolute [absolute]
0x00000468 _fixture_export
0x00000460 _fixture_weak [weak-def]
0x00000470 _main
+1
View File
@@ -0,0 +1 @@
Mach-O 64-bit executable arm64
@@ -0,0 +1,4 @@
fixture [arm64]:
-imports:
0x0000 _puts (from libSystem)
0x0001 _fixture_weak (from <weak-def-coalesce>)
@@ -0,0 +1,4 @@
/usr/lib/libc++.1.dylib [arm64e]:
-exports:
offset symbol
[re-export] __ZNKSt10bad_typeid4whatEv (from libc++abi)
+2
View File
@@ -0,0 +1,2 @@
input file fixture is not a fat file
Non-fat file: fixture is architecture: arm64
+5
View File
@@ -0,0 +1,5 @@
__mh_execute_header
_fixture_absolute
_fixture_export
_fixture_weak
_main
+195
View File
@@ -0,0 +1,195 @@
fixture:
Load command 0
cmd LC_SEGMENT_64
cmdsize 72
segname __PAGEZERO
vmaddr 0x0000000000000000
vmsize 0x0000000100000000
fileoff 0
filesize 0
maxprot 0x00000000
initprot 0x00000000
nsects 0
flags 0x0
Load command 1
cmd LC_SEGMENT_64
cmdsize 392
segname __TEXT
vmaddr 0x0000000100000000
vmsize 0x0000000000004000
fileoff 0
filesize 16384
maxprot 0x00000005
initprot 0x00000005
nsects 4
flags 0x0
Section
sectname __text
segname __TEXT
addr 0x0000000100000460
size 0x0000000000000050
offset 1120
align 2^2 (4)
reloff 0
nreloc 0
flags 0x80000400
reserved1 0
reserved2 0
Section
sectname __stubs
segname __TEXT
addr 0x00000001000004b0
size 0x0000000000000018
offset 1200
align 2^2 (4)
reloff 0
nreloc 0
flags 0x80000408
reserved1 0 (index into indirect symbol table)
reserved2 12 (size of stubs)
Section
sectname __cstring
segname __TEXT
addr 0x00000001000004c8
size 0x0000000000000008
offset 1224
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000002
reserved1 0
reserved2 0
Section
sectname __unwind_info
segname __TEXT
addr 0x00000001000004d0
size 0x0000000000000060
offset 1232
align 2^2 (4)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Load command 2
cmd LC_SEGMENT_64
cmdsize 152
segname __DATA_CONST
vmaddr 0x0000000100004000
vmsize 0x0000000000004000
fileoff 16384
filesize 16384
maxprot 0x00000003
initprot 0x00000003
nsects 1
flags 0x10
Section
sectname __got
segname __DATA_CONST
addr 0x0000000100004000
size 0x0000000000000010
offset 16384
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000006
reserved1 2 (index into indirect symbol table)
reserved2 0
Load command 3
cmd LC_SEGMENT_64
cmdsize 72
segname __LINKEDIT
vmaddr 0x0000000100008000
vmsize 0x0000000000004000
fileoff 32768
filesize 824
maxprot 0x00000001
initprot 0x00000001
nsects 0
flags 0x0
Load command 4
cmd LC_DYLD_CHAINED_FIXUPS
cmdsize 16
dataoff 32768
datasize 112
Load command 5
cmd LC_DYLD_EXPORTS_TRIE
cmdsize 16
dataoff 32880
datasize 96
Load command 6
cmd LC_SYMTAB
cmdsize 24
symoff 32984
nsyms 6
stroff 33096
strsize 88
Load command 7
cmd LC_DYSYMTAB
cmdsize 80
ilocalsym 0
nlocalsym 0
iextdefsym 0
nextdefsym 5
iundefsym 5
nundefsym 1
tocoff 0
ntoc 0
modtaboff 0
nmodtab 0
extrefsymoff 0
nextrefsyms 0
indirectsymoff 33080
nindirectsyms 4
extreloff 0
nextrel 0
locreloff 0
nlocrel 0
Load command 8
cmd LC_LOAD_DYLINKER
cmdsize 32
name /usr/lib/dyld (offset 12)
Load command 9
cmd LC_UUID
cmdsize 24
uuid DD511BAA-DF23-31EA-A44A-0E09FC69C471
Load command 10
cmd LC_BUILD_VERSION
cmdsize 32
platform 1
minos 26.0
sdk 26.5
ntools 1
tool 3
version 1267.0
Load command 11
cmd LC_SOURCE_VERSION
cmdsize 16
version 0.0
Load command 12
cmd LC_MAIN
cmdsize 24
entryoff 1136
stacksize 0
Load command 13
cmd LC_LOAD_DYLIB
cmdsize 56
name /usr/lib/libSystem.B.dylib (offset 24)
time stamp 2 Thu Jan 1 08:00:02 1970
current version 1356.0.0
compatibility version 1.0.0
Load command 14
cmd LC_FUNCTION_STARTS
cmdsize 16
dataoff 32976
datasize 8
Load command 15
cmd LC_DATA_IN_CODE
cmdsize 16
dataoff 32984
datasize 0
Load command 16
cmd LC_CODE_SIGNATURE
cmdsize 16
dataoff 33184
datasize 408
+10
View File
@@ -0,0 +1,10 @@
fixture:
Load command 10
cmd LC_BUILD_VERSION
cmdsize 32
platform MACOS
minos 26.0
sdk 26.5
ntools 1
tool LD
version 1267.0
+27
View File
@@ -0,0 +1,27 @@
# High-address otool capture
`otool-high-address.txt` is captured output from the installed Apple `otool`,
with only its first filename line changed to `fixture:`. It exercises addresses
above JavaScript's safe integer range and the actual `2^N (bytes)` alignment
notation. The minimal Mach-O is generated locally; no binary is checked in.
Reproduce the capture on macOS with Xcode command line tools:
```sh
python3 - <<'PY'
import struct
from pathlib import Path
base = 0xfffffff007004001
header = struct.pack('<8I', 0xfeedfacf, 0x0100000c, 0, 5, 1, 152, 0, 0)
segment = struct.pack(
'<II16sQQQQIIII', 0x19, 152, b'__TEXT', base, 0x1000, 0, 185, 5, 5, 1, 0,
)
section = struct.pack(
'<16s16sQQIIIIIIII', b'__text', b'__TEXT', base + 184, 1,
184, 0, 0, 0, 0x80000400, 0, 0, 0,
)
Path('/tmp/rea-high-address.macho').write_bytes(header + segment + section + b'\xc0')
PY
xcrun otool -l /tmp/rea-high-address.macho
```
+25
View File
@@ -0,0 +1,25 @@
fixture:
Load command 0
cmd LC_SEGMENT_64
cmdsize 152
segname __TEXT
vmaddr 0xfffffff007004001
vmsize 0x0000000000001000
fileoff 0
filesize 185
maxprot 0x00000005
initprot 0x00000005
nsects 1
flags 0x0
Section
sectname __text
segname __TEXT
addr 0xfffffff0070040b9
size 0x0000000000000001
offset 184
align 2^0 (1)
reloff 0
nreloc 0
flags 0x80000400
reserved1 0
reserved2 0