Skip to content

fix(store): guard deepClone against __proto__ key reassignment - #195

Merged
JosunLP merged 1 commit into
devfrom
fix/175-deepclone-proto-guard
Jul 6, 2026
Merged

fix(store): guard deepClone against __proto__ key reassignment#195
JosunLP merged 1 commit into
devfrom
fix/175-deepclone-proto-guard

Conversation

@JosunLP

@JosunLP JosunLP commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #175 (Low; robustness).

The store's deepClone assigned via bracket notation over Object.keys, so a state object with an own enumerable __proto__ key (e.g. from JSON.parse('{"__proto__":{…}}')) triggered the __proto__ setter and reassigned the clone's prototype instead of copying a data property, corrupting the object $patchDeep operates on. Contained (no global Object.prototype pollution) but a fidelity bug.

Fix

deepClone skips prototype-pollution keys via the shared isPrototypePollutionKey helper from core/utils/object.ts (already used by merge).

Verification

  • New test: cloning a JSON.parse'd {"__proto__":{polluted:true},"safe":1} yields a clone whose prototype is still Object.prototype, preserves safe, and does not pollute {}. Fails on the pre-fix code.
  • Store suite: 95 pass / 0 fail. tsc --noEmit clean.

🤖 Generated with Claude Code

deepClone assigned via bracket notation over Object.keys, so an own
enumerable __proto__ key (e.g. from JSON.parse('{"__proto__":{…}}'))
triggered the setter and reassigned the clone's prototype instead of
copying a data property, corrupting the object $patchDeep operates on.

deepClone now skips prototype-pollution keys via the shared
isPrototypePollutionKey helper.

Fixes #175

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7ba94f3-8b1f-4b83-b3d6-eae06f038e0c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/175-deepclone-proto-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added store Changes to the store module tests Chenges to the tests labels Jul 6, 2026
@JosunLP
JosunLP merged commit 2d2a40e into dev Jul 6, 2026
9 checks passed
@JosunLP
JosunLP deleted the fix/175-deepclone-proto-guard branch July 6, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

store Changes to the store module tests Chenges to the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant