bug: GlobalReader.ReadFrom panics with fromSequence > MaxInt64 — both pgstore and sqlitestore #153

Closed
opened 2026-03-01 12:24:10 +00:00 by ash · 0 comments
Owner

Bug

Found by red team testing. ReadFrom(ctx, math.MaxUint64, limit) panics with pgx encoding error.

The API accepts uint64 for fromSequence but Postgres BIGSERIAL is int64 (max 9.2×10¹⁸). Any fromSequence > MaxInt64 causes a panic.

Fix

Add bounds check at the top of ReadFrom in both pgstore and sqlitestore:

if fromSequence > math.MaxInt64 {
    return nil, nil // no events can exist past MaxInt64
}

Also add to LatestSequence return type documentation that the practical max is MaxInt64.

Priority

Medium — unlikely in practice (9.2 quintillion events) but the API should not panic on valid uint64 input.

## Bug Found by red team testing. `ReadFrom(ctx, math.MaxUint64, limit)` panics with pgx encoding error. The API accepts `uint64` for `fromSequence` but Postgres BIGSERIAL is `int64` (max 9.2×10¹⁸). Any `fromSequence > MaxInt64` causes a panic. ## Fix Add bounds check at the top of ReadFrom in both pgstore and sqlitestore: ```go if fromSequence > math.MaxInt64 { return nil, nil // no events can exist past MaxInt64 } ``` Also add to LatestSequence return type documentation that the practical max is MaxInt64. ## Priority Medium — unlikely in practice (9.2 quintillion events) but the API should not panic on valid uint64 input.
ash changed title from bug: GlobalReader.ReadFrom panics with fromSequence > MaxInt64 to bug: GlobalReader.ReadFrom panics with fromSequence > MaxInt64 — both pgstore and sqlitestore 2026-03-01 12:35:28 +00:00
ash closed this issue 2026-03-01 12:40:07 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#153
No description provided.