Skip to content

fix(cutter): keep exact digits of 64-bit JSON integers - #10337

Closed
rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/cutter-exact-json-integers
Closed

rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/cutter-exact-json-integers

Conversation

@rudycelekli

Copy link
Copy Markdown

Summary

cutter_command with json: true rounded Rizin integers above 2^53. Rizin prints unsigned 64-bit addresses in decimal, so on a kernel or other high-half image aflj, pdj and iej returned wrong addresses. For example, the real offset 0xffffffff81000078 came back as 18446744071578845000, which is 0xffffffff81000000, the image base. Cutter's cmdj is json.loads(cmd(command)) (src/python/cutter.py), and the bridge writes Python ints exactly. The loss happened only at the client's final JSON.parse. No open issue or PR matches this.

Problem and expected behavior

Smallest trigger: open an x86-64 ELF whose PT_LOAD is at 0xffffffff81000000 and run aflj with json: true. Real Rizin 0.9.1 output:

[{"offset":18446744071578845304,"name":"entry0","size":8,...,"minbound":18446744071578845304,"maxbound":18446744071578845312,...}]

Before: offset, minbound and maxbound all became 18446744071578845000, so the function's start and end were reported as the same address. After: integer literals that a JavaScript number cannot hold exactly are returned as decimal strings with the producer's digits ("18446744071578845304"). Safe integers, floats and every other value are unchanged.

Change and scope

  • CutterBridgeClient parses the authenticated response with a reviver. When a parsed number is not a safe integer and its source text (context.source) is an integer literal, the reviver returns that text. This follows the same source-text pattern as parseKunaJson and readPlistJson.
  • CutterBridgeService adds one limitation to json: true evidence that says such integers are returned as decimal strings. Text-mode (json: false) evidence does not change.

Not included: no change to the Python bridge, the frame decoder or the tool schema (output is already jsonValueSchema). Non-integral numbers that round are left as they are, because Rizin does not emit them for addresses.

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: CutterBridgeClient response parsing (after proof verification). CutterBridgeService evidence limitations consume it. No path was removed.
  • Contribution scope fit and linked maintainer decision: an ordinary correctness fix within the existing Cutter provider. Maintainer scope decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. In json: true output, an integer whose magnitude exceeds 2^53 - 1 is now a JSON string where it used to be a rounded number.
  • Provider, bridge, target-format, or platform compatibility: any Cutter or Rizin version. The bridge protocol is unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: normalized_result.output and raw_result keep exact digits. A new limitation names the representation.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • 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): none.

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:
    • tests/boundary/providers/CutterBridgeClient.test.ts "keeps exact digits of Rizin's unsigned 64-bit JSON addresses" serves the real Rizin 0.9.1 aflj integers through the authenticated v2 frame fixture.
    • tests/boundary/providers/CutterBridgeService.test.ts asserts that the limitation is present for json: true and absent for json: false.
  • Base reproduction or other evidence: base 54906fdb1fc735b507961b2954f6968775cae4f6. The producer bytes came from real rizin 0.9.1 (Homebrew, darwin-arm64), rizin -N -q -e scr.color=0 -c 'aa;aflj', on an 8-byte x86-64 ELF64 loaded at 0xffffffff81000000. With src/ reverted, the client test failed with "offset": 18446744071578845000, "minbound": 18446744071578845000 and "maxbound": 18446744071578845000 where the exact strings were expected. With the fix, it passed.
  • User-visible CLI/MCP output (if applicable): not exercised against a live Cutter.
  • Remaining proof gaps: no live Cutter run, because Cutter is not installed here. The Cutter-side cmdj behavior is source-derived from rizinorg/cutter src/python/cutter.py.

Lifecycle regressions: not applicable, because this change does not touch ownership, cancellation or cleanup.

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.

Validation performed

  • npx vitest run tests/boundary/providers/CutterBridgeClient.test.ts tests/boundary/providers/CutterBridgeService.test.ts: 60/60 passed with the fix. The new client test failed on base with src/ reverted.
  • npx vitest run tests/boundary/providers/cutterBridgeProducer.test.ts: one or two cases hit spawnSync python3 ETIMEDOUT under machine load (load average about 79). The same case fails identically on base with src/ reverted, so these failures are environmental.
  • npm run check:fast (typecheck and lint): passed.
  • npx oxfmt --check on the changed files: passed.
  • npm run test:focused did not reach Vitest on this machine. metadata:check fails in scripts/lib/verifier-source-loader.mjs because Node 26.12.1 rejects stripTypeScriptTypes mode: "transform". This fails before any test runs and is unrelated to this change.

Compatibility, safety, and release

  • Breaking changes or migration steps: none intended. A caller that read a rounded number for an integer above 2^53 now receives a string with the exact digits.
  • Real Hopper/Ghidra, browser, or OS coverage: real Rizin 0.9.1 output only. Cutter was not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: parsing runs only after the response proof is verified. No new I/O.

Prepared with AI assistance. Human ownership declarations remain pending.

Author readiness

Human owner: @rudycelekli

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

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the remaining request for number-boundary tests is non-blocking.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining request for number-boundary tests is non-blocking.

Findings

  1. P2 Number boundaries lack tests ▶
Fix with agent prompt
### Issue 1
tests/boundary/providers/CutterBridgeClient.test.ts:880-883
The new regression covers large positive integers but leaves the conversion boundary and float exclusion untested. Add raw-response cases for `9007199254740991`, `9007199254740992`, `-9007199254740993`, `9007199254740992.0`, and `1e20`. Assert that only unsafe integer literals become strings. Otherwise, a later parser change could alter floats or mishandle the cutoff without failing this regression.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Preserves large JSON integer literals as exact decimal strings when reading authenticated Cutter responses.

  • Cutter JSON results keep the exact digits of large integers.

Source review found no new actionable issue or security concern. Tests were not run during this review. Checking whether another PR supersedes this one was blocked by unavailable GitHub authentication.

Reviews (3) · Last reviewed commit: "fix(cutter): keep exact digits of 64-bit..." · Reviewed by Greptile

Comment on lines +880 to +883
const aflj =
'[{"offset":18446744071578845304,"name":"entry0","size":8,' +
'"minbound":18446744071578845304,"maxbound":18446744071578845312,' +
'"stackframe":8,"nbbs":1}]';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Number boundaries lack tests

The new regression covers large positive integers but leaves the conversion boundary and float exclusion untested. Add raw-response cases for 9007199254740991, 9007199254740992, -9007199254740993, 9007199254740992.0, and 1e20. Assert that only unsafe integer literals become strings. Otherwise, a later parser change could alter floats or mishandle the cutoff without failing this regression.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/boundary/providers/CutterBridgeClient.test.ts
Line: 880-883

Comment:
**Number boundaries lack tests**

The new regression covers large positive integers but leaves the conversion boundary and float exclusion untested. Add raw-response cases for `9007199254740991`, `9007199254740992`, `-9007199254740993`, `9007199254740992.0`, and `1e20`. Assert that only unsafe integer literals become strings. Otherwise, a later parser change could alter floats or mishandle the cutoff without failing this regression.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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: cutter Analysis provider / engine: cutter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants