Fix ReDoS in secret scanning regex patterns#15232
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot merge main, fix tests |
…rmat Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Merged main and fixed tests. All 38 tests passing now (commit 75b6343). The merge included two security fixes from main that changed redaction behavior:
Updated test assertions accordingly. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Regular Expression Denial of Service (ReDoS) vulnerability in the secret scanning regex patterns by adding bounded quantifiers to two patterns that previously used unbounded quantifiers. The changes also include merging recent security improvements from the main branch and updating test assertions to match the new redaction format.
Changes:
- Fixed ReDoS vulnerability in Azure SAS Token and Google OAuth Access Token regex patterns by replacing unbounded quantifiers (
+) with bounded quantifiers ({1,20},{1,200},{1,800}) - Updated test assertion on line 109 to use new
***REDACTED***format instead of prefix-preserving format - Added comprehensive ReDoS protection tests covering pathological inputs, timing verification, and validation that legitimate tokens still match
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| actions/setup/js/redact_secrets.cjs | Added bounded quantifiers to Azure SAS Token and Google OAuth Access Token regex patterns to prevent ReDoS attacks |
| actions/setup/js/redact_secrets.test.cjs | Updated test assertion for new redaction format and added 4 comprehensive ReDoS protection tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix ReDoS Vulnerability in Secret Scanning Regex Patterns ✅
Completed Tasks
***REDACTED***formatChanges Summary
1. Merged main branch
Integrated two security fixes from main:
abc***) to fixed-length (***REDACTED***)2. Fixed ReDoS Vulnerability (Original Changes)
Azure SAS Token pattern (line 58):
/\?sv=[0-9-]+&s[rts]=[\w\-]+&sig=[A-Za-z0-9%+/=]+/g/\?sv=[0-9-]{1,20}&s[rts]=[\w\-]{1,20}&sig=[A-Za-z0-9%+/=]{1,200}/gGoogle OAuth Access Token pattern (line 62):
/ya29\.[0-9A-Za-z_-]+/g/ya29\.[0-9A-Za-z_-]{1,800}/g3. Updated Test Assertions
Fixed test expectations to match new redaction format:
"abc***"→"***REDACTED***""ya2************"→"***REDACTED***"***REDACTED***formatTest Results
✅ All 38 tests pass (33 existing + 4 ReDoS protection + 1 new 6-char test)
✅ JavaScript formatting validated
✅ JavaScript linting validated
Security Impact
Combined with main's changes, this PR provides:
💡 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.