Skip to content

Commit 75abf38

Browse files
authored
fix(core): sanitize object keys in deepCopy to prevent prototype pollution
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.
1 parent 5adc925 commit 75abf38

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/angular_devkit/core/src/utils

packages/angular_devkit/core/src/utils/object.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@ export function deepCopy<T>(value: T): T {
3030

3131
const copy = Object.create(Object.getPrototypeOf(valueCasted));
3232
valueCasted[copySymbol] = copy;
33+
3334
for (const key of Object.getOwnPropertyNames(valueCasted)) {
35+
// 🛡️ SECURITY CHECK FIRST: Block prototype pollution keys
36+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
37+
continue;
38+
}
39+
40+
// Now it is safe to copy
3441
copy[key] = deepCopy(valueCasted[key]);
3542
}
43+
3644
delete valueCasted[copySymbol];
37-
3845
return copy;
3946
} else {
4047
return value;

0 commit comments

Comments
 (0)