Skip to content

Commit 90281e6

Browse files
Copilotmrjf
andauthored
Limit regex quantifier in extractGroupNames to prevent ReDoS
Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/59ed5e8d-fa0e-441b-a183-ff544daaf104 Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent f41fa5d commit 90281e6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/stats/string_ops_extended.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ export function strExtractGroups(
209209
/** Parse named capture group names from a regex source string. */
210210
function extractGroupNames(re: RegExp): string[] {
211211
// Match named capture groups: (?<name>...)
212-
// Use matchAll for safety — it creates a fresh iterator with its own state.
213-
const matches = re.source.matchAll(/\(\?<([^>]+)>/g);
212+
// Limit group name length to 64 chars to avoid polynomial ReDoS.
213+
const matches = re.source.matchAll(/\(\?<([^>]{1,64})>/g);
214214
const names: string[] = [];
215215
for (const m of matches) {
216216
const name = m[1];

0 commit comments

Comments
 (0)