refactor: Remote code execution via MongoDB BSON parser through prototype pollution; fixes security vulnerability [GHSA-462x-c3jw-7vr6](https://github.com/parse-community/parse-server/security/advisories/GHSA-462x-c3jw-7vr6) (#8676)
This commit is contained in:
@@ -64,8 +64,6 @@ function RestWrite(config, auth, className, query, data, originalData, clientSDK
|
||||
}
|
||||
}
|
||||
|
||||
this.checkProhibitedKeywords(data);
|
||||
|
||||
// When the operation is complete, this.response may have several
|
||||
// fields.
|
||||
// response: the actual data to be returned
|
||||
@@ -304,7 +302,11 @@ RestWrite.prototype.runBeforeSaveTrigger = function () {
|
||||
delete this.data.objectId;
|
||||
}
|
||||
}
|
||||
this.checkProhibitedKeywords(this.data);
|
||||
try {
|
||||
Utils.checkProhibitedKeywords(this.config, this.data);
|
||||
} catch (error) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1798,20 +1800,5 @@ RestWrite.prototype._updateResponseWithData = function (response, data) {
|
||||
return response;
|
||||
};
|
||||
|
||||
RestWrite.prototype.checkProhibitedKeywords = function (data) {
|
||||
if (this.config.requestKeywordDenylist) {
|
||||
// Scan request data for denied keywords
|
||||
for (const keyword of this.config.requestKeywordDenylist) {
|
||||
const match = Utils.objectContainsKeyValue(data, keyword.key, keyword.value);
|
||||
if (match) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
`Prohibited keyword in request data: ${JSON.stringify(keyword)}.`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default RestWrite;
|
||||
module.exports = RestWrite;
|
||||
|
||||
Reference in New Issue
Block a user