Skip to content

Add timeouts or non-backtracking to built-in symbol extraction regexes #2876

Description

@Widthdom

Summary

Built-in symbol extraction regexes are compiled without explicit match timeouts or non-backtracking mode.

Evidence

src/CodeIndex/Indexer/Symbols/SymbolExtractor.cs defines many built-in new Regex(..., RegexOptions.Compiled) patterns. Workspace pattern regexes are tracked separately, but these built-in extractors still appear to run without a timeout/non-backtracking guarantee.

Impact

Even with per-file size limits, long or minified lines can turn regex extraction into excessive CPU use. This is a robustness and denial-of-service risk for untrusted repositories.

Suggested fix

Give built-in regexes explicit timeouts, convert safe patterns to RegexOptions.NonBacktracking where compatible, and add regression tests around adversarial long-line inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions