Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions spec/vulnerabilities.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,44 @@ describe('(GHSA-fjxm-vhvc-gcmj) LiveQuery Operator Type Confusion', () => {
});
});

describe('challenge endpoint authData provider value validation', () => {
it('rejects challenge request with null provider value without 500', async () => {
const res = await request({
method: 'POST',
url: 'http://localhost:8378/1/challenge',
headers: {
'Content-Type': 'application/json',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest',
},
body: JSON.stringify({
authData: { anonymous: null },
challengeData: { anonymous: { token: '123456' } },
}),
}).catch(e => e);
expect(res.status).toBeGreaterThanOrEqual(400);
expect(res.status).toBeLessThan(500);
});

it('rejects challenge request with non-object provider value without 500', async () => {
const res = await request({
method: 'POST',
url: 'http://localhost:8378/1/challenge',
headers: {
'Content-Type': 'application/json',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest',
},
body: JSON.stringify({
authData: { anonymous: 'string_value' },
challengeData: { anonymous: { token: '123456' } },
}),
}).catch(e => e);
expect(res.status).toBeGreaterThanOrEqual(400);
expect(res.status).toBeLessThan(500);
});
});

describe('(GHSA-r3xq-68wh-gwvh) Password reset single-use token bypass via concurrent requests', () => {
let sendPasswordResetEmail;

Expand Down
13 changes: 11 additions & 2 deletions src/Routers/UsersRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,16 @@ export class UsersRouter extends ClassesRouter {
);
}

if (Object.keys(authData).filter(key => authData[key].id).length > 1) {
for (const key of Object.keys(authData)) {
if (authData[key] !== null && (typeof authData[key] !== 'object' || Array.isArray(authData[key]))) {
throw new Parse.Error(
Parse.Error.OTHER_CAUSE,
`authData.${key} should be an object.`
);
}
}

if (Object.keys(authData).filter(key => authData[key] && authData[key].id).length > 1) {
throw new Parse.Error(
Parse.Error.OTHER_CAUSE,
'You cannot provide more than one authData provider with an id.'
Expand All @@ -628,7 +637,7 @@ export class UsersRouter extends ClassesRouter {
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
}
// Find the provider used to find the user
const provider = Object.keys(authData).find(key => authData[key].id);
const provider = Object.keys(authData).find(key => authData[key] && authData[key].id);

parseUser = Parse.User.fromJSON({ className: '_User', ...results[0] });
request = getRequestObject(undefined, req.auth, parseUser, parseUser, req.config);
Expand Down
Loading