chore(deps): update dependency immutable to v4 [security]#2832
Open
renovate[bot] wants to merge 1 commit into
Open
chore(deps): update dependency immutable to v4 [security]#2832renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
3.8.3→4.3.9Immutable.js
List32-bit trie overflow → unrecoverable DoSCVE-2026-59879 / GHSA-v56q-mh7h-f735
More information
Details
Summary
List#set,List#setSize,List#setIn,List#updateIn(and the functionalset/setIn/updateIn) mishandle an index or size in the range[2 ** 30, 2 ** 31):Listthe operation enters an uncatchable infinite loop (a tight CPU spin; a surroundingtry/catchnever regains control). Only killing the worker recovers it.List(≥ 32 elements — i.e. any array of ≥ 32 items turned into aListbyfromJS) the loop allocates without bound → heap exhaustion → the process aborts (SIGABRT, exit134, or kernel OOM-kill137). A real crash, not a recoverable error.The index may be a numeric string, so it can come straight from a request body, URL, or key-path. A single small unauthenticated request is enough.
There is also a companion silent data-corruption issue in
setSize:Impact
Availability only. A reachable configuration is any endpoint that routes untrusted input into a
Listindex or asetIn/updateInkey-path — which the extremely commonstate = fromJS(body); state.setIn(userPath, value)pattern does (config stores, document/collection editors, redux-immutable reducers, JSON-Patch endpoints, etc.).No confidentiality or integrity impact, no RCE. The companion
setSizebug can silently corrupt application state (wrong size) without crashing.Reproduction (immutable 5.1.7)
A remote 43-byte HTTP request (
{"path":["items","1073741824"],"value":"x"}) is sufficient to abort a worker that applies it viastate = state.setIn(path, value).Any index in
[2 ** 30, 2 ** 31)works (1073741824,2000000000, …). An index in[2 ** 31, 2 ** 32)does not crash — it silently wraps (clearing the List) via the same root cause.Root cause
Liststores its values in a 32-wide trie (SHIFT = 5, so each level addresses 5 more bits) and uses signed 32-bit bitwise arithmetic throughoutsetListBounds()(src/List.js):relies on
1 << (newLevel + SHIFT). A JavaScript shift count is taken mod 32, so oncenewLevel + SHIFTreaches31the term goes negative (1 << 31 === -2147483648) and at32wraps to1(1 << 35 === 8). The comparison then staystrueforever and the loop never terminates. On a populatedList, each iteration retains a newVNode([newRoot]), so the heap fills and V8 aborts; on an emptyListit spins on CPU without allocating.setSizecorruption). Thebegin |= 0/end |= 0coercion (ToInt32) silently wraps large finite values ((2 ** 31) | 0 === -2147483648,(2 ** 32 + 5) | 0 === 5), producing a wrong resulting size instead of an error.The threshold is
2 ** 30: that is the largest size for which1 << (newLevel + SHIFT)stays a valid positive 32-bit integer throughout the loops (newLevel + SHIFTstays ≤ 30).Remediation
The fix is contained to
setListBounds()insrc/List.js:Validate up front, before the lossy
| 0coercion. Compute the intended origin and capacity in full precision and throw a clear, catchableRangeErrorwhen they exceed the addressable range (MAX_LIST_SIZE = 2 ** 30).Infinity/NaNare left to the existing| 0 → 0behaviour (sosetSize(Infinity)stays0andslice(0, Infinity)still means "to the end").Stop the shift from wrapping. Replace
1 << expin the level-raising loops with a helper that uses the cheap bitwise shift while it is exact (exp ≤ 30, the common path including everypush/setSize/slice) and falls back to the non-wrapping2 ** exponly for the rare deep trees reached when a negative origin (unshift/ negative index) is normalized to a large positive capacity (expcan reach 35 there, where1 << 35would wrap to 8).This turns every hang, the misleading
"Maximum call stack size exceeded", the OOM/SIGABRT, and the silentsetSizetruncation into one descriptiveRangeError, preserves all behaviour for sizes< 2 ** 30, and keeps the hotpushpath on the fast bitwise shift (the2 ** expbranch is never reached by non-negative operations).Is the new limit a breaking change?
No working code is affected. A
Listcould never actually hold≥ 2 ** 30values before — the attempt hung, crashed, or silently corrupted the size. The limit was already implicit in the 32-bit trie; the fix only makes it explicit and catchable, mirroring native JS arrays (new Array(2 ** 32)→RangeError: Invalid array length). The single observable behaviour change is thatsetSize(hugeValue), which used to return a silently wrong size, now throws.2 ** 30≈ 1.07 billion entries (~8 GB of pointers alone), far beyond any practical use.Mitigations (for users who cannot upgrade immediately)
Listindex orsetIn/updateInkey-path segment against a sane maximum before passing it to immutable.≥ 2 ** 30.--max-old-space-size) so an abort is contained.Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Immutabl: Hash-collision algorithmic complexity denial of service in Immutable.Map/Set
CVE-2026-59880 / GHSA-xvcm-6775-5m9r
More information
Details
Summary
Immutable.MapandImmutable.Setkeep keys that share the same 32-bit hash in a collision bucket that is scanned linearly. The string hash is public and deterministic, so an attacker who controls the keys inserted into a Map can craft many keys that all collide, degrading insertion and lookup from amortized O(1) to O(n) per operation — and O(n²) to build or read the whole set. A small, attacker-shaped payload can therefore consume disproportionate CPU and, on a single-threaded runtime such as Node.js, stall the event loop and deny service.Details
The string hash uses the JVM-style polynomial
hashed = (31 * hashed + charCode) | 0. Strings such as"Aa"and"BB"hash to the same value (65*31+97 == 66*31+66 == 2112), and concatenating such blocks yields2^ndistinct strings sharing one hash (40 characters ⇒ >1,000,000 colliding keys).All such keys route to a single
HashCollisionNode, whoseget/updatewalk the entire bucket testingis(). There is no per-process salt, so the colliding set is fully precomputable from the open-source algorithm.Proof of concept
Inserting N colliding keys (e.g. via
Immutable.Map(obj)/Immutable.fromJS(obj)) is O(N²). Measured on one machine, ~8,000 collidingkeys take ~0.7 s to build and ~0.6 s to read, scaling ×4 per doubling; ~16,000 keys exceed several seconds.
Impact
CPU-bound denial of service in applications that ingest attacker-controlled object keys into Immutable structures, e.g.
Immutable.Map(req.body),Immutable.fromJS(req.body),state.merge(userObject)/mergeDeep(...). Applications that only store attacker input as values under fixed keys are not affected.Affected versions
All versions through
5.1.7(the deterministic string hash and linear collision bucket have existed since the 4.x line).Patches
Fixed in
5.1.8(adjust to the actual release): large collision buckets are indexed by a per-process seeded secondary hash, restoring near-linear behavior for the affected paths. The publichash()is unchanged (no breaking change), andis()remains the sole authority on key equality.Workarounds
Before passing untrusted data to Immutable.js: cap request body size, limit object key count/length, and reject high-cardinality payloads; avoid building Maps directly from untrusted object keys.
References
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Release Notes
immutable-js/immutable-js (immutable)
v4.3.9Compare Source
v4.3.8Compare Source
Fix Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') in immutable
v4.3.7Compare Source
v4.3.6Compare Source
Repeat(<value>).equals(undefined)incorrectly returning true #1994 by @butchlerv4.3.5Compare Source
v4.3.4Compare Source
v4.3.3Compare Source
v4.3.2Compare Source
v4.3.1Compare Source
some#1944v4.3.0Compare Source
v4.2.4Compare Source
v4.2.3Compare Source
groupByreturn either aMapor anOrderedMap: make the type more precise than baseCollection#1924v4.2.2Compare Source
partitionmethod #1920 by Dagurv4.2.1Compare Source
toJSto avoir circular referencev4.2.0Compare Source
partitionmethod to all containers #1916 by johnw42v4.1.0Compare Source
v4.0.0Compare Source
This release brings new functionality and many fixes.
Key changes
mergeandmergeDeephas changedIterableis renamed to CollectionDiff of changed API (click to expand)
Note for users of v4.0.0-rc.12
There were mostly bugfixes and improvements since RC 12. Upgrading should be painless for most users.
However, there is one breaking change: The behavior of
mergeandmergeDeephas changed. See below for details.BREAKING
merge()
No longer use value-equality within
merge()(#1391)No longer deeply coerce argument to merge() (#1339)
mergeDeep()
Replace incompatible collections when merging nested data (#1840)
Concat Lists when merging deeply (#1344)
Seq
Remove IteratorSequence. Do not attempt to detect iterators in
Seq(). (#1589)Remove
Seq.of()(#1311, #1310)isImmutable()
isImmutable()now returns true for collections currently within awithMutations()call. (#1374)toArray()
KeyedCollection.toArray() returns array of tuples. (#1340)
concat()
list.concat()now has a slightly more efficient implementation andmap.concat()is an alias formap.merge(). (#1373)Collection, formerly
IterableIterableclass has been renamed toCollection, andisIterable()has been renamed toisCollection().Aliases with the existing names exist to make transitioning code easier.
Record
isCollection(myRecord)returnsfalseinstead oftrue.map,filter,forEach) no longer exist on Records.delete()andclear()no longer exist on Records.Other breaking changes
Potentially Breaking: Improve hash speed and avoid collision for common values (#1629)
Node buffers no longer considered value-equal (#1437)
Plain Objects and Arrays are no longer considered opaque values (#1369)
The "predicate" functions,
isCollection,isKeyed,isIndexed,isAssociativehave been moved fromIterable.to the top level exports.The
toJSON()method performs a shallow conversion (previously it was an alias fortoJS(), which remains a deep conversion).Some minor implementation details have changed, which may require updates to libraries which deeply integrate with Immutable.js's private APIs.
The Cursor API is officially deprecated. Use immutable-cursor instead.
Potentially Breaking: [TypeScript] Remove
Iterable<T>as tuple from Map constructor types (#1626)New
taking advantage of the latest features from both tools.
Add "sideEffects: false" to package.json (#1661)
Use ES standard for iterator method reuse (#1867)
Generalize
fromJS()andSeq()to support Sets (#1865)Top level predicate functions (#1600)
Improve performance of toJS (#1581)
Added optional
notSetValueinfirst()andlast()(#1556)Make
isArrayLikecheck more precise to avoid false positives (#1520)map()for List, Map, and Set returns itself for no-ops (#1455) (5726bd1)Hash functions as objects, allowing functions as values in collections (#1485)
Functional API for
get(),set(), and more which support both Immutable.js collections and plain Objects and Arrays (#1369)Relicensed as MIT (#1320)
Support for Transducers! (ee9c68f1)
Add new method,
zipAll()(#1195)Bundle and distribute an "es module" so Webpack and Rollup can use tree-shaking for smaller builds (#1204)
Warn instead of throw when
getIn()has a bad path (668f2236)A new predicate function
isValueObject()helps to detect objects which implementequals()andhashCode(),and type definitions now define the interface
ValueObjectwhich you can implement in your own code to create objects whichbehave as values and can be keys in Maps or entries in Sets.
Using
fromJS()with a "reviver" function now provides access to the key path to each translated value. (#1118)Fixed
Fix issue with IE11 and missing Symbol.iterator (#1850)
Fix ordered set with map (#1663)
Do not modify iter during List.map and Map.map (#1649)
Fix ordered map delete all (#1777)
Hash symbols as objects (#1753)
Fix returning a Record in merge() when Record is empty (#1785)
Fix for RC~12: Records from different factories aren't equal (#1734)
"too much recursion" error when creating a Record type from an instance of another Record (#1690)
Fix glob for npm format script on Windows (#18)
Remove deprecated cursor API (#13)
Add missing es exports (#1740)
Support nulls in genTypeDefData.js (#185)
Support isPlainObj in IE11 and other esoteric parameters f3a6d5ce
Set.mapproduces valid underlying map (#1606)Support isPlainObj with
constructorkey (#1627)groupByno longer returns a mutable Map instance (#1602)Fix issue where refs can recursively collide, corrupting
.size(#1598)Throw error in
mergeWith()method if missing the requiredmergerfunction (#1543)Update
isPlainObj()to workaround Safari bug and allow cross-realm values (#1557)Fix missing "& T" to some methods in RecordInstance (#1464)
Make notSetValue optional for typed Records (#1461) (
a1029bb)Export type of RecordInstance (#1434)
Fix Record
sizecheck in merge() (#1521)Fix Map#concat being not defined (#1402)
getIn()no longer throws when encountering a missing path (#1361)Do not throw from hasIn (#1319)
Long hash codes no longer cause an infinite loop (#1175)
slice()which should return an empty set could return a full set or vice versa (#1245, #1287)Ensure empty slices do not throw when iterated (#1220)
Error during equals check on Record with undefined or null (#1208)
Fix size of count() after filtering or flattening (#1171)
Configuration
📅 Schedule: (in timezone Europe/Zurich)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.