bug: prevent prototype pollution in chat.add message merge - #219
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
bug: prevent prototype pollution in chat.add message merge#219devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Replace lodash _.merge of untrusted req.body.message with an allow-listed Object.assign, harden chat.delete/findUser, and bump lodash to 4.17.21.
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
chat.addmerged the untrustedreq.body.messagestraight into the outgoing message with_.mergeon lodash 4.17.4, so a body like{"message":{"__proto__":{"canDelete":true}}}pollutedObject.prototypeand granted every user the delete permission checked inchat.delete.The merge is replaced by an allow-listed copy — no recursive merge of attacker-controlled keys reaches the target:
Defense in depth on the same path:
chat.deletenow requires an owncanDelete === trueon the user record, so a polluted prototype can't grant it.findUserrejects non-stringname/password(blocks{"$ne": null}-style objects).lodashbumped 4.17.4 → 4.17.21 (the version that fixes themergepollution CVEs) inpackage.jsonand bothpackage-lock.jsonsections; therequire('lodash')inroutes/index.jsis dropped since nothing else uses it.tests/chat.prototype-pollution.test.jscovers__proto__(built withJSON.parse, since an object-literal__proto__key isn't an own property),constructor.prototype, field allow-listing, the delete denial, and non-string credentials. 5/5 pass; they fail onmain.Devin-Org: engineering
Devin Review