Skip to content

Commit 735669a

Browse files
authored
refactor: Prototype pollution via Cloud Code Webhooks; fixes security vulnerability [GHSA-93vw-8fm5-p2jf](GHSA-93vw-8fm5-p2jf) (#8307)
1 parent d9c3c02 commit 735669a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

spec/vulnerabilities.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ describe('Vulnerabilities', () => {
109109
);
110110
});
111111

112+
it('denies expanding existing object with polluted keys', async () => {
113+
const obj = await new Parse.Object('RCE', { a: { foo: [] } }).save();
114+
await reconfigureServer({
115+
requestKeywordDenylist: ['foo'],
116+
});
117+
obj.addUnique('a.foo', 'abc');
118+
await expectAsync(obj.save()).toBeRejectedWith(
119+
new Parse.Error(Parse.Error.INVALID_KEY_NAME, `Prohibited keyword in request data: "foo".`)
120+
);
121+
});
122+
112123
it('denies creating a cloud trigger with polluted data', async () => {
113124
Parse.Cloud.beforeSave('TestObject', ({ object }) => {
114125
object.set('obj', {

src/Controllers/DatabaseController.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,11 @@ class DatabaseController {
17681768
if (this.options && this.options.requestKeywordDenylist) {
17691769
// Scan request data for denied keywords
17701770
for (const keyword of this.options.requestKeywordDenylist) {
1771-
const match = Utils.objectContainsKeyValue({ firstKey: undefined }, keyword.key, undefined);
1771+
const match = Utils.objectContainsKeyValue(
1772+
{ [firstKey]: true, [nextPath]: true },
1773+
keyword.key,
1774+
true
1775+
);
17721776
if (match) {
17731777
throw new Parse.Error(
17741778
Parse.Error.INVALID_KEY_NAME,

0 commit comments

Comments
 (0)