Skip to content

feat(utils): implement defensive deepClone with WeakMap and prototype pollution defense (#13830) - #13831

Open
whyst0ne wants to merge 1 commit into
SecureBananaLabs:mainfrom
whyst0ne:feat/deep-clone-defense-v2
Open

whyst0ne wants to merge 1 commit into
SecureBananaLabs:mainfrom
whyst0ne:feat/deep-clone-defense-v2

Conversation

@whyst0ne

Copy link
Copy Markdown

Closes #13830
Refs #743

Summary

  • Implemented defensive deepClone(value, options), isCloneable, and safeClone in apps/api/src/utils/deepClone.js.
  • Handled complex circular reference topologies across objects, arrays, Maps, and Sets via WeakMap memoization.
  • Defended against Prototype Pollution (CWE-1321) by screening dangerous keys (__proto__, constructor, prototype).
  • Preserved prototype chains including Object.create(null) null-prototype dictionaries.
  • Isolated memory allocations for ArrayBuffer, TypedArrays (Uint8Array, Float64Array, BigInt64Array), and DataView.
  • Preserved own Symbol properties and property descriptors.
  • Maintained full fidelity for Date, RegExp (source, flags, lastIndex), and Error (name, message, cause).
  • Comprehensive unit test suite in apps/api/src/tests/deepClone.test.js (23/23 passing via node --test).

Settlement Address: 0xE5Ab26877172254B72f3AE6DA5789D2468B7B282
Estimated Bounty Tier: $800 USD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(utils): implement defensive deepClone with WeakMap circular reference tracking and prototype pollution defense (ref #743)

1 participant