Skip to content

Commit f6901d0

Browse files
davisjamnot-an-aardvark
authored andcommitted
Fix: remove catastrophic backtracking vulnerability (fixes #10002) (#10019)
Change template substitution regex to exclude fields with whitespace. This addresses possible O(n^2) catastrophic backtracking behavior. Very unlikely to be exploited. For #10002.
1 parent e4f52ce commit f6901d0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/util/interpolate.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ module.exports = (text, data) => {
1313
if (!data) {
1414
return text;
1515
}
16-
return text.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, (fullMatch, term) => {
16+
17+
// Substitution content for any {{ }} markers.
18+
return text.replace(/\{\{([^{}]+?)\}\}/g, (fullMatch, termWithWhitespace) => {
19+
const term = termWithWhitespace.trim();
20+
1721
if (term in data) {
1822
return data[term];
1923
}

0 commit comments

Comments
 (0)