Open
Conversation
All errors are fixed expect some regarding lib/SimpleSchema.js and its class fields and static properties which are recents syntax updates
WIP - make simple-schema fully Async
| merge(destination[prop], source[prop]) | ||
| } else { | ||
| destination[prop] = source[prop]; | ||
| destination[prop] = source[prop] |
Check warning
Code scanning / CodeQL
Prototype-polluting function Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 months ago
To fix the prototype pollution vulnerability, we should block all dangerous property names from being merged into the destination object. Specifically, we should skip any property named __proto__, constructor, or prototype during the merge. This can be done by adding a check at the start of the property loop to return early if the property name matches any of these. The fix should be applied in the merge function in lib/utility/merge.js, specifically in the property iteration block (lines 13–27). No new imports or methods are needed.
Suggested changeset
1
lib/utility/merge.js
| @@ -11,7 +11,7 @@ | ||
| export default function merge (destination, ...sources) { | ||
| sources.forEach((source) => { | ||
| Object.keys(source).forEach((prop) => { | ||
| if (prop === '__proto__') return // protect against prototype pollution | ||
| if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return // protect against prototype pollution | ||
| if ( | ||
| source[prop] && | ||
| source[prop].constructor && |
Copilot is powered by AI and may make mistakes. Always verify output.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on @vparpoil last PR this is going to continue full async support. This will be breaking, so a new major version will be introduced.
The following parts will be async:
We need to test, where the async pattern is breaking current setups and document these changes with examples in a migration guide.