fix(mongodb): Block arbitrary update operators in _patch data (CWE-943)#3665
Merged
fix(mongodb): Block arbitrary update operators in _patch data (CWE-943)#3665
Conversation
Member
|
Wasn't it always intended for the operators to be supported? |
71ba234 to
439a146
Compare
Add a disabledOperators option (defaults to ['$rename']) that drops specified MongoDB update operators from patch data before passing to findOneAndUpdate(). $rename is blocked by default since it can expose internal fields. Other operators like $push and $inc remain allowed since the dangerous scenarios they enable (e.g. unsetting passwords, pushing roles) should be caught by schema validation in a properly configured app. Apps can customize the denylist via the disabledOperators service option or per-call via params.adapter.disabledOperators.
439a146 to
72400a7
Compare
daffl
approved these changes
Mar 4, 2026
|
Thank you so much for fixing |
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.
Summary
Addresses NoSQL operator injection in
_patch()where arbitrary MongoDB update operators pass through directly tofindOneAndUpdate().Approach
Adds a
disabledOperatorsoption (defaults to['$rename']) that drops specified MongoDB update operators from patch data.$renameis blocked by default since it can expose internal fields. Other operators like$pushand$incremain allowed — the dangerous scenarios they enable (e.g. unsetting passwords, pushing roles) should be caught by schema validation in a properly configured app.Customizing the denylist
Per-service:
Per-call:
Related