fix: bound queries, error bodies, and non-HTTP result URLs - #34
Merged
Merged
Conversation
Reject search queries longer than 512 characters before the network, truncate HTTP error bodies to 8 KiB, drop javascript:/file: result URLs from remote and embedded responses, and cap OpenAlex inverted-index expansion so a hostile academic payload cannot explode memory. Amp-Thread-ID: https://ampcode.com/threads/T-01a0a633-11d2-7529-ae4c-9572c04b5518 Co-authored-by: Max Carter <undivisible@vk.com>
|
Capy couldn't review this pull request because Max's workspace is out of credits, add credits or enable auto-reload to resume automatic reviews. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_00f1afad-db97-4055-a335-79f85225e6b0) |
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.
Focused hardening that does not redo Jules cache-key (#29), info-disclosure (#6), or
abstract_textclone (#28) work:SearchQuery/WebsurfxQueryreject empty, oversized (>512 chars), and page-0 inputs before any HTTP call.http/httpsURLs (javascript:,file:dropped).abstract_inverted_indexexpansion is capped (256 entries / 512 positions / 48 words).Local: 61 tests,
cargo fmt --check, Clippy-D warnings. Please review before merge — URL filtering changes response contents.Note
Medium Risk
URL filtering changes what clients see in results and counts; validation and truncation are low-risk but behavior changes warrant review for integrations that relied on non-HTTP URLs or long queries.
Overview
Hardens search input handling and result sanitization before and after provider calls.
Query limits:
SearchClient::searchandsearch_websurfxnow reject queries over 512 characters (Error::QueryTooLong) and treat page 0 as invalid on the Websurfx path, matching existingSearchQuerybehavior—all checked before any HTTP request.Safer errors: Non-success HTTP responses truncate error bodies to 8 KiB with UTF-8-safe boundaries so large upstream payloads are not echoed wholesale in
Error::HttpStatus.HTTP-only links: Embedded providers build results through
result(), which now returnsNonefor non-http/httpsURLs (e.g.javascript:,file:). Remote SearxNG and Websurfx responses pass throughretain_http_results, which drops bad URLs, setsfilters.filtered, and refreshes sources/counts when anything is removed.OpenAlex DoS guard:
abstract_inverted_indexexpansion is capped (256 entries / 512 positions / 48 words) so huge indexes cannot blow up CPU or memory.Reviewed by Cursor Bugbot for commit f5eedeb. Configure here.