Skip to content

fix: reject integer version fields above u64 - #141

Merged
HaoZeke merged 2 commits into
developfrom
repro-followup-r8-core-r11
Dec 3, 2026
Merged

HaoZeke merged 2 commits into
developfrom
repro-followup-r8-core-r11

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Reject integer version fields that do not fit in a u64, where the parser used to accept them. The spec, the FFI error detail and the tests now match.

Panel: 8/8, with 5 PASS and 3 NIT. Follow-ups for the nits live in ljos Software-go9l.


Note

Medium Risk
Behavior change for previously accepted metadata (huge version integers) across read/write/RPC paths; low security impact but may break files or clients that relied on saturation or unbounded minors.

Overview
CON-line2.22 is tightened so only con_spec_version, con_spec_minor, and con_spec_patch must fit in an unsigned 64-bit integer; other *_version metadata keys stay opaque. Spec docs and the 4.0.1 changelog wording are updated to match.

Parsers and writers no longer accept or saturate oversized integers on those three keys (including values that used to round-trip via u64::MAX / “substitutable huge minor”). They now fail with InvalidMetadataJson and the shared message that the field must be a JSON integer ≥ 0 that fits in u64. The same rule is applied consistently on the reader, frame builder, RPC metadata path, C FFI (surfacing that sentence in last_error), Python, and Julia (_minor_token_u64 and legacy rewrite checks for patch/version).

Conformance corpus, minor-token probe fixtures, and cross-binding tests are flipped so cases like con_spec_minor: 2^64 and float-edge huge minors are rejects instead of accepts.

Reviewed by Cursor Bugbot for commit 38ac7f1. Bugbot is set up for automated code reviews on this repo. Configure here.

CON-line2.22 rejects an integer literal above u64 on three reserved
fields, matched by exact name: con_spec_version, con_spec_minor, and
con_spec_patch. A larger integer is InvalidMetadataJson. 2^64-1 still
parses. The builder and the Python metadata path use that same check,
so a reserved integer above u64 is not written. A Python dict
con_spec_version above u64 is rejected with the same error as
set_metadata_json and is not replaced by major 4.

Unreserved keys are untouched. schema_version -1 stays accepted.
schema_version -0, -0.0, -0e0, and -1e-400 stay accepted, as do
abi_version and generator_version. An unreserved schema_version of
1e309 stays accepted on the reader. The builder still reports the
JSON number error for that token.

A negative integer on con_spec_minor and con_spec_patch is still
rejected, as it was before.

RPC round-trips 2^64-1 and rejects 2^64, including con_spec_patch.
A negative patch is rejected on that path too.

rkr_frame_builder_set_metadata_json records that same u64 sentence
on rkr_last_error. Other JSON failures stay on the generic status
text.

v2_minor_2pow64.con and d14_minor_2pow64.con in the corpus31
manifest expect the reserved integer above u64 to be rejected.

Kitline-Change: ykqsvtrwkpvnwowplvxwlyrnrwumvrlx

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8a3362c. Configure here.

Comment thread src/ffi.rs
let message = err.to_string();
if message.contains(crate::parser::DUPLICATE_CON_SPEC_MINOR)
|| message.contains("number out of range")
|| message.contains("fits in an unsigned 64-bit integer")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Builder FFI hides version errors

Medium Severity

rkr_frame_builder_set_metadata_json now fails on an unsupported or non-integer con_spec_version, but the C error stays generic RKR_STATUS_INVALID_JSON with the static "invalid JSON" text and line 0. The detail filter only keeps duplicate-key, out-of-range, and u64-ceiling messages, so UnsupportedVersion and the major-integer failure never replace it. A read of the same object reports the real status, message, and line 2.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8a3362c. Configure here.

rkr_frame_metadata_json synthesizes "con_spec_version":1 for implicit v1
frames, which rkr_frame_builder_set_metadata_json now rejects under
CON-line2.5 when validate_metadata_schema validates con_spec_version.
Drop that synthesized member on spec_version == 1 frames before handing
metadata JSON to the builder so v1 rewrites upgrade cleanly and match
rkr_frame_binding_rewrite byte-for-byte.

Remove huge con_spec_minor saturation in _minor_token_u64 and _json_u64,
update _INVALID_CON_SPEC_MINOR to the u64 message, and pass invalid
con_spec_patch tokens unchanged to the builder rather than stripping them
on major-3 rewrites. Update the Julia test suite to expect u64 rejection
without saturation.

Kitline-Change: qrytzmoovlszrvzsmqxunoqnpqsoxvoz
@HaoZeke
HaoZeke merged commit 285f8f6 into develop Dec 3, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant