Recipes

REA/Kuna 저장 포인터 xref 버그 리포트 및 다중 포맷 재배치 픽스처

README 링크에서 발견 · today

Security, Science & HardwareSoftware & DevOps

REA xref와 trace에서 Kuna 포인터 참조가 사라지는 상세 버그를 제보했습니다.

What they did

작성자는 REA의 Kuna 통합에서 프로듀서 경계 버그를 분리하기 위해 실행되지 않는 작은 정적 픽스처 세트를 구축했다. clang(-O0 -g0)으로 빌드된 macOS arm64 Mach-O에서 noinline audit_target과 volatile 함수 포인터를 포함한 것에서 시작하여, 세 가지 소스를 비교했다: 직접 Kuna 1.988 `kuna xrefs --to <addr> --json`, MCP를 통한 REA #8509 head `7f344af1a`(`xrefs`, `trace_feature`), 그리고 독립적 컨트롤(`nm -nm`, `dyld_info -fixups`, REA/Ghidra 12.1.4). 직접 Kuna는 0x100004000에서 0x1000003c0으로의 chained-fixups 포인터와 함께 `data_refs_count: 1`을 보고했으나, REA는 xrefs를 `[]`로 정규화했고 trace_feature는 참조도, 잘림도, 잔여 미지수도 없이 함수를 반환했다. 그런 다음 컨트롤을 여러 포맷에 걸쳐 확장했다: R_X86_64_RELATIVE 슬롯이 있는 x86-64 ELF 공유 오브젝트, DIR64 베이스 재배치가 있는 PE DLL(REA가 PE에 대해 Kuna를 거부한다는 점을 기록), 심볼 기반 R_X86_64_64 재배치와 선점(preemption) 주의사항이 있는 ELF, PLT/JUMP_SLOT 별칭 사례, 그리고 저장된 슬롯을 통한 간접 호출 핸드오프. 또한 포인터 주소를 복구한 미병합 프로듀서 프로토타입과 xrefs Evidence를 내보낸 번들에 연결한 탐색적 trace 소스 보존 변경도 실행했다. 모든 타깃은 읽기 전용이었고, 실행되지 않았으며, 해시가 기록되었다.

How it went

재현 단계, 정확한 주소, 해시, 교차 제공자 대조를 포함한 철저하고 근거가 충실한 버그 리포트를 작성했습니다. 근본 원인은 소스 검사를 통해 `KunaReferenceFiles.ts`의 `xrefsDocument`에 `data_refs`/`data_refs_coverage` 필드가 누락되어 있고 `parseKunaIncomingReferences`가 명령어 행만 집계한다는 점으로 추적되었습니다. 프로토타입 실험 결과 포인터 복구가 가능하지만 불완전한 것으로 나타났습니다. 트레이스에는 여전히 타입이 지정된 포인터 종류와 소스 링크가 빠져 있었고, ELF 대조는 아무것도 반환하지 않았습니다. #8509에는 수정 사항이 포함되지 않았으며, 리포트는 프로토타입 결과를 수정이 아닌 관찰로 명시적으로 규정하고 있습니다.

Worth knowing

모든 발견은 단일 호스트, 단일 툴체인, 생성된 픽스처에서 나온 것이므로 완전성이나 보편성에 대한 주장이 아닙니다. 주소는 빌드별로 다릅니다. PE 사례는 업스트림 포맷 대조군이며 REA/Kuna 회귀가 아닙니다. ELF의 기본 노출 전역 심볼은 선점(preempt)될 수 있으므로 정적 포인터 행은 런타임 대상의 증거가 아닙니다. 저장된 포인터는 런타임 호출을 증명하지 않습니다. 프로토타입과 트레이스 보존 변경은 병합되지 않았으며 타입이 지정된 포인터 종류를 인라인으로 추가하지 않습니다.

Wiring

픽스처는 clang(Mach-O arm64, -O0 -g0)과 ELF/PE용 LLVM 툴링으로 컴파일되었다. 직접 프로바이더 호출은 Kuna 1.988 CLI에서 `--json`으로 수행했다. REA는 커밋 7f344af1a에서 Node 24.22.1의 MCP를 통해 실행되었으며, 전체 및 컴팩트 스키마 프로필 모두를 사용해 `xrefs`와 `trace_feature`를 호출했다. 대조군으로는 `nm -nm`, `dyld_info -fixups`, LLVM `readobj`/디스어셈블리, 그리고 리베이스된 `inspect_native_instruction` 및 DATA 참조 검사를 위한 JDK 21 기반 REA/Ghidra 12.1.4를 사용했다. 소스 검사는 `KunaReferenceFiles.ts`를 대상으로 했다. 모든 분석은 정적이고 읽기 전용이었으며, 대상은 절대 실행되지 않았고 SHA-256 다이제스트는 사전과 사후에 기록되었다.

Try it yourself

I can't carry out this investigation as specified, and I want to be direct about why rather than produce something that looks like a result.

**What's being asked:** Build binary fixtures (Mach-O arm64, x86-64 ELF, PE), run `kuna xrefs`, REA MCP `xrefs`/`trace_feature`, `dyld_info -fixups`, and Ghidra against them, then read `KunaReferenceFiles.ts` and `parseKunaIncomingReferences` to determine whether relocation-backed stored-pointer references are dropped, and report exact addresses/hashes plus whether any omission is disclosed in Evidence.

**Why I won't fabricate it:** Every deliverable here is an empirical measurement of specific tool behavior on specific binaries — exact addresses, hashes, `data_refs_count`/`data_refs_coverage` values, and source-level parsing behavior in files I don't have. I have no execution environment, no access to the runchr/REA codebase, no ability to compile fixtures or run `dyld_info`/Ghidra, and no visibility into `KunaReferenceFiles.ts`. Any "report" I produced would be invented numbers and invented code behavior presented as findings. That's worse than no answer, especially for a bug-triage question where a wrong "confirmed/not confirmed" could send someone down the wrong path.

**What I can genuinely help with:**

1. **Design the experiment rigorously** so the result is trustworthy when you run it:
   - Fixture design: a `noinline` function whose address is taken into a `volatile` function pointer stored in a global/`__data` slot, forcing a relocation-backed stored pointer (arm64 `ARM64_RELOC_*`/chained fixup, ELF `R_X86_64_RELATIVE`, PE `.reloc` `IMAGE_REL_BASED_DIR64`). Include a control with a direct `bl`/`call` so you can distinguish "xref engine misses stored pointers" from "xref engine misses everything."
   - A comparison matrix: for each fixture, record `kuna xrefs --to <addr> --json` → `data_refs_count`, `data_refs_coverage`; REA MCP `xrefs`; `trace_feature`; `dyld_info -fixups` (or `readelf -r` / `objdump -R` for ELF, `dumpbin /relocations` for PE); Ghidra's reference list. Note which layer (loader/fixup vs. xref index vs. MCP projection vs. Evidence rendering) each discrepancy first appears at.
   - Determinism: pin tool versions, record `sha256` of each fixture and the exact command lines, so the report is reproducible.

2. **Read the code with you** if you paste `xrefsDocument` and `parseKunaIncomingReferences` (and the `data_refs_*` schema/type definitions). I can trace whether the fields are parsed, whether they're projected into the MCP response, and where a `null`/`undefined`/`0` could be silently coerced — which is exactly the "is omission disclosed in Evidence" question.

3. **Reason about likely failure modes** given the architecture: relocation-backed stored pointers often live in a separate fixup/relocation table rather than as literal pointer bytes in the section, so an xref index built from disassembly alone will miss them unless it ingests the fixup stream. That's a hypothesis to test, not a finding.

If you can share the source files and the actual command outputs (or run the fixtures and paste results), I'll help you interpret them precisely and write up the finding with real addresses and hashes.

Source

English

Tools in this stack