Skip to content

fix(cli): reject non-decimal binary diagnostic limits - #9166

Closed
Plastic-time wants to merge 2 commits into
morluto:mainfrom
Plastic-time:rrfz/decimal-pe-inspection-limits
Closed

Plastic-time wants to merge 2 commits into
morluto:mainfrom
Plastic-time:rrfz/decimal-pe-inspection-limits

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Most limits in src/cli/binaryDiagnosticsCommands.ts were registered as the shared numeric fields. Incur reads those through Number(). So inspect-pe-imports --max-dlls 0x2 enforced a two-descriptor budget, and --max-file-bytes 1e3 meant 1000 bytes. #8919 fixed the same coercion for the byte-entropy window in this file with cliDecimalField. This change uses that helper for the other 26 limits in the file.

No issue is linked. I found this while checking which numeric CLI options still go through Number().

Problem and expected behavior

On main bacc1e384, with C:\Windows\System32\notepad.exe (3 import descriptors):

  • rea inspect-pe-imports notepad.exe --max-dlls 0x2 --json exits 1 with resource_constraint: "Import inventory declares 3 descriptors, above the 2-entry DLL allowance". --max-dlls 2 gives the same result.
  • The same holds for every limit below. Each 0x… or 1e… spelling within the field's bounds is admitted as its numeric value.

Expected: these limits take decimal text only. A non-decimal spelling is refused during argument parsing and names the field. Decimal values keep the shared bounds and defaults.

Change and scope

src/cli/binaryDiagnosticsCommands.ts wraps each shared field in cliDecimalField(...):

  • inspect-elf-notes: --max-file-bytes, --max-entries
  • inspect-apple-ips: --max-file-bytes, --max-threads, --max-frames, --max-images, --max-registers, --max-integer-text-bytes
  • inspect-kernel-module: --max-file-bytes, --max-entries
  • inspect-pe-load-config: --max-file-bytes, --max-callbacks
  • inspect-binary-hardening: --max-file-bytes
  • inspect-pe-certificates: --max-file-bytes, --max-entries
  • inspect-pe-imports: --max-file-bytes, --max-dlls, --max-functions
  • inspect-pe-resources: --max-file-bytes, --max-entries
  • inspect-devicetree: --max-file-bytes, --max-nodes, --max-properties, --max-depth (the CLI descriptions stay)
  • inspect-native-exports: --max-file-bytes
  • inspect-binary-layout and inspect-recorded-crash: --pwntools-timeout-ms (optional, still absent when omitted)

The byte-entropy options were already decimal-only. MCP is unchanged.

Scope decision: not applicable. This is an ordinary fix within the existing CLI boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: each inspect*InputSchema still owns its bounds and defaults. CLI argument parsing now admits only decimal text before it.
  • Contribution scope fit and linked maintainer decision: ordinary fix; not applicable.
  • CLI and MCP/tool-catalog contract: the 26 CLI options now refuse non-decimal text. Help keeps every description and default; the type hint changes from <number> to <value>, as for the byte-entropy options. MCP is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none. A decimal limit reaches the same service input as before.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): a refused option reads no file.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none committed.

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: a "binary diagnostic limit options" block in tests/boundary/cli/cliIntegerArguments.test.ts, after the pyc and BEAM block.

    • One row per option. Each passes a single 0x… or 1e… spelling that Number() admits within that field's bounds, and expects VALIDATION_ERROR naming the field.
    • One positive case runs inspect-pe-imports --max-functions=01 on the existing peImportImage() fixture (two functions). It expects resource_constraint with details.reported_limits { limit: "functions", maximum: 1 }, so the decimal value reaches the service.
  • Base reproduction: with main's binaryDiagnosticsCommands.ts (rebuilt by test:focused), the file gives 27 failed, 112 passed. All 27 rejection rows fail; the positive case passes. With this change: 139 passed.

  • User-visible CLI output, inspect-pe-imports C:\Windows\System32\notepad.exe --max-dlls 0x2 --json:

    Before: exit 1, "code":"resource_constraint", "above the 2-entry DLL allowance".

    After:

    {"code":"VALIDATION_ERROR","message":"REA could not read the command arguments. Check the named argument and its expected type, then try again.","fieldErrors":[{"code":"invalid_format","missing":false,"path":"maxDlls","expected":"","received":"","message":"Expected a decimal integer"}]}

    --max-dlls 2 still gives the 2-entry resource_constraint. inspect-pe-imports --help shows the same descriptions and defaults as main.

  • Remaining proof gaps: Linux CI has not run yet. The pwntools options are only checked at argument parsing here, since pwntools runs on Linux x64 only.

Boundary regressions: input admission at the CLI argument boundary, through the compiled CLI. Lifecycle regressions: not applicable.

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.

Not an evidence-bearing change.

Validation performed

Windows 11, Node.js 24.22.1, base bacc1e384.

Compatibility, safety, and release

  • Breaking changes or migration steps: a non-decimal spelling such as 0x2 or 1e3 is now refused. The limits are documented as counts, byte sizes and milliseconds, so this follows fix(cli): reject non-decimal byte-entropy window options #8919 without a breaking marker.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process, file, or network effect.

Author readiness

Human owner: @Plastic-time

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

@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-06T16:12:05.466754Z
We couldn’t complete this review. Comment @codex review to try again.
17ded34 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 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

Uses cliDecimalField for the remaining binary diagnostic limits, keeping bounds and defaults in the shared schemas.

  • Binary inspection commands accept decimal limit values only.

Reviews (3) · Last reviewed commit: "test(cli): assert binary limit facts and..." · Reviewed by Greptile

The decimal keep case matched "max_functions above 1" in the
remediation text. It now checks details.reported_limits for the
functions limit with maximum 1, so a wording change cannot break it.

The rejection rows put the value third. The test name now prints the
tested spelling, such as --max-functions=1e1, instead of the field.
@morluto morluto closed this Nov 7, 2026
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants