GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — id(tuple): decode accepts negative ints that wrap to zero/positive and NaN floats — the negative branch has no range check, unlike the positive branch · Issue #1610 · developing-today/code

id(tuple): decode accepts negative ints that wrap to zero/positive and NaN floats — the negative branch has no range check, unlike the positive branch #1610

New issue
Copy link
New issue
Copy link
Closed
#1746
Closed
id(tuple): decode accepts negative ints that wrap to zero/positive and NaN floats — the negative branch has no range check, unlike the positive branch#1610
#1746
Copy link
Assignees
dezren39
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

@dezren39
dezren39
opened on Oct 28, 2026
Issue body actions

Problem

pkgs/id/src/tuple.rs decode / decode_one (380, 393) accepts integer and float encodings that the encoder can never produce and that the positive-int branch explicitly refuses — so a crafted or corrupted tuple key decodes to a different value than its tag claims, silently.

Verified this run by replicating the decoder's exact arithmetic (no code compiled on the sandbox):

1. Negative ints have no range check — they wrap to zero or positive

Positive branch (tuple.rs:446-461) checks the payload:

ensure!(i64::try_from(v).is_ok(), "positive integer exceeds i64::MAX");

Negative branch (tuple.rs:464-478) has no equivalent check on abs before 0u64.wrapping_sub(abs) as i64:

  • tag 0x13 (1-byte negative), payload 0xFF → ones-complement abs = 0 → decodes to Int(0) — zero via a negative tag (canonical zero is the single 0x14 tag).
  • tag 0x0C (8-byte negative), payload 0x00 × 8 → abs = u64::MAX → 0 - abs wraps → decodes to Int(1) — a positive value from a negative tag, at the negative end of the sort order.
  • tag 0x0C, payload 0x7F 0x00… → abs = 9295429630892703743 (> 2^63) → decodes to Int(9151314442816847873), again positive.

The encoder (push_int, tuple.rs:~335-350) can only emit abs in 1..=2^63 for values i64::MIN..=-1.

2. Floats decode to NaN, which the encoder refuses

Encoder float() (tuple.rs:260-264) rejects NaN ("NaN cannot be encoded in tuple keys"; TupleValue::Float is documented "NaN excluded"). The FLOAT64 decode branch (tuple.rs:482-499) reverses the sort transform and returns f64::from_be_bytes(b) with no is_nan check — e.g. payload 21 FF F8 00 00 00 00 00 00 decodes to Float(NaN).

3. Non-minimal int encodings are accepted

Both int branches accept leading-zero payloads the encoder's byte_len minimal encoding never emits — e.g. tag 0x16 (2-byte positive) payload 00 01 decodes to Int(1), whose canonical encoding is 0x15 01. Two distinct keys therefore decode to the same value.

Why it matters

Tuple keys are the sort-preserving keys for the tag store: tags.rs decode_alpha_key / decode_omega_key (tags.rs:585, 609) run decode over keys read back from the namespace documents and trust the decoded subject/key/value. A key that decodes to a value outside its tag's range breaks the encoding's core invariant — byte order preserves semantic order (module doc, tuple.rs:1-25) — and does so silently: the positive branch proves the authors intended out-of-range payloads to be an error, the negative branch just misses it. This is the same asymmetry class as the store's other canonical-decoding rules (e.g. chain.rs refuses non-canonical encodings outright).

Acceptance criteria

  • Decoding a negative-int payload with abs == 0 or abs > 2^63 returns an error (mirroring the positive branch's range check), with unit tests for abs == 0, abs == 2^63 (valid, i64::MIN), abs == 2^63 + 1, and abs == u64::MAX.
  • Decoding a float payload that reverses to NaN returns an error, with a unit test using a crafted NaN payload.
  • Non-minimal int encodings (a payload whose first byte makes a shorter encoding possible) are either refused with tests, or explicitly documented as accepted — one behaviour, pinned.
  • All existing tuple round-trip and sort-order tests still pass; no encoder change (encodings on disk/in documents are unchanged).

Activity

Next
  1. developing-today commented on Oct 28, 2026

    @developing-today
    developing-todayBot
    on Oct 28, 2026 – with developing.today
    Contributor
    More actions

    CODE-634

  2. dezren39
    added
    queue/queuedHas a queued queue task
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    effort/sSmall: expected under 2 hours of work
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    dezren39
    on Oct 28, 2026
    MemberAuthor
    More actions

    🤖 Agent note · state: filed

    • Agent: new-issue-creator (new-issue-creator-code-b)
    • Session / ID: new-issue-creator-code-b · 2026-10-28 01:20 CDT run
    • Found via: filed this run
    • Task: Filed tuple decoder canonicality bug: negative-int branch lacks the positive branch's range check (wraps to 0/positive), NaN floats decode despite encoder refusal, non-minimal int encodings accepted. Enqueued for triage.
    • Expectation: effort/s — triage confirms the fix scope (decoder range/NaN checks + tests) in pkgs/id/src/tuple.rs; no encoder change.
    • Links: packet enqueued to repo-health-code-pilot (see backlog entry)
  4. dezren39 commented on Oct 28, 2026

    @dezren39
    dezren39
    on Oct 28, 2026
    MemberAuthor
    More actions

    🤖 Agent note · state: filed (addendum)

    • Agent: new-issue-creator (new-issue-creator-code-b)
    • Session / ID: new-issue-creator-code-b · 2026-10-28 01:20 CDT run
    • Found via: filed this run
    • Task: Addendum to this issue, same decoder: decode_one's NESTED branch (tuple.rs:428-438) recurses with no depth limit — the nested: bool parameter carries no depth, and there is no counter anywhere in decode/decode_one. A crafted key of N repeats of the 0x05 nested tag (plus terminators) recurses N deep and overflows the stack (a process abort, not a catchable error) in anything that decodes stored keys, e.g. tags.rs decode_alpha_key/decode_omega_key. Contrast chain.rs:39,350: CBOR decoding of received events sets RECURSION_LIMIT: 64 for exactly this reason. Suggested addition to the fix scope: thread a depth limit through decode_one (a small constant in the spirit of chain's 64) and refuse deeper nesting with an error; add a test with a deeply-nested payload.
    • Expectation: effort/s — folds into the same triage/fix as the int/float canonicality items; no separate issue filed (same decoder, same hardening change).
    • Links: id(tuple): decode accepts negative ints that wrap to zero/positive and NaN floats — the negative branch has no range check, unlike the positive branch #1610
  5. github-actions
    assigned
    dezren39
    on Oct 28, 2026
  6. dezren39
    added
    queue/claimedQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Oct 28, 2026
  7. 56 remaining items

  8. dezren39
    added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 28, 2026
  9. dezren39
    added a commit that references this issue on Oct 28, 2026

    fix(id/tuple): decode range-checks negative ints, rejects NaN and non…

    76c3135
  10. dezren39
    closed this as completedin #1746on Oct 28, 2026
  11. dezren39 commented on Oct 28, 2026

    @dezren39
    dezren39
    on Oct 28, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane D shift
    • Session / ID: queue task 1851 (small_fix, resume)
    • Found via: queue claim
    • Task: Resumed from awaiting_ci: PR fix(id/tuple): decode range-checks negative ints, rejects NaN and non-minimal ints (#1610) #1746 CI verified fresh — all checks SUCCESS except neutral CodeRabbit. Diff reviewed against triage task 1711 ruling: negative-int magnitude range check (1..=2^63, i64::MIN stays decodable), NaN rejected on FLOAT64 decode, non-minimal int encodings pinned to reject with tests, no encoder change. Merged PR fix(id/tuple): decode range-checks negative ints, rejects NaN and non-minimal ints (#1610) #1746 (squash) at 2026-10-28T22:02:00Z, merge sha 76c3135. Closing this issue as fixed.
    • Links: PR fix(id/tuple): decode range-checks negative ints, rejects NaN and non-minimal ints (#1610) #1746
  12. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Oct 28, 2026
  13. dezren39
    added a commit that references this issue on Nov 10, 2026

    fix(id): reject non-canonical -0.0 tuple FLOAT64 keys (#2421)

    cbdb737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.