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 1 commit
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
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -51,8 +51,8 @@
"set"
],
"devDependencies": {
"bundt": "1.1.2",
"bundt": "1.1.5",
lukeed marked this conversation as resolved.
Show resolved Hide resolved
"esm": "3.2.25",
"uvu": "0.5.1"
"uvu": "0.5.3"
lukeed marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
13 changes: 13 additions & 0 deletions test/suites/pollution.js
Expand Up @@ -85,5 +85,18 @@ export default function (dset) {
});
});

// Test for CVE-2022-25645 - CWE-1321
pollution(
"should ignore JSON.parse crafted object including __proto__ :: provided by snyk",
() => {
var a = { b: { c: 1 } };
assert.is(a.polluted, undefined);
assert.is({}.polluted, undefined);
dset(a, "b", JSON.parse('{"__proto__":{"polluted":"Yes!"}}')); //Needs to craft payload with JSON.parse to keep the object key proto
assert.is(a.polluted, undefined);
assert.is({}.polluted, undefined);
}
);
lukeed marked this conversation as resolved.
Show resolved Hide resolved

pollution.run();
}