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:
@@ -175,22 +175,13 @@ export class FilesRouter {
|
||||
const base64 = req.body.toString('base64');
|
||||
const file = new Parse.File(filename, { base64 }, contentType);
|
||||
const { metadata = {}, tags = {} } = req.fileData || {};
|
||||
if (req.config && req.config.requestKeywordDenylist) {
|
||||
try {
|
||||
// Scan request data for denied keywords
|
||||
for (const keyword of req.config.requestKeywordDenylist) {
|
||||
const match =
|
||||
Utils.objectContainsKeyValue(metadata, keyword.key, keyword.value) ||
|
||||
Utils.objectContainsKeyValue(tags, keyword.key, keyword.value);
|
||||
if (match) {
|
||||
next(
|
||||
new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
`Prohibited keyword in request data: ${JSON.stringify(keyword)}.`
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Utils.checkProhibitedKeywords(config, metadata);
|
||||
Utils.checkProhibitedKeywords(config, tags);
|
||||
} catch (error) {
|
||||
next(new Parse.Error(Parse.Error.INVALID_KEY_NAME, error));
|
||||
return;
|
||||
}
|
||||
file.setTags(tags);
|
||||
file.setMetadata(metadata);
|
||||
|
||||
Reference in New Issue
Block a user