Skip to content

Commit

Permalink
Fix: remove catastrophic backtracking vulnerability
Browse files Browse the repository at this point in the history
Change template substitution regex to exclude fields with whitespace.
This addresses possible O(n^2) catastrophic backtracking behavior.

Very unlikely to be exploited. For eslint#10002.
  • Loading branch information
davisjam committed Feb 24, 2018
1 parent 558ccba commit 58ad0af
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/util/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ module.exports = (text, data) => {
if (!data) {
return text;
}
return text.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, (fullMatch, term) => {

// Substitution content for any {{ }} markers.
return text.replace(/\{\{([^{}]+?)\}\}/g, (fullMatch, termWithWhitespace) => {
const term = termWithWhitespace.trim();

if (term in data) {
return data[term];
}
Expand Down

0 comments on commit 58ad0af

Please sign in to comment.