Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue#33 CVE-2022-25645 added test for it #38

Merged
merged 2 commits into from May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/merge.js
Expand Up @@ -6,6 +6,7 @@ export function merge(a, b, k) {
}
} else {
for (k in b) {
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
a[k] = merge(a[k], b[k]);
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/suites/pollution.js
Expand Up @@ -85,5 +85,15 @@ export default function (dset) {
});
});

// Test for CVE-2022-25645 - CWE-1321
pollution('should ignore JSON.parse crafted object with "__proto__" key', () => {
let a = { b: { c: 1 } };
assert.is(a.polluted, undefined);
assert.is({}.polluted, undefined);
dset(a, "b", JSON.parse('{"__proto__":{"polluted":"Yes!"}}'));
assert.is(a.polluted, undefined);
assert.is({}.polluted, undefined);
});

pollution.run();
}