Skip to content

prototype(gate_store): reject float overflow, out-of-range integers, empty identifiers, and invalid RemoteGateStore timeout #645

Open

Description

@drk-ram

What is wrong

On main at b938790, prototype/gate_store.py has four input-validation gaps across the wire protocol and client/server boundaries:

  1. Float exponent overflow in _recv: _recv passes parse_constant=_no_constants to json.loads to reject literal NaN/Infinity, but omits parse_float, so overflowed float literals such as 1e309 or -1e309 parse to inf/-inf without raising ValueError.
  2. Uncaught OverflowError on 64-bit integer overflow in _int / _Handler.handle: _int accepts any Python int, including negative values or values >= 2**63 (or > 9007199254740991). When passed to SQLite in mint_challenge, sqlite3 raises built-in OverflowError (Python int too large to convert to SQLite INTEGER), which is neither a (KeyError, TypeError, ValueError) nor a sqlite3.Error, so _Handler.handle fails to catch it and drops the connection instead of returning {"error": "malformed"}.
  3. Empty string identifiers and unvalidated nonce format in _str / _dispatch: _str accepts "" for issuer, token_id, session_id, and call_id, and _dispatch accepts non-hex or wrong-length nonce values instead of requiring 32 lowercase hex characters ([0-9a-f]{32}).
  4. Unvalidated timeout in RemoteGateStore.__init__: RemoteGateStore accepts timeout=False, timeout=0, timeout=-1.0, or timeout=float("nan") at construction time instead of raising ValueError.

Spec section or file

prototype/gate_store.py (_recv, _str, _int, _dispatch, RemoteGateStore.__init__)

Expected behavior

  • _recv rejects non-finite parse_float values with ValueError.
  • _int enforces 0 <= value <= v._MAX_INT (9007199254740991), raising ValueError on negative or oversized integers so _Handler.handle returns {"error": "malformed"}.
  • _str rejects empty strings "", and _nonce requires [0-9a-f]{32}.
  • RemoteGateStore.__init__ validates that timeout is a positive finite int or float (excluding bool).

Impact

Prevents unhandled OverflowError crashes in GateStoreServer, non-finite float smuggling over the wire protocol, empty identifier rows in SQLite state, and invalid socket timeouts in RemoteGateStore.

Activity

  1. github-actions commented on Oct 30, 2026

    @github-actions
    Contributor

    🟡 Contributor Check: MEDIUM

    Check Result
    Profile MEDIUM
    Credential LOW
    Overall MEDIUM

    Automated check by AgenTrust Contributor Check.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions