Skip to content

fix: bound queries, error bodies, and non-HTTP result URLs - #34

Merged
undivisible merged 1 commit into
mainfrom
fix/query-url-error-bounds
Sep 16, 2026
Merged

undivisible merged 1 commit into
mainfrom
fix/query-url-error-bounds

Conversation

@undivisible

@undivisible undivisible commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Focused hardening that does not redo Jules cache-key (#29), info-disclosure (#6), or abstract_text clone (#28) work:

  • SearchQuery / WebsurfxQuery reject empty, oversized (>512 chars), and page-0 inputs before any HTTP call.
  • Remote HTTP error bodies are truncated to 8 KiB (UTF-8 safe).
  • Embedded and remote results keep only http/https URLs (javascript:, file: dropped).
  • OpenAlex abstract_inverted_index expansion 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::search and search_websurfx now reject queries over 512 characters (Error::QueryTooLong) and treat page 0 as invalid on the Websurfx path, matching existing SearchQuery behavior—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 returns None for non-http/https URLs (e.g. javascript:, file:). Remote SearxNG and Websurfx responses pass through retain_http_results, which drops bad URLs, sets filters.filtered, and refreshes sources/counts when anything is removed.

OpenAlex DoS guard: abstract_inverted_index expansion 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.

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-ai

capy-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown

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.

Open in Capy

@cursor

cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@undivisible
undivisible merged commit b387553 into main Sep 16, 2026
2 checks passed
@undivisible
undivisible deleted the fix/query-url-error-bounds branch September 16, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants