-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix object proto pollution #113
Conversation
src/inserters.js
Outdated
desc.configurable = true; | ||
if (prop === 'value') { | ||
desc.writable = true; | ||
if (Object.hasOwnProperty.call(map, proto)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we instead do:
const protos = Object.getOwnPropertyNames(map);
for (let i = 0; i < protos.length; i++) {
const proto = protos[i];
const funcs = map[proto];
...
?
That way we save the extra indentation, and this should be safe because Object
is a native and therefore protos
too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(protos
could also be declared in the upper scope, outside of the function, your call)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good ideas! the 2nd will save the extra call. on it
test/inserters.js
Outdated
@@ -184,4 +184,22 @@ describe('test DOM insertions', async function () { | |||
}); | |||
expect(result).toBe('V'); | |||
}); | |||
|
|||
it('should fail to use atob of an iframe added after Object.prototype pollution', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent test, I think this would be more appropriate at /test/overwrites.js
. Also can you add the // reference: https://github.com/LavaMoat/snow/pull/112
comment please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @mmndaniel!
A few minor requests if you don't mind. Also, please add and commit snow.js
and snow.prod.js
files after running yarn build
locally (you can see in former PRs we add the dst files with each change. we do this because we'd like each version to be accessible via servers such as unpkg
out of the box)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, super important!
Thanks again for the help @mmndaniel 🙏
(first external PR ever btw 🎉)
An attempt to fix #112