Skip to content

Add timeouts or non-backtracking to reference extraction regexes #2887

Description

@Widthdom

Finding

Reference extraction contains many compiled regular expressions that run over source lines and language-specific type/reference expressions without explicit match timeouts or non-backtracking. This is separate from the already filed built-in symbol extraction regex issue.

Evidence

  • src/CodeIndex/Indexer/References/Support/LanguageReferenceExtractionSupport.cs defines many RegexOptions.Compiled | RegexOptions.CultureInvariant patterns.
  • src/CodeIndex/Indexer/References/Languages/PythonReferenceExtractor.cs:152 uses Regex.Replace without a timeout.
  • src/CodeIndex/Indexer/References/ReferenceExtractor.TypeReferences.cs:2558 calls regex.Replace(...) on prepared input.

Suggested fix

Audit reference extraction regexes, add bounded match timeouts or RegexOptions.NonBacktracking where compatible, and add adversarial long-line tests for representative languages.

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