public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/nodejs22] f44: Update bundled brace-expansion to version 2.1.6
@ 2026-10-15 10:05 Andrei Radchenko
0 siblings, 0 replies; only message in thread
From: Andrei Radchenko @ 2026-10-15 10:05 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/nodejs22
Branch : f44
Commit : b56d572ecbb7c2f170f8053eb400bb6fe0e82530
Author : Andrei Radchenko <aradchen@redhat.com>
Date : 2026-10-15T12:04:06+02:00
Stats : +472/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/nodejs22/c/b56d572ecbb7c2f170f8053eb400bb6fe0e82530?branch=f44
Log:
Update bundled brace-expansion to version 2.1.6
Single patch covering the full brace-expansion DoS fix chain on the 2.x
line (2.1.3 / 2.1.5 / 2.1.6). Resolves exponential-time, unbounded-array,
parseCommaParts and nested-recursion stack-exhaustion variants.
Related: rhbz#2494970
Related: rhbz#2511800
Related: rhbz#2550225
Related: rhbz#2550333
Related: rhbz#2548099
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---
diff --git a/0001-Update-brace-expansion-to-version-2.1.6.patch b/0001-Update-brace-expansion-to-version-2.1.6.patch
new file mode 100644
index 0000000..3202c1f
--- /dev/null
+++ b/0001-Update-brace-expansion-to-version-2.1.6.patch
@@ -0,0 +1,471 @@
+From d0ba62621ddc25435419afc81e862141ceb546f8 Mon Sep 17 00:00:00 2001
+From: Andrei Radchenko <aradchen@redhat.com>
+Date: Tue, 13 Oct 2026 14:12:18 +0200
+Subject: [PATCH] Update brace-expansion to version 2.1.6
+
+---
+ .../npm/node_modules/brace-expansion/index.js | 371 +++++++++++++-----
+ .../node_modules/brace-expansion/package.json | 2 +-
+ 2 files changed, 274 insertions(+), 99 deletions(-)
+
+diff --git a/deps/npm/node_modules/brace-expansion/index.js b/deps/npm/node_modules/brace-expansion/index.js
+index 254ca75d..7e754076 100644
+--- a/deps/npm/node_modules/brace-expansion/index.js
++++ b/deps/npm/node_modules/brace-expansion/index.js
+@@ -8,6 +8,30 @@ var escClose = '\0CLOSE'+Math.random()+'\0';
+ var escComma = '\0COMMA'+Math.random()+'\0';
+ var escPeriod = '\0PERIOD'+Math.random()+'\0';
+
++var EXPANSION_MAX = 100000
++
++// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
++// input like `'{a,b}'.repeat(1500)` stays under that count - its output is
++// truncated to 100k results - while making every result ~1500 characters
++// long. The result set, and the intermediate arrays built while combining
++// brace sets, then grow large enough to exhaust memory and crash the process
++// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
++// characters the accumulator may hold at any point, so memory stays flat no
++// matter how many brace groups are chained. The limit sits well above any
++// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
++// characters) so legitimate input is unaffected.
++var EXPANSION_MAX_LENGTH = 4000000
++
++// `expand` recurses once per level of brace *nesting* - both when expanding a
++// set's comma members and when re-wrapping a set whose body is a single part.
++// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
++// level per chained group), which left nesting depth unbounded: about 3,100
++// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
++// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
++// will follow nesting. It sits far above any realistic pattern and well below
++// the depth at which the stack runs out.
++var EXPANSION_MAX_DEPTH = 1000
++
+ function numeric(str) {
+ return parseInt(str, 10) == str
+ ? parseInt(str, 10)
+@@ -31,40 +55,65 @@ function unescapeBraces(str) {
+ }
+
+
++// Like `target.push(...items)` but doesn't overflow the stack
++function pushAll(target, items) {
++ for (var i = 0; i < items.length; i++) {
++ target.push(items[i]);
++ }
++}
++
+ // Basically just str.split(","), but handling cases
+ // where we have nested braced sections, which should be
+ // treated as individual members, like {a,{b,c},d}
+ function parseCommaParts(str) {
+- if (!str)
+- return [''];
+-
+ var parts = [];
+- var m = balanced('{', '}', str);
+
+- if (!m)
+- return str.split(',');
++ // Walk the brace groups iteratively. Recursing on `post` once per group let a
++ // chain of them exhaust the stack - the parsing-side counterpart to
++ // the `expand` overflow fixed for CVE-2026-14257, and not something `max` or
++ // `maxLength` can bound, since it happens before expansion.
++ //
++ // The part the next chunk continues
++ var carry = '';
+
+- var pre = m.pre;
+- var body = m.body;
+- var post = m.post;
+- var p = pre.split(',');
++ for (;;) {
++ var m = balanced('{', '}', str);
+
+- p[p.length-1] += '{' + body + '}';
+- var postParts = parseCommaParts(post);
+- if (post.length) {
+- p[p.length-1] += postParts.shift();
+- p.push.apply(p, postParts);
+- }
++ if (!m) {
++ var tail = str.split(',');
++ tail[0] = carry + tail[0];
++ pushAll(parts, tail);
++ return parts;
++ }
+
+- parts.push.apply(parts, p);
++ var pre = m.pre;
++ var body = m.body;
++ var post = m.post;
++ var p = pre.split(',');
++
++ p[0] = carry + p[0];
++ p[p.length-1] += '{' + body + '}';
++
++ if (!post.length) {
++ pushAll(parts, p);
++ return parts;
++ }
+
+- return parts;
++ carry = p.pop();
++ pushAll(parts, p);
++ str = post;
++ }
+ }
+
+-function expandTop(str) {
++function expandTop(str, options) {
+ if (!str)
+ return [];
+
++ options = options || {};
++ var max = options.max == null ? EXPANSION_MAX : options.max;
++ var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
++ var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
++
+ // I don't know why Bash 4.3 does this, but it does.
+ // Anything starting with {} will have the first two bytes preserved
+ // but *only* at the top level, so {},a}b will not expand to anything,
+@@ -75,7 +124,7 @@ function expandTop(str) {
+ str = '\\{\\}' + str.substr(2);
+ }
+
+- return expand(escapeBraces(str), true).map(unescapeBraces);
++ return expand(escapeBraces(str), max, maxLength, maxDepth, 0, true).map(unescapeBraces);
+ }
+
+ function embrace(str) {
+@@ -92,24 +141,153 @@ function gte(i, y) {
+ return i >= y;
+ }
+
+-function expand(str, isTop) {
+- var expansions = [];
++// Build `{ acc[a] + pre + values[v] }` for every combination, capping the
++// number of results at `max` and the total number of characters at `maxLength`.
++// This is the one place output grows, so bounding it here keeps the single
++// accumulator - and therefore memory - flat regardless of how many brace groups
++// are combined (CVE-2026-14257).
++function combine(
++ acc,
++ pre,
++ values,
++ max,
++ maxLength,
++ dropEmpties
++) {
++ var out = []
++ var length = 0
++ for (var a = 0; a < acc.length; a++) {
++ for (var v = 0; v < values.length; v++) {
++ if (out.length >= max) return out
++ var expansion = acc[a] + pre + values[v]
++ // Bash drops empty results at the top level. Skip them before they count
++ // against `max`, so `max` bounds the number of *kept* results.
++ if (dropEmpties && !expansion) continue
++ if (length + expansion.length > maxLength) return out
++ out.push(expansion)
++ length += expansion.length
++ }
++ }
++ return out
++}
++
++// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
++// sequence body.
++function expandSequence(
++ body,
++ isAlphaSequence,
++ max,
++ maxLength
++) {
++ var n = body.split(/\.\./)
++ var N = []
++ // A sequence body always splits into two or three parts, but the compiler
++ // can't know that.
++ /* c8 ignore start */
++ if (n[0] === undefined || n[1] === undefined) {
++ return N
++ }
++ /* c8 ignore stop */
++ var x = numeric(n[0])
++ var y = numeric(n[1])
++ var width = Math.max(n[0].length, n[1].length)
++ var incr =
++ n.length === 3 && n[2] !== undefined ?
++ Math.max(Math.abs(numeric(n[2])), 1)
++ : 1
++ var test = lte
++ var reverse = y < x
++ if (reverse) {
++ incr *= -1
++ test = gte
++ }
++ var pad = n.some(isPadded)
++
++ var length = 0
++ for (var i = x; test(i, y) && N.length < max; i += incr) {
++ var c
++ if (isAlphaSequence) {
++ c = String.fromCharCode(i)
++ if (c === '\\') {
++ c = ''
++ }
++ } else {
++ c = String(i)
++ if (pad) {
++ var need = width - c.length
++ if (need > 0) {
++ var z = new Array(need + 1).join('0')
++ if (i < 0) {
++ c = '-' + z + c.slice(1)
++ } else {
++ c = z + c
++ }
++ }
++ }
++ }
++ if (length + c.length > maxLength) break
++ N.push(c)
++ length += c.length
++ }
++ return N
++}
++
++function expand(
++ str,
++ max,
++ maxLength,
++ maxDepth,
++ depth,
++ isTop
++) {
++ // Too deeply nested to keep following: treat the rest as literal, the same
++ // way a group that cannot expand is already handled. Truncating rather than
++ // throwing keeps expansion total, matching `max` and `maxLength`.
++ if (depth > maxDepth) {
++ return [str];
++ }
+
+- var m = balanced('{', '}', str);
+- if (!m) return [str];
++ // Consume the string's top-level brace groups left to right, threading a
++ // running set of combined prefixes (`acc`). Expanding the tail iteratively -
++ // rather than recursing on `m.post` once per group - keeps the native stack
++ // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
++ // longer overflow the stack, and leaves a single accumulator whose size
++ // `maxLength` bounds directly (CVE-2026-14257).
++ var acc = ['']
+
+- // no need to expand pre, since it is guaranteed to be free of brace-sets
+- var pre = m.pre;
+- var post = m.post.length
+- ? expand(m.post, false)
+- : [''];
++ // Bash drops empty results, but only when the *first* top-level group is a
++ // comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
++ // is on the final strings, so it is applied to whichever `combine` produces
++ // them (the one with no brace set left in the tail).
++ var dropEmpties = false
++ var firstGroup = true
+
+- if (/\$$/.test(m.pre)) {
+- for (var k = 0; k < post.length; k++) {
+- var expansion = pre+ '{' + m.body + '}' + post[k];
+- expansions.push(expansion);
++ for (;;) {
++ const m = balanced('{', '}', str)
++
++ // No brace set left: the rest of the string is literal.
++ if (!m) {
++ return combine(acc, str, [''], max, maxLength, dropEmpties)
++ }
++
++ // no need to expand pre, since it is guaranteed to be free of brace-sets
++ const pre = m.pre
++
++ if (/\$$/.test(pre)) {
++ acc = combine(
++ acc,
++ pre + '{' + m.body + '}',
++ [''],
++ max,
++ maxLength,
++ dropEmpties && !m.post.length
++ )
++ firstGroup = false
++ if (!m.post.length) break
++ str = m.post
++ continue
+ }
+- } else {
++
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
+ var isSequence = isNumericSequence || isAlphaSequence;
+@@ -118,86 +296,83 @@ function expand(str, isTop) {
+ // {a},b}
+ if (m.post.match(/,(?!,).*\}/)) {
+ str = m.pre + '{' + m.body + escClose + m.post;
+- return expand(str);
++ isTop = true;
++ continue;
+ }
+- return [str];
++ // Nothing here expands, so the whole remaining string is literal.
++ return combine(
++ acc,
++ pre + '{' + m.body + '}' + m.post,
++ [''],
++ max,
++ maxLength,
++ dropEmpties
++ )
+ }
+
+- var n;
++ if (firstGroup) {
++ dropEmpties = isTop && !isSequence
++ firstGroup = false
++ }
++
++ var values;
+ if (isSequence) {
+- n = m.body.split(/\.\./);
++ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
+ } else {
+- n = parseCommaParts(m.body);
+- if (n.length === 1) {
++ var n = parseCommaParts(m.body);
++ if (n.length === 1 && n[0] !== undefined) {
+ // x{{a,b}}y ==> x{a}y x{b}y
+- n = expand(n[0], false).map(embrace);
++ n = expand(n[0], max, maxLength, maxDepth, depth + 1, false).map(embrace);
++ //XXX is this necessary? Can't seem to hit it in tests.
++ /* c8 ignore start */
+ if (n.length === 1) {
+- return post.map(function(p) {
+- return m.pre + n[0] + p;
+- });
++ acc = combine(
++ acc,
++ pre + n[0],
++ [''],
++ max,
++ maxLength,
++ dropEmpties && !m.post.length
++ )
++ if (!m.post.length) break
++ str = m.post
++ continue
+ }
++ /* c8 ignore stop */
+ }
+- }
+-
+- // at this point, n is the parts, and we know it's not a comma set
+- // with a single entry.
+- var N;
+
+- if (isSequence) {
+- var x = numeric(n[0]);
+- var y = numeric(n[1]);
+- var width = Math.max(n[0].length, n[1].length)
+- var incr = n.length == 3
+- ? Math.abs(numeric(n[2]))
+- : 1;
+- var test = lte;
+- var reverse = y < x;
+- if (reverse) {
+- incr *= -1;
+- test = gte;
+- }
+- var pad = n.some(isPadded);
+-
+- N = [];
+-
+- for (var i = x; test(i, y); i += incr) {
+- var c;
+- if (isAlphaSequence) {
+- c = String.fromCharCode(i);
+- if (c === '\\')
+- c = '';
+- } else {
+- c = String(i);
+- if (pad) {
+- var need = width - c.length;
+- if (need > 0) {
+- var z = new Array(need + 1).join('0');
+- if (i < 0)
+- c = '-' + z + c.slice(1);
+- else
+- c = z + c;
+- }
+- }
++ // Values that `combine` is going to drop as empty produce no result, so
++ // they must not count against `max` - otherwise `{a,,b}` with `max: 2`
++ // would stop at `['a', '']` and yield one result instead of two. Skipping
++ // them outright keeps `values` bounded while leaving `max` a bound on
++ // *kept* results.
++ var dropsEmpties = dropEmpties && !m.post.length && !pre
++ for (var d = 0; dropsEmpties && d < acc.length; d++) {
++ if (acc[d]) {
++ dropsEmpties = false
+ }
+- N.push(c);
+ }
+- } else {
+- N = [];
+
+- for (var j = 0; j < n.length; j++) {
+- N.push.apply(N, expand(n[j], false));
++ values = []
++ var valuesLength = 0
++ outer: for (var j = 0; j < n.length; j++) {
++ var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, false)
++ for (var k = 0; k < expanded.length; k++) {
++ var v = expanded[k]
++ if (dropsEmpties && !v) continue
++ if (values.length >= max || valuesLength + v.length > maxLength) {
++ break outer
++ }
++ values.push(v)
++ valuesLength += v.length
++ }
+ }
+ }
+
+- for (var j = 0; j < N.length; j++) {
+- for (var k = 0; k < post.length; k++) {
+- var expansion = pre + N[j] + post[k];
+- if (!isTop || isSequence || expansion)
+- expansions.push(expansion);
+- }
+- }
++ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length)
++ if (!m.post.length) break
++ str = m.post
+ }
+
+- return expansions;
++ return acc
+ }
+-
+diff --git a/deps/npm/node_modules/brace-expansion/package.json b/deps/npm/node_modules/brace-expansion/package.json
+index c7eee345..21c6faa2 100644
+--- a/deps/npm/node_modules/brace-expansion/package.json
++++ b/deps/npm/node_modules/brace-expansion/package.json
+@@ -1,7 +1,7 @@
+ {
+ "name": "brace-expansion",
+ "description": "Brace expansion as known from sh/bash",
+- "version": "2.0.2",
++ "version": "2.1.6",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/juliangruber/brace-expansion.git"
+--
+2.55.0
+
diff --git a/nodejs22.spec b/nodejs22.spec
index af2a1b5..0714139 100644
--- a/nodejs22.spec
+++ b/nodejs22.spec
@@ -166,6 +166,7 @@ Source101: nodejs.srpm.macros
0001-Remove-unused-OpenSSL-config.patch
0001-fips-disable-options.patch
0002-CVE-2026-42338-ip-address-security-fix.patch
+0001-Update-brace-expansion-to-version-2.1.6.patch
%description
Node.js is a platform built on Chrome's JavaScript runtime
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-15 10:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 10:05 [rpms/nodejs22] f44: Update bundled brace-expansion to version 2.1.6 Andrei Radchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox