Skip to content

Bound All Work Triggered by a Single Token Selection Request [HIGH] #1641

Description

@HayimShaul

Description
Conduct an architectural review of every code path reachable from a Selector.Select call -- token iteration depth, number of lock attempts, retry and back-off cycles, and lock-store growth -- and impose hard, configurable upper bounds on each dimension. Any request that would exceed these limits must be aborted early and all acquired locks released immediately. This is the primary defence against algorithmic attacks: no matter how a request is crafted (adversarial OwnerFilter, extreme quantity, or high concurrency), the system must shed load and return an error rather than consuming unbounded memory, CPU, storage, or wall-clock time.

Short Summary
An attacker can create a transaction that selects a large amount of tokens from database. This can exhaust the CPU and memory of the view service.

Activity

  1. added this to the Q2/26 milestone on May 3, 2026
  2. SurbhiAgarwal1 commented on May 4, 2026

    @SurbhiAgarwal1
    Contributor

    Hi @HayimShaul , @adecaro , I’d like to propose a structured approach to bound all work triggered by a Selector.Select request and prevent unbounded resource consumption.


    1. Introduce a Selection Budget (Core Idea)

    Define a per-request SelectionBudget that tracks and enforces limits across all dimensions:

    • maxTokensScanned
    • maxLockAttempts
    • maxRetries
    • maxDuration (wall-clock timeout)
    • maxLocksHeld

    This budget is initialized at the start of Selector.Select and passed through all downstream calls.

    type SelectionBudget struct {
        MaxTokensScanned int
        MaxLockAttempts  int
        MaxRetries       int
        MaxLocksHeld     int
        Deadline         time.Time
    }
    Can you assign me this issue ?
  3. self-assigned this
    on May 12, 2026
  4. modified the milestones: Q2/26, Q3/26 on Jun 2, 2026
  5. self-assigned this
    on Sep 23, 2026
  6. modified the milestones: Q3/26, Q4/26 on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions