Skip to content

Commit df5ac7d

Browse files
committed
Merge remote-tracking branch 'upstream/alpha' into alpha
2 parents 94c77b6 + c6b7470 commit df5ac7d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

spec/vulnerabilities.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,35 @@ describe('Vulnerabilities', () => {
4747
).toBeRejectedWith(new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'Invalid object ID.'));
4848
await new Parse.Query(Parse.User).find({ sessionToken: innocentUser.getSessionToken() });
4949
});
50+
51+
});
52+
53+
describe('legacy session upgrade for user with poisoned object ID', () => {
54+
// Legacy session tokens (_session_token on _User) are a MongoDB-only legacy feature
55+
it_only_db('mongo')('refuses legacy session upgrade for user with poisoned object ID', async () => {
56+
const parseServer = await global.reconfigureServer();
57+
const databaseController = parseServer.config.databaseController;
58+
const poisonedId = 'role:legacy';
59+
const legacyToken = 'legacy-poisoned-token';
60+
// Create user with poisoned ID and legacy session token directly in DB
61+
await databaseController.create('_User', {
62+
objectId: poisonedId,
63+
_session_token: legacyToken,
64+
});
65+
await expectAsync(
66+
request({
67+
method: 'POST',
68+
url: 'http://localhost:8378/1/upgradeToRevocableSession',
69+
headers: {
70+
'Content-Type': 'application/json',
71+
'X-Parse-Application-Id': 'test',
72+
'X-Parse-REST-API-Key': 'rest',
73+
'X-Parse-Session-Token': legacyToken,
74+
},
75+
body: JSON.stringify({}),
76+
})
77+
).toBeRejected();
78+
});
5079
});
5180
});
5281

src/Auth.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ var getAuthForLegacySessionToken = async function ({ config, sessionToken, insta
228228
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'invalid legacy session token');
229229
}
230230
const obj = results[0];
231+
232+
if (typeof obj['objectId'] === 'string' && obj['objectId'].startsWith('role:')) {
233+
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'Invalid object ID.');
234+
}
235+
231236
obj.className = '_User';
232237
const userObject = Parse.Object.fromJSON(obj);
233238
return new Auth({

0 commit comments

Comments
 (0)