Skip to content

ScrubInlineCode regex does not handle nested backticks or escaped content #2006

Description

@Widthdom

Summary

The regex pattern @"[^]+"at line 210 in GitHubIssueReporter.cs uses a naive non-greedy negated character class that fails on nested backticks, escaped backticks in template literals, or code containing backticks as values (e.g., markdown examples withconst x = `template`` strings). This leaves code-like content in submitted GitHub issues when backticks appear inside the matched span.

Where

  • src/CodeIndex/Cli/GitHubIssueReporter.cs:208-211
  • tests/CodeIndex.Tests/GitHubIssueReporterTests.cs:89-103 (no test for nested/escaped backticks)

Suggested approach

  1. Add unit tests that verify ScrubInlineCode correctly handles: escaped backticks, nested templates, backticks as code values
  2. Define what "correct" scrubbing means — is it safe to preserve outer backticks if inner content is stripped?
  3. Audit the description text for other code block patterns that bypass the single-backtick regex (triple-backtick blocks, HTML tags)
  4. Consider switching to a more defensive regex or a multi-pass sanitization that handles multiple escaping layers
  5. Document the scrubbing policy explicitly: what survives, what gets replaced, and why
  6. Add regression tests to prevent re-introduction of this vulnerability in future refactors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions