Skip to content

Sanitize titles for Unicode security and duplicate prefix prevention - #14825

Merged
pelikhan merged 3 commits into
mainfrom
copilot/sanitize-title-handling
Feb 10, 2026
Merged

Sanitize titles for Unicode security and duplicate prefix prevention#14825
pelikhan merged 3 commits into
mainfrom
copilot/sanitize-title-handling

Conversation

CopilotAI commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Titles in safe output handlers were vulnerable to Unicode-based attacks (bidirectional overrides, zero-width characters, fullwidth ASCII) and agent-generated duplicate prefixes.

Changes

  • New module sanitize_title.cjs

    • sanitizeTitle(title, titlePrefix) - Applies Unicode hardening via hardenUnicodeText() and strips duplicate prefix occurrences (handles separators: :, -, |)
    • applyTitlePrefix(sanitizedTitle, titlePrefix) - Safely applies prefix after sanitization
  • Unicode security hardening

    • NFC normalization, zero-width removal (U+200B-D, FEFF), bidi override removal (U+202A-E, 2066-9), fullwidth→ASCII (U+FF01-5E)
  • Integration

    • create_issue.cjs, create_discussion.cjs, create_pull_request.cjs - Sanitize then apply prefix
    • update_issue.cjs, update_discussion.cjs, update_pull_request.cjs - Sanitize only (no prefix handling)

Example

// Before: Vulnerable to Unicode attacks and duplicate prefixestitle=titlePrefix+message.title;// After: Sanitized and deduplicatedtitle=sanitizeTitle(message.title,titlePrefix);// Hardens Unicode, removes dupestitle=applyTitlePrefix(title,titlePrefix);// Applies prefix safely

Prevents attacks like "[Agent]\u200B\u202A[Agent]\u202C Fix""[Agent] Fix" and ensures consistent, secure title handling across all entity types.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

CopilotAIand others added 2 commits February 10, 2026 19:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Add sanitization for issue and pull request titlesSanitize titles for Unicode security and duplicate prefix preventionFeb 10, 2026
CopilotAI requested a review from pelikhanFebruary 10, 2026 19:28
@pelikhan
pelikhan marked this pull request as ready for review February 10, 2026 19:34
CopilotAI review requested due to automatic review settings February 10, 2026 19:34

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces Unicode security hardening and duplicate prefix prevention for titles in issue, discussion, and pull request handlers. It addresses vulnerabilities to Unicode-based attacks (bidirectional overrides, zero-width characters, fullwidth ASCII) and prevents agents from generating duplicate title prefixes.

Changes:

  • New sanitize_title.cjs module with sanitizeTitle() and applyTitlePrefix() functions
  • Integration of title sanitization in all create handlers (issues, discussions, PRs)
  • Integration of title sanitization in all update handlers (issues, discussions, PRs)
  • Comprehensive test suite covering Unicode attacks, prefix deduplication, and edge cases

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
actions/setup/js/sanitize_title.cjsNew module implementing Unicode hardening via hardenUnicodeText() and smart prefix removal with separator handling
actions/setup/js/sanitize_title.test.cjsComprehensive test suite covering Unicode security, prefix deduplication, and integration scenarios
actions/setup/js/create_issue.cjsIntegrates two-step sanitization: sanitizeTitle() to harden and deduplicate, then applyTitlePrefix() to safely apply prefix
actions/setup/js/create_discussion.cjsSame two-step sanitization pattern as create_issue.cjs
actions/setup/js/create_pull_request.cjsSame two-step sanitization pattern as create_issue.cjs
actions/setup/js/update_issue.cjsApplies sanitizeTitle() without prefix parameter (updates don't need prefix handling)
actions/setup/js/update_discussion.cjsSame update-only sanitization pattern as update_issue.cjs
actions/setup/js/update_pull_request.cjsSame update-only sanitization pattern as update_issue.cjs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan
pelikhan merged commit 2fcef7a into mainFeb 10, 2026
165 checks passed
@pelikhan
pelikhan deleted the copilot/sanitize-title-handling branch February 10, 2026 19:40
Sign up for freeto 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.

3 participants

@pelikhan