Skip to content

fix(core): sanitize object keys in deepCopy to prevent prototype pollution#33049

Open
XananasX7 wants to merge 1 commit intoangular:mainfrom
XananasX7:patch-1
Open

fix(core): sanitize object keys in deepCopy to prevent prototype pollution#33049
XananasX7 wants to merge 1 commit intoangular:mainfrom
XananasX7:patch-1

Conversation

@XananasX7
Copy link
Copy Markdown

Description

This Pull Request fixes a critical Prototype Pollution vulnerability in the deepCopy utility within @angular-devkit/core.

Technical Details

The current implementation of deepCopy recursively iterates over object properties using Object.getOwnPropertyNames without sanitizing sensitive keys. An attacker can provide a malicious configuration (e.g., in angular.json) containing __proto__, constructor, or prototype keys to pollute the global Object.prototype. In Node.js environments, this can lead to Remote Code Execution (RCE) by overwriting inherited properties used by task runners.

Fix

Implemented a security check within the recursive loop to skip sensitive keys (__proto__, constructor, prototype), ensuring the integrity of the prototype chain.

Reference: Google Issue Tracker #506079652

…ution

This patch addresses a critical Prototype Pollution vulnerability in the deepCopy utility. By blocking sensitive keys such as __proto__, constructor, and prototype during recursive cloning, we prevent attackers from polluting the global Object.prototype via malicious configuration files (e.g., angular.json). This fix directly mitigates the RCE risk reported in Google Issue Tracker #506079652.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the deepCopy utility by adding a security check to prevent prototype pollution. It explicitly skips the proto, constructor, and prototype keys during object cloning. I have no feedback to provide.

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.

1 participant