From 9ea275fb1fddf2ecea26167aa29cbf76814eaf4c Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Wed, 2 Dec 2026 16:57:51 +0100 Subject: [PATCH] fix(site): resolve CodeQL ReDoS and incomplete escaping alerts (#5369) * fix(scripts): remove ambiguous regex in co-author parsing (ReDoS) The co-author trailer regex used \s+([^<]+)\s+< where both \s+ overlap with [^<]+, giving polynomial backtracking on long whitespace runs. \s([^<]+)\s< matches exactly the same strings and the same email group. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G9u8FhTjfkTLPkCeVkHN6p * fix: escape all occurrences when sanitizing strings - base64SVG: replace every newline, not just the first one - createOGImage: escape & before < and > so tags aren't double-escaped Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G9u8FhTjfkTLPkCeVkHN6p --------- Co-authored-by: Claude --- docs/.vitepress/createOGImage.ts | 2 +- scripts/updateContributors.mts | 2 +- tools/build-icons/utils/base64SVG.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/.vitepress/createOGImage.ts b/docs/.vitepress/createOGImage.ts index 84098314c..c42a24053 100644 --- a/docs/.vitepress/createOGImage.ts +++ b/docs/.vitepress/createOGImage.ts @@ -57,7 +57,7 @@ export async function createIconOGImage(iconName: string, tags: string[]) { const data = { name: iconName, - tags: tags.join(' • ').replace(//g, '>').replace(/&/g, '&'), + tags: tags.join(' • ').replace(/&/g, '&').replace(//g, '>'), iconSVG, }; diff --git a/scripts/updateContributors.mts b/scripts/updateContributors.mts index 9e8e7a623..d8c91694b 100644 --- a/scripts/updateContributors.mts +++ b/scripts/updateContributors.mts @@ -57,7 +57,7 @@ const getContributors = async (file: string, includeCoAuthors?: boolean) => { } if (includeCoAuthors) { const matches = commit.body.matchAll( - /(^Author:|^Co-authored-by:)\s+(?[^<]+)\s+<(?[^>]+)>/gm, + /(^Author:|^Co-authored-by:)\s(?[^<]+)\s<(?[^>]+)>/gm, ); for (const match of matches) { diff --git a/tools/build-icons/utils/base64SVG.ts b/tools/build-icons/utils/base64SVG.ts index b4a833c7d..abd32f75e 100644 --- a/tools/build-icons/utils/base64SVG.ts +++ b/tools/build-icons/utils/base64SVG.ts @@ -1,7 +1,7 @@ const base64SVG = (svgContents: string) => Buffer.from( svgContents - .replace('\n', '') + .replaceAll('\n', '') .replace( 'stroke="currentColor"', 'stroke="#000" style="background-color: #fff; border-radius: 2px"',