security: clamp list_pages and get_ingest_log limits#109
Open
garagon wants to merge 1 commit intogarrytan:masterfrom
Open
security: clamp list_pages and get_ingest_log limits#109garagon wants to merge 1 commit intogarrytan:masterfrom
garagon wants to merge 1 commit intogarrytan:masterfrom
Conversation
list_pages and get_ingest_log pass caller-supplied limit values
directly to the engine without capping. An MCP caller with
{limit: 10000000} forces unbounded result sets. Apply the same
clampSearchLimit (max 100) already used by search/query operations.
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.
Summary
Several gbrain MCP operations accept a
limitparameter that controls how manyresults to return. The
searchandqueryoperations were already capped at 100 viaclampSearchLimit(fixed in v0.9.1). Two other operations were not:list_pages:(p.limit as number) || 50— no capget_ingest_log:(p.limit as number) || 20— no capThe problem: an MCP caller can pass
{limit: 10000000}and force the engine toreturn an unbounded result set, consuming memory on the server.
What the fix does
Both operations now use
clampSearchLimit(p.limit, defaultValue)— the same functionthat already caps
searchandquery. The ceiling isMAX_SEARCH_LIMIT = 100.Normal usage (limit under 100) is unaffected.
Changes
src/core/operations.tsclampSearchLimitfromengine.tslist_pageshandler:clampSearchLimit(p.limit, 50)get_ingest_loghandler:clampSearchLimit(p.limit, 20)Validation
bun test test/parity.test.ts— 10 pass (operation contract intact)bun test test/search-limit.test.ts— 11 pass (clamp logic verified)clampSearchLimit(10000000, 50)→ 100,clampSearchLimit(undefined, 50)→ 50