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

It's possible to pollute object prototype #188

Closed
bebraw opened this issue Jun 21, 2021 · 1 comment
Closed

It's possible to pollute object prototype #188

bebraw opened this issue Jun 21, 2021 · 1 comment

Comments

@bebraw
Copy link
Member

bebraw commented Jun 21, 2021

Consider the following test:

it("should not pollute __proto__", function () {
    const obj = { tmp: "" };

    // @ts-ignore: Pollute __proto__ on purpose
    merge(obj, (obj.__proto__.polluted = "Proto has been polluted"));

    const obj_new = [];

    // @ts-ignore: Pollute __proto__ on purpose
    expect(obj_new.polluted).toEqual(undefined);
});

The problem is, if there's a block like (obj.__proto__.polluted = "Proto has been polluted"), it's polluting the original obj.

I tried fixing it in various ways but it doesn't seem fixable and even with a no-op (i.e. return object), it's still polluted.

It would be great if someone could point out a way to fix the issue. Any sort of serialization is out of the window since you can merge objects with functions.

You can run the test at https://github.com/survivejs/webpack-merge/tree/fix/do-not-pollute .

Thanks to Daniel Elkabes from WhiteSource Software for pointing out the issue.

@bebraw
Copy link
Member Author

bebraw commented Jun 23, 2021

Based on Daniel fixing the issue is out of scope of this package after all so I'm closing this as wontfix as there's nothing to fix.

@bebraw bebraw closed this as completed Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant