Skip to content

Commit 4ac4b7f

Browse files
authored
Merge pull request from GHSA-7pr3-p5fm-8r9x
* fix: LQ deletes session token * add 4.10.4 * add changes
1 parent 6683cd9 commit 4ac4b7f

File tree

6 files changed

+121
-6
lines changed

6 files changed

+121
-6
lines changed

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Parse Server Changelog
22

3+
## 4.10.4
4+
[Full Changelog](https://github.com/parse-community/parse-server/compare/4.10.3...4.10.4)
5+
6+
### Security Fixes
7+
- Strip out sessionToken when LiveQuery is used on Parse.User (Daniel Blyth) [GHSA-7pr3-p5fm-8r9x](https://github.com/parse-community/parse-server/security/advisories/GHSA-7pr3-p5fm-8r9x)
8+
39
# 4.10.3
410

511
## Security Fixes
@@ -24,15 +30,15 @@
2430

2531
*Versions >4.5.2 and <4.10.0 are skipped.*
2632

27-
> ⚠️ A security incident caused a number of incorrect version tags to be pushed to the Parse Server repository. These version tags linked to a personal fork of a contributor who had write access to the repository. The code to which these tags linked has not been reviewed or approved by Parse Platform. Even though no releases were published with these incorrect versions, it was possible to define a Parse Server dependency that pointed to these version tags, for example if you defined this dependency:
33+
> ⚠️ A security incident caused a number of incorrect version tags to be pushed to the Parse Server repository. These version tags linked to a personal fork of a contributor who had write access to the repository. The code to which these tags linked has not been reviewed or approved by Parse Platform. Even though no releases were published with these incorrect versions, it was possible to define a Parse Server dependency that pointed to these version tags, for example if you defined this dependency:
2834
> ```js
2935
> "parse-server": "[email protected]:parse-community/parse-server.git#4.9.3"
3036
> ```
31-
>
37+
>
3238
> We have since deleted the incorrect version tags, but they may still show up if your personal fork on GitHub or locally. We do not know when these tags have been pushed to the Parse Server repository, but we first became aware of this issue on July 21, 2021. We are not aware of any malicious code or concerns related to privacy, security or legality (e.g. proprietary code). However, it has been reported that some functionality does not work as expected and the introduction of security vulnerabilities cannot be ruled out.
3339
>
34-
> You may be also affected if you used the Bitnami image for Parse Server. Bitnami picked up the incorrect version tag `4.9.3` and published a new Bitnami image for Parse Server.
35-
>
40+
> You may be also affected if you used the Bitnami image for Parse Server. Bitnami picked up the incorrect version tag `4.9.3` and published a new Bitnami image for Parse Server.
41+
>
3642
>**If you are using any of the affected versions, we urgently recommend to upgrade to version `4.10.0`.**
3743
3844
# 4.5.2

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-server",
3-
"version": "4.10.3",
3+
"version": "4.10.4",
44
"description": "An express module providing a Parse-compatible API server",
55
"main": "lib/index.js",
66
"repository": {

spec/ParseLiveQuery.spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,52 @@ describe('ParseLiveQuery', function () {
928928
done();
929929
});
930930

931+
it('should strip out session token in LiveQuery', async () => {
932+
await reconfigureServer({
933+
liveQuery: { classNames: ['_User'] },
934+
startLiveQueryServer: true,
935+
verbose: false,
936+
silent: true,
937+
});
938+
939+
const user = new Parse.User();
940+
user.setUsername('username');
941+
user.setPassword('password');
942+
user.set('foo', 'bar');
943+
944+
const query = new Parse.Query(Parse.User);
945+
query.equalTo('foo', 'bar');
946+
const subscription = await query.subscribe();
947+
948+
const events = ['create', 'update', 'enter', 'leave', 'delete'];
949+
const response = (obj, prev) => {
950+
expect(obj.get('sessionToken')).toBeUndefined();
951+
expect(obj.sessionToken).toBeUndefined();
952+
expect(prev?.sessionToken).toBeUndefined();
953+
if (prev && prev.get) {
954+
expect(prev.get('sessionToken')).toBeUndefined();
955+
}
956+
};
957+
const calls = {};
958+
for (const key of events) {
959+
calls[key] = response;
960+
spyOn(calls, key).and.callThrough();
961+
subscription.on(key, calls[key]);
962+
}
963+
await user.signUp();
964+
user.unset('foo');
965+
await user.save();
966+
user.set('foo', 'bar');
967+
await user.save();
968+
user.set('yolo', 'bar');
969+
await user.save();
970+
await user.destroy();
971+
await new Promise(resolve => process.nextTick(resolve));
972+
for (const key of events) {
973+
expect(calls[key]).toHaveBeenCalled();
974+
}
975+
});
976+
931977
afterEach(async function (done) {
932978
const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient();
933979
client.close();

spec/ParseUser.spec.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,6 +3929,51 @@ describe('Parse.User testing', () => {
39293929
}
39303930
});
39313931

3932+
it('should strip out authdata in LiveQuery', async () => {
3933+
const provider = getMockFacebookProvider();
3934+
Parse.User._registerAuthenticationProvider(provider);
3935+
3936+
await reconfigureServer({
3937+
liveQuery: { classNames: ['_User'] },
3938+
startLiveQueryServer: true,
3939+
verbose: false,
3940+
silent: true,
3941+
});
3942+
3943+
const query = new Parse.Query(Parse.User);
3944+
query.doesNotExist('foo');
3945+
const subscription = await query.subscribe();
3946+
3947+
const events = ['create', 'update', 'enter', 'leave', 'delete'];
3948+
const response = (obj, prev) => {
3949+
expect(obj.get('authData')).toBeUndefined();
3950+
expect(obj.authData).toBeUndefined();
3951+
expect(prev?.authData).toBeUndefined();
3952+
if (prev && prev.get) {
3953+
expect(prev.get('authData')).toBeUndefined();
3954+
}
3955+
};
3956+
const calls = {};
3957+
for (const key of events) {
3958+
calls[key] = response;
3959+
spyOn(calls, key).and.callThrough();
3960+
subscription.on(key, calls[key]);
3961+
}
3962+
const user = await Parse.User._logInWith('facebook');
3963+
3964+
user.set('foo', 'bar');
3965+
await user.save();
3966+
user.unset('foo');
3967+
await user.save();
3968+
user.set('yolo', 'bar');
3969+
await user.save();
3970+
await user.destroy();
3971+
await new Promise(resolve => process.nextTick(resolve));
3972+
for (const key of events) {
3973+
expect(calls[key]).toHaveBeenCalled();
3974+
}
3975+
});
3976+
39323977
describe('issue #4897', () => {
39333978
it_only_db('mongo')('should be able to login with a legacy user (no ACL)', async () => {
39343979
// This issue is a side effect of the locked users and legacy users which don't have ACL's

src/LiveQuery/ParseLiveQueryServer.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ class ParseLiveQueryServer {
179179
deletedParseObject = res.object.toJSON();
180180
deletedParseObject.className = className;
181181
}
182+
if (
183+
(deletedParseObject.className === '_User' ||
184+
deletedParseObject.className === '_Session') &&
185+
!client.hasMasterKey
186+
) {
187+
delete deletedParseObject.sessionToken;
188+
delete deletedParseObject.authData;
189+
}
182190
client.pushDelete(requestId, deletedParseObject);
183191
})
184192
.catch(error => {
@@ -315,6 +323,16 @@ class ParseLiveQueryServer {
315323
originalParseObject = res.original.toJSON();
316324
originalParseObject.className = res.original.className || className;
317325
}
326+
if (
327+
(currentParseObject.className === '_User' ||
328+
currentParseObject.className === '_Session') &&
329+
!client.hasMasterKey
330+
) {
331+
delete currentParseObject.sessionToken;
332+
delete originalParseObject?.sessionToken;
333+
delete currentParseObject.authData;
334+
delete originalParseObject?.authData;
335+
}
318336
const functionName =
319337
'push' + message.event.charAt(0).toUpperCase() + message.event.slice(1);
320338
if (client[functionName]) {

0 commit comments

Comments
 (0)