fix(server): clamp list RPC page limit to prevent unbounded queries#140
Merged
johntmyers merged 1 commit intomainfrom Mar 6, 2026
Merged
fix(server): clamp list RPC page limit to prevent unbounded queries#140johntmyers merged 1 commit intomainfrom
johntmyers merged 1 commit intomainfrom
Conversation
Closes #26 All list RPCs (ListSandboxes, ListProviders, ListSandboxPolicies, ListInferenceRoutes) passed the client-provided limit directly to SQL queries with no upper bound. A client could send limit=u32::MAX and cause the server to load all records into memory, risking OOM. This introduces a MAX_PAGE_SIZE constant (1000) and a clamp_limit helper that caps the limit in every list handler before it reaches the persistence layer.
Closed
drew
pushed a commit
that referenced
this pull request
Mar 16, 2026
…140) Closes #26 All list RPCs (ListSandboxes, ListProviders, ListSandboxPolicies, ListInferenceRoutes) passed the client-provided limit directly to SQL queries with no upper bound. A client could send limit=u32::MAX and cause the server to load all records into memory, risking OOM. This introduces a MAX_PAGE_SIZE constant (1000) and a clamp_limit helper that caps the limit in every list handler before it reaches the persistence layer. Co-authored-by: John Myers <johntmyers@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #26
Summary
All list RPCs passed the client-provided
limitdirectly to SQL queries with no upper bound, allowing a single request to load an unbounded number of rows and cause memory exhaustion (DoS). This fix introduces aMAX_PAGE_SIZEconstant (1000) and aclamp_limithelper that caps the limit in every list handler before it reaches the persistence layer.Changes Made
crates/navigator-server/src/grpc.rs: AddedMAX_PAGE_SIZEconstant (1000) andclamp_limit(raw, default, max)helper function. Appliedclamp_limitinlist_sandboxes,list_providers, andlist_sandbox_policieshandlers. Added 3 unit tests forclamp_limit.crates/navigator-server/src/inference.rs: ImportedMAX_PAGE_SIZEandclamp_limitfromgrpcmodule. Appliedclamp_limitinlist_inference_routeshandler.Deviations from Plan
None — implemented as planned.
Tests Added
clamp_limit—clamp_limit_zero_returns_default,clamp_limit_within_range_passes_through,clamp_limit_exceeding_max_is_cappedsqlite_list_pagingtest covers store-level paging)Documentation Updated
Verification