Open
Conversation
Co-authored-by: naohanpen <88918376+naohanpen@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] 申請のファイル拡張子の正規表現をエスケープするか、お知らせを出す
Fix file extension regex injection vulnerability and add warning for special characters
Aug 3, 2025
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Deploying sos25-client with
|
| Latest commit: |
d8de4ba
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://29457c4b.sos25-client.pages.dev |
| Branch Preview URL: | https://copilot-fix-668-2.sos25-client.pages.dev |
Contributor
|
@copilot メッセージを表示する画面が間違えています。 |
…back Co-authored-by: naohanpen <88918376+naohanpen@users.noreply.github.com>
Contributor
Author
メッセージの表示場所を変更しました。警告は Commit: 253fdca Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
Fix file extension regex injection vulnerability and add warning for special characters
Fix file extension regex injection vulnerability and move warning to form editor
Aug 3, 2025
Contributor
naohanpen
approved these changes
Aug 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This PR fixes a security vulnerability in file extension validation where special regex characters could cause unintended behavior or regex errors, and moves the warning message to the appropriate admin interface.
Problem
The file extension validation in
FilesField.tsxwas directly inserting user-provided extensions into a regex pattern without proper escaping:This caused several issues:
*would cause "Nothing to repeat" regex errors.*would match any file (severe security issue)+,?,^,$, etc.) could break validation logicSolution
Created comprehensive regex escaping utilities in
src/lib/textUtils.ts:escapeRegexCharacters(): Properly escapes all regex special charactershasRegexSpecialCharacters(): Detects potentially problematic characterscreateSafeExtensionRegex(): Creates secure regex patterns from extension arraysUpdated FilesField component to use safe regex creation.
Added comprehensive test coverage with 21 test cases covering all edge cases and security scenarios.
Moved warning message to FormFieldEditor.tsx - The warning for special characters now appears in the form builder interface where administrators configure extensions, rather than in the file upload component shown to users.
Security Impact
Before:
After:
UI Changes
The warning message now appears in the admin form editor interface when administrators configure file extensions with special characters:
The fix maintains backward compatibility while preventing regex injection attacks and providing helpful warnings to administrators in the appropriate interface.
Fixes #668.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.