Skip to content

[P1] [bug] BIGINT UNSIGNED > 2^53 silently corrupts via JS Number #410

Closed

Description

@EVWorth

[P1] [bug] BIGINT UNSIGNED > 2^53 silently corrupts via JS Number deserialization

Context

Rust SqlValue::UInt(u64) for BIGINT UNSIGNED deserializes through serde(untagged) to a JS number. JS Number is a 64-bit double; integers above Number.MAX_SAFE_INTEGER (2^53 - 1) lose precision.

Problem

Per docs/audits/results.md F17.

A users.id BIGINT UNSIGNED AUTO_INCREMENT past 2^53 (rare but possible on long-lived systems) shows the same number for two distinct IDs. Sorting breaks; UPDATE WHERE matches the wrong row; COUNT(*) is wrong. Same risk applies to signed BIGINT near 2^63.

Files

  • src/types/index.ts:85
  • src-tauri/crates/mas-core/src/models/query.rs:24-32
  • src-tauri/crates/mas-core/src/query/executor.rs:262-269

Repro (if applicable)

Static analysis only.

Expected

SELECT * FROM ids WHERE id = 9007199254740993 shows the exact value. Sorting crosses the 2^53 boundary correctly.

Proposed fix

Scope M. (a) Rust serializes Int(i64)/UInt(u64) as strings when above 2^53; TS SqlValue adds a bigint or string variant for large integers. OR (b) Use a tagged-enum on the wire (#[serde(tag = "type")]).

Acceptance

Values above 2^53 render exactly; sorting is monotonic.

Needs human verify

Yes

Labels: audit, area/results, severity/p1, kind/bug

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/results
    on Jul 31, 2026
  2. EVWorth commented on Aug 30, 2026

    @EVWorth
    OwnerAuthor

    Fixed by the BIGINT work in #502/#510. executor.rs now carries both signed and unsigned 64-bit integers as text so JSON.parse cannot truncate them:

    "BIGINT" => decode_or_text::<i64, _>(row, index, t, |v| SqlValue::String(v.to_string())),
    "BIGINT UNSIGNED" => decode_or_text::<u64, _>(row, index, t, |v| SqlValue::String(v.to_string())),

    The frontend uses ColumnMeta to know the value is still numeric.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/resultsauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions