Skip to content

fix: Limit explore search query length to keep TUI responsive#18251

Merged
fdncred merged 2 commits into
nushell:mainfrom
orbisai0security:fix-v003-search-input-length-limit
May 20, 2026
Merged

fix: Limit explore search query length to keep TUI responsive#18251
fdncred merged 2 commits into
nushell:mainfrom
orbisai0security:fix-v003-search-input-length-limit

Conversation

@orbisai0security
Copy link
Copy Markdown
Contributor

@orbisai0security orbisai0security commented May 20, 2026

Summary

This adds a small upper bound to the interactive explore search query.

The search filter is re-applied on each typed character, so extremely long search input can cause unnecessary repeated work and make the TUI feel sluggish. This caps the query length at 256 characters as a defensive responsiveness guard.

This is not intended to change normal search behaviour; 256 characters should be well above typical interactive search usage.

Description: User keystrokes captured in tui.rs:112 via handle_search_input are passed directly to apply_search_filter() in app.rs:194 without confirmed input validation, length limits, or debouncing. If apply_search_filter() compiles user input as a regular expression (a common pattern in TUI search implementations), adversarial inputs containing catastrophic backtracking patterns (e.g., (a+)+ against a non-matching string) can cause the Rust regex engine to consume 100% CPU, freezing the TUI. This is a Regular Expression Denial of Service (ReDoS) vulnerability. Confidence is medium because the code structure confirms the unsanitized input flow, though the exact filter implementation requires verification.

Changes

  • crates/nu-explore/src/explore_config/input.rs

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 20, 2026

Can you place a comment above the line explaining why it's limiting a search to less than 256 chars?

Add comments to clarify interactive search input behavior.
@orbisai0security
Copy link
Copy Markdown
Contributor Author

Thanks, added a comment explaining the 256-character cap.

I’ve framed it as an interactive responsiveness guard rather than relying on a specific regex-engine failure mode: search filtering is applied on every keystroke, so bounding the query prevents pathological or accidental very-long inputs from making the TUI sluggish. Happy to adjust the wording or the limit if you prefer a different threshold.

@orbisai0security orbisai0security changed the title fix: user keystrokes captured in tui in tui.rs fix: Limit explore search query length to keep TUI responsive May 20, 2026
@fdncred fdncred merged commit 7d5535b into nushell:main May 20, 2026
17 checks passed
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 20, 2026

Thanks

@github-actions github-actions Bot added this to the v0.113.0 milestone May 20, 2026
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