Skip to content

Commit

Permalink
fix: prototype pollution vulnerability in extend (CVE-2024-45435)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersk committed Oct 2, 2024
1 parent 1067900 commit 12b84bd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export function extend<T, A, B>(target: T, a: A, b: B): T & A & B;
export function extend(target: any = {}, ...sources: any[]) {
for (let i = 0; i < sources.length; i++) {
const source = sources[i];
const targetProto = Object.getPrototypeOf(target);
for (const prop in source) {
if (targetProto !== null && prop in targetProto) {
continue; // prevent prototype pollution
}
const sourceProp = source[prop];
if (
typeof sourceProp === 'object' &&
Expand Down

0 comments on commit 12b84bd

Please sign in to comment.