Skip to content

fix(kuna): stop calling executable-segment data sections definite data - #10686

Merged
morluto merged 4 commits into
morluto:mainfrom
Davmunrey:fix/kuna-exec-const
Nov 18, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
Davmunrey:fix/kuna-exec-const

Conversation

@Davmunrey

@Davmunrey Davmunrey commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #8352. With Kuna, an address in a Mach-O section whose attributes declare no instructions was refused as "data that Kuna lists, not a procedure". This happened even when the section sits in an executable segment. In the issue's fixture:

  • a direct call targets _placed_in_const in __TEXT,__const (segment initprot r-x);
  • REA's own procedure_callees reports that call;
  • Ghidra decodes and decompiles the destination.

Yet the Kuna refusal stated categorically that the entry is data.

Change and scope

  • KunaInventoryPlacement.ts: each data placement now records whether its enclosing segment's initial protection includes VM_PROT_EXECUTE (codePossible). The Mach-O header placement is always false.
  • For executable-segment placements, the refusal changes three things:
    • It keeps the section declaration and the classification, but says REA's Kuna lane does not treat the entry as a procedure, and that the declaration alone does not prove the bytes are not code.
    • Its remediation adds the Ghidra provider as a route to decode the entry.
    • address_name's limitation is qualified the same way.
  • Non-executable segments and the Mach-O header keep the existing wording and remediation.
  • Not included: procedure tools still refuse these entries. Making them followable through Kuna needs a design decision.

Evidence and regression coverage

  • tests/boundary/providers/kuna/kunaMachoInventory.test.ts covers the fixture's table entry in executable __TEXT,__const: the exact refusal, the Ghidra route in the remediation, and the address_name limitation. An unchanged __DATA,__data control has no Ghidra route.
  • kunaInventoryPlacement.test.ts: the placement map now carries { region, codePossible }.
  • The full Kuna boundary directory shows the same 11 environment-related failures (root and CPU load: doctor, project cache, version probe) on unchanged main as on this branch. The changed files' tests pass.

Validation performed

  • npm run test:focused -- tests/boundary/providers/kuna/kunaMachoInventory.test.ts tests/boundary/providers/kuna/kunaMachoInventoryMcp.test.ts tests/boundary/providers/kuna/kunaInventoryPlacement.test.ts: passed.
  • npm run check:fast passed.
  • Gap: no real Kuna run.

Maintainer follow-up

Kuna list and search now keep the same executable-segment caveat as direct refusal and address lookup. Non-executable data and Mach-O headers keep their data classification. The original listing failed the new mixed-inventory assertion. Seventeen focused fixture tests and check:ci:fast passed on the repair. The eight CLI/MCP inventory tests passed again after bringing in current main, and the pre-push checks passed. This follow-up used provider fixtures.

Author readiness

Human owner: @Davmunrey

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

An address in a Mach-O section whose attributes declare no instructions
was refused as "data that Kuna lists, not a procedure", even when the
section sits in an executable segment. In morluto#8352 a direct call targets
`_placed_in_const` in `__TEXT,__const` (segment initprot r-x), Ghidra
decodes and decompiles it, and REA's own procedure_callees reports the
call, yet the Kuna refusal asserted it categorically as data.

The Mach-O layout now records, for each data placement, whether its
enclosing segment's initial protection includes VM_PROT_EXECUTE. For such
placements the refusal keeps the section declaration and the
classification, but says REA's Kuna lane does not treat the entry as a
procedure and that the declaration alone does not prove the bytes are
not code; its remediation adds the Ghidra provider as a decoding route.
address_name's limitation is qualified the same way. Non-executable
segments and the Mach-O header keep the existing wording. Procedure
tools still refuse these entries; making them followable is left open.

Validation: kunaMachoInventory and kunaInventoryPlacement boundary tests
cover the executable `__TEXT,__const` entry, its remediation and
address_name limitation, and an unchanged `__DATA` control. The full
Kuna boundary directory shows the same 11 environment-related failures
on unchanged main as on this branch; check:fast passes.

Refs morluto#8352
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T23:25:13.026539Z
We couldn’t complete this review. Comment @codex review to try again.
cc59b02 PR opened
ℹ️ 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.

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

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable correctness or security issues were found.

Summary

Kuna now qualifies refusals for entries in executable Mach-O segments without changing which entries procedure tools accept.

  • Kuna describes executable-segment entries as possibly code, not definite data.

The earlier shared-name finding is addressed. No new actionable issues were found. Validation here was source-based; no tests or real Kuna runs were performed.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/kuna/KunaSessionClient.ts Resolved
…shared by data entries

Review follow-up: a name that several data entries share took a grouped refusal that still said "they are data, not procedures" and offered no Ghidra route, even when one entry lies in an executable segment. The grouped message and remediation now come from KunaInventoryPlacement beside the single-entry ones: with an executable placement they keep the caveat and the Ghidra route, and otherwise the wording is unchanged.

Tests: a shared-name case with and without an executable-segment entry fails before this change and passes after; the Mach-O inventory tests pass. Five process-lifecycle Kuna test files fail identically with and without this change in this environment.
@Davmunrey

Copy link
Copy Markdown
Contributor Author

Ready to merge: full CI is green on this head, Greptile's latest review is 5/5 with no open threads, and it merges into main 42cab26 without conflicts.

@morluto
morluto merged commit 1920525 into morluto:main Nov 18, 2026
40 checks passed
@morluto morluto added bug Something isn't working provider: kuna Analysis provider / engine: kuna labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: kuna Analysis provider / engine: kuna

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants