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

Preventing prototype pollution vulnerabilities #2115

Merged
merged 7 commits into from
Apr 15, 2024

Conversation

AnastasiiaSvietlova
Copy link
Contributor

@AnastasiiaSvietlova AnastasiiaSvietlova commented Apr 8, 2024

Goal

Preventing the __proto__ , constructor or prototype property from being used as a section in clear and add methods of metadata-delegate.js

Changeset

Added condition if __proto__ || constructor || prototype tries to pass as a section in the clear or add method, it will not be executed.

Testing

Created unit tests for checking 'constructor' and 'prototype'.
it doesn't seem easy to check whether proto keys can be overwritten

Copy link

github-actions bot commented Apr 8, 2024

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 43.69 kB 13.41 kB
After 43.80 kB 13.43 kB
± ⚠️ +106 bytes ⚠️ +26 bytes

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against b27fa41

CHANGELOG.md Outdated Show resolved Hide resolved
packages/core/test/metadata-delegate.test.js Outdated Show resolved Hide resolved
@gingerbenw
Copy link
Member

was the vulnerability just for the clear method? should we add it to the add method as well, while we're here?

@AnastasiiaSvietlova
Copy link
Contributor Author

Yes, it was only for clear method. But I think it's a good point to do the same for add.

@AnastasiiaSvietlova AnastasiiaSvietlova requested review from gingerbenw and removed request for gingerbenw April 12, 2024 12:45
Copy link
Member

@gingerbenw gingerbenw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a couple of minor suggestions 👍🏻

CHANGELOG.md Outdated
Comment on lines 7 to 9
- (metadata-delegate) Preventing prototype pollution vulnerabilities [#2115](https://github.com/bugsnag/bugsnag-js/pull/2115)

- (plugin-interaction-breadcrumbs) Improved performance of click event breadcrumbs [#2094](https://github.com/bugsnag/bugsnag-js/pull/2094)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit of formatting:

Suggested change
- (metadata-delegate) Preventing prototype pollution vulnerabilities [#2115](https://github.com/bugsnag/bugsnag-js/pull/2115)
- (plugin-interaction-breadcrumbs) Improved performance of click event breadcrumbs [#2094](https://github.com/bugsnag/bugsnag-js/pull/2094)
- (plugin-interaction-breadcrumbs) Improved performance of click event breadcrumbs [#2094](https://github.com/bugsnag/bugsnag-js/pull/2094)
- (metadata-delegate) Preventing prototype pollution vulnerabilities [#2115](https://github.com/bugsnag/bugsnag-js/pull/2115)

key: 'prototype',
expected: {}
}
])('should not add constructor or prototype keys', ({ key, expected }) => {
Copy link
Member

@gingerbenw gingerbenw Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use $key here (or any key in objects provided to .each) to output the following at runtime:

should not add constructor keys
should not add prototype keys
Suggested change
])('should not add constructor or prototype keys', ({ key, expected }) => {
])('should not add $key keys', ({ key, expected }) => {

}
}
}
])('should not overwrite constructor or prototype keys', ({ key, state, expected }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
])('should not overwrite constructor or prototype keys', ({ key, state, expected }) => {
])('should not overwrite $key keys', ({ key, state, expected }) => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants