Skip to content

Commit 7e88e47

Browse files
committed
fix: prototype pollution vulnerability in extend (CVE-2024-45435) andersk chartist-js#1433
1 parent 05ba72a commit 7e88e47

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/utils/extend.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export function extend<T, A, B>(target: T, a: A, b: B): T & A & B;
1111
export function extend(target: any = {}, ...sources: any[]) {
1212
for (let i = 0; i < sources.length; i++) {
1313
const source = sources[i];
14+
const targetProto = Object.getPrototypeOf(target);
1415
for (const prop in source) {
16+
if (targetProto !== null && prop in targetProto) {
17+
continue; // prevent prototype pollution
18+
}
1519
const sourceProp = source[prop];
1620
if (
1721
typeof sourceProp === 'object' &&

0 commit comments

Comments
 (0)