mirror of
https://github.com/parse-community/parse-server
synced 2026-08-09 13:03:18 +00:00
Compare commits
15
Commits
9.0.0-alpha.5
...
8.6.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c43ddb74e | ||
|
|
07870f59ee | ||
|
|
0994d6e9b8 | ||
|
|
0c940b7089 | ||
|
|
bfe11c4917 | ||
|
|
07bddc0850 | ||
|
|
d39387f44d | ||
|
|
6c79da91fc | ||
|
|
9f28ff5663 | ||
|
|
9b94083acc | ||
|
|
035b9b549e | ||
|
|
155c6ad92d | ||
|
|
0b032a3f87 | ||
|
|
12d8b502a2 | ||
|
|
9896817df6 |
+2
-3
@@ -34,7 +34,7 @@ async function config() {
|
||||
console.log(`Running on branch: ${branch}`);
|
||||
|
||||
// Set changelog file
|
||||
const changelogFile = `./changelogs/CHANGELOG_${branch}.md`;
|
||||
const changelogFile = `./changelogs/CHANGELOG_release.md`;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Changelog file output to: ${changelogFile}`);
|
||||
|
||||
@@ -46,9 +46,8 @@ async function config() {
|
||||
'release',
|
||||
{ name: 'alpha', prerelease: true },
|
||||
// { name: 'beta', prerelease: true },
|
||||
'next-major',
|
||||
// Long-Term-Support branch
|
||||
'release-8.x.x',
|
||||
{ name: 'release-8.x.x', range: '8.x.x', channel: '8.x.x' },
|
||||
],
|
||||
dryRun: false,
|
||||
debug: true,
|
||||
|
||||
@@ -1,3 +1,52 @@
|
||||
## [8.6.7](https://github.com/parse-community/parse-server/compare/8.6.6...8.6.7) (2026-03-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Malformed `$regex` query leaks database error details in API response (GHSA-9cp7-3q5w-j92g) ([#10102](https://github.com/parse-community/parse-server/issues/10102)) ([07870f5](https://github.com/parse-community/parse-server/commit/07870f59eec03f5c2a5fb1732cb28787ca3f8152))
|
||||
|
||||
## [8.6.6](https://github.com/parse-community/parse-server/compare/8.6.5...8.6.6) (2026-03-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Endpoint `/loginAs` allows `readOnlyMasterKey` to gain full read and write access as any user ([GHSA-79wj-8rqv-jvp5](https://github.com/parse-community/parse-server/security/advisories/GHSA-79wj-8rqv-jvp5)) ([#10099](https://github.com/parse-community/parse-server/issues/10099)) ([0c940b7](https://github.com/parse-community/parse-server/commit/0c940b70891c947fbf6c55536ed95ae300c23350))
|
||||
|
||||
## [8.6.5](https://github.com/parse-community/parse-server/compare/8.6.4...8.6.5) (2026-03-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* File creation and deletion bypasses `readOnlyMasterKey` write restriction (GHSA-xfh7-phr7-gr2x) ([#10096](https://github.com/parse-community/parse-server/issues/10096)) ([07bddc0](https://github.com/parse-community/parse-server/commit/07bddc0850c0eebb51219fe1d5d342f4412461ba))
|
||||
|
||||
## [8.6.4](https://github.com/parse-community/parse-server/compare/8.6.3...8.6.4) (2026-03-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Cloud Hooks and Cloud Jobs bypass `readOnlyMasterKey` write restriction (GHSA-vc89-5g3r-cmhh) ([#10089](https://github.com/parse-community/parse-server/issues/10089)) ([6c79da9](https://github.com/parse-community/parse-server/commit/6c79da91fc5ec6f2a0bb69a0ca6a886c1585754f))
|
||||
|
||||
## [8.6.3](https://github.com/parse-community/parse-server/compare/8.6.2...8.6.3) (2026-02-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* JWT Algorithm Confusion in Google Auth Adapter ([GHSA-4q3h-vp4r-prv2](https://github.com/parse-community/parse-server/security/advisories/GHSA-4q3h-vp4r-prv2)) ([#10073](https://github.com/parse-community/parse-server/issues/10073)) ([9b94083](https://github.com/parse-community/parse-server/commit/9b94083accb7f3e72c6b8126c195c7a03dd2dfd7))
|
||||
|
||||
## [8.6.2](https://github.com/parse-community/parse-server/compare/8.6.1...8.6.2) (2025-12-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Server-Side Request Forgery (SSRF) in Instagram auth adapter [GHSA-3f5f-xgrj-97pf](https://github.com/parse-community/parse-server/security/advisories/GHSA-3f5f-xgrj-97pf) ([#9989](https://github.com/parse-community/parse-server/issues/9989)) ([155c6ad](https://github.com/parse-community/parse-server/commit/155c6ad92d2375652c9720d7deed129a9e8f74ff))
|
||||
|
||||
## [8.6.1](https://github.com/parse-community/parse-server/compare/8.6.0...8.6.1) (2025-12-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Cross-Site Scripting (XSS) via HTML pages for password reset and email verification [GHSA-jhgf-2h8h-ggxv](https://github.com/parse-community/parse-server/security/advisories/GHSA-jhgf-2h8h-ggxv) ([#9986](https://github.com/parse-community/parse-server/issues/9986)) ([12d8b50](https://github.com/parse-community/parse-server/commit/12d8b502a2f99098d177d095842b07d55f62313a))
|
||||
|
||||
# [8.6.0](https://github.com/parse-community/parse-server/compare/8.5.0...8.6.0) (2025-12-10)
|
||||
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "parse-server",
|
||||
"version": "8.6.0",
|
||||
"version": "8.6.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "parse-server",
|
||||
"version": "8.6.0",
|
||||
"version": "8.6.7",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "parse-server",
|
||||
"version": "8.6.0",
|
||||
"version": "8.6.7",
|
||||
"description": "An express module providing a Parse-compatible API server",
|
||||
"main": "lib/index.js",
|
||||
"repository": {
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<body>
|
||||
<h1>{{appName}}</h1>
|
||||
<h1>Expired verification link!</h1>
|
||||
<form method="POST" action="{{{publicServerUrl}}}/apps/{{{appId}}}/resend_verification_email">
|
||||
<input name="token" type="hidden" value="{{{token}}}">
|
||||
<input name="locale" type="hidden" value="{{{locale}}}">
|
||||
<form method="POST" action="{{publicServerUrl}}/apps/{{appId}}/resend_verification_email">
|
||||
<input name="token" type="hidden" value="{{token}}">
|
||||
<input name="locale" type="hidden" value="{{locale}}">
|
||||
<button type="submit">Resend Link</button>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
<p>You can set a new Password for your account: {{username}}</p>
|
||||
<br />
|
||||
<p>{{error}}</p>
|
||||
<form id='form' action='{{{publicServerUrl}}}/apps/{{{appId}}}/request_password_reset' method='POST'>
|
||||
<form id='form' action='{{publicServerUrl}}/apps/{{appId}}/request_password_reset' method='POST'>
|
||||
<input name='utf-8' type='hidden' value='✓' />
|
||||
<input name="username" type="hidden" id="username" value="{{{username}}}" />
|
||||
<input name="token" type="hidden" id="token" value="{{{token}}}" />
|
||||
<input name="locale" type="hidden" id="locale" value="{{{locale}}}" />
|
||||
<input name="username" type="hidden" id="username" value="{{username}}" />
|
||||
<input name="token" type="hidden" id="token" value="{{token}}" />
|
||||
<input name="locale" type="hidden" id="locale" value="{{locale}}" />
|
||||
|
||||
<p>New Password</p>
|
||||
<input name="new_password" type="password" id="password" />
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<body>
|
||||
<h1>{{appName}}</h1>
|
||||
<h1>Expired verification link!</h1>
|
||||
<form method="POST" action="{{{publicServerUrl}}}/apps/{{{appId}}}/resend_verification_email">
|
||||
<input name="token" type="hidden" value="{{{token}}}">
|
||||
<input name="locale" type="hidden" value="{{{locale}}}">
|
||||
<form method="POST" action="{{publicServerUrl}}/apps/{{appId}}/resend_verification_email">
|
||||
<input name="token" type="hidden" value="{{token}}">
|
||||
<input name="locale" type="hidden" value="{{locale}}">
|
||||
<button type="submit">Resend Link</button>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
<p>You can set a new Password for your account: {{username}}</p>
|
||||
<br />
|
||||
<p>{{error}}</p>
|
||||
<form id='form' action='{{{publicServerUrl}}}/apps/{{{appId}}}/request_password_reset' method='POST'>
|
||||
<form id='form' action='{{publicServerUrl}}/apps/{{appId}}/request_password_reset' method='POST'>
|
||||
<input name='utf-8' type='hidden' value='✓' />
|
||||
<input name="username" type="hidden" id="username" value="{{{username}}}" />
|
||||
<input name="token" type="hidden" id="token" value="{{{token}}}" />
|
||||
<input name="locale" type="hidden" id="locale" value="{{{locale}}}" />
|
||||
<input name="username" type="hidden" id="username" value="{{username}}" />
|
||||
<input name="token" type="hidden" id="token" value="{{token}}" />
|
||||
<input name="locale" type="hidden" id="locale" value="{{locale}}" />
|
||||
|
||||
<p>New Password</p>
|
||||
<input name="new_password" type="password" id="password" />
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
<body>
|
||||
<h1>{{appName}}</h1>
|
||||
<h1>Expired verification link!</h1>
|
||||
<form method="POST" action="{{{publicServerUrl}}}/apps/{{{appId}}}/resend_verification_email">
|
||||
<input name="token" type="hidden" value="{{{token}}}">
|
||||
<input name="locale" type="hidden" value="{{{locale}}}">
|
||||
<form method="POST" action="{{publicServerUrl}}/apps/{{appId}}/resend_verification_email">
|
||||
<input name="token" type="hidden" value="{{token}}">
|
||||
<input name="locale" type="hidden" value="{{locale}}">
|
||||
<button type="submit">Resend Link</button>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
<p>You can set a new Password for your account: {{username}}</p>
|
||||
<br />
|
||||
<p>{{error}}</p>
|
||||
<form id='form' action='{{{publicServerUrl}}}/apps/{{{appId}}}/request_password_reset' method='POST'>
|
||||
<form id='form' action='{{publicServerUrl}}/apps/{{appId}}/request_password_reset' method='POST'>
|
||||
<input name='utf-8' type='hidden' value='✓' />
|
||||
<input name="username" type="hidden" id="username" value="{{{username}}}" />
|
||||
<input name="token" type="hidden" id="token" value="{{{token}}}" />
|
||||
<input name="locale" type="hidden" id="locale" value="{{{locale}}}" />
|
||||
<input name="username" type="hidden" id="username" value="{{username}}" />
|
||||
<input name="token" type="hidden" id="token" value="{{token}}" />
|
||||
<input name="locale" type="hidden" id="locale" value="{{locale}}" />
|
||||
|
||||
<p>New Password</p>
|
||||
<input name="new_password" type="password" id="password" />
|
||||
|
||||
@@ -101,6 +101,31 @@ describe('InstagramAdapter', function () {
|
||||
'Instagram auth is invalid for this user.'
|
||||
);
|
||||
});
|
||||
|
||||
it('should ignore client-provided apiURL and use hardcoded endpoint', async () => {
|
||||
const accessToken = 'mockAccessToken';
|
||||
const authData = {
|
||||
id: 'mockUserId',
|
||||
apiURL: 'https://example.com/',
|
||||
};
|
||||
|
||||
mockFetch([
|
||||
{
|
||||
url: 'https://graph.instagram.com/me?fields=id&access_token=mockAccessToken',
|
||||
method: 'GET',
|
||||
response: {
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
id: 'mockUserId',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const user = await adapter.getUserFromAccessToken(accessToken, authData);
|
||||
expect(user).toEqual({ id: 'mockUserId' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('InstagramAdapter E2E Test', function () {
|
||||
|
||||
@@ -500,19 +500,60 @@ describe('google auth adapter', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// it('should throw error if public key used to encode token is not available', async () => {
|
||||
// const fakeDecodedToken = { header: { kid: '789', alg: 'RS256' } };
|
||||
// try {
|
||||
// spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
it('should reject forged alg:none JWT from advisory PoC (GHSA-4q3h-vp4r-prv2)', async () => {
|
||||
const header = Buffer.from('{"alg":"none","kid":"nonexistent-key","typ":"JWT"}').toString('base64url');
|
||||
const payload = Buffer.from('{"sub":"the_user_id","iss":"accounts.google.com","aud":"secret","exp":9999999999}').toString('base64url');
|
||||
const forgedToken = `${header}.${payload}.`;
|
||||
|
||||
// await google.validateAuthData({ id: 'the_user_id', id_token: 'the_token' }, {});
|
||||
// fail();
|
||||
// } catch (e) {
|
||||
// expect(e.message).toBe(
|
||||
// `Unable to find matching key for Key ID: ${fakeDecodedToken.header.kid}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
|
||||
try {
|
||||
await google.validateAuthData(
|
||||
{ id: 'the_user_id', id_token: forgedToken },
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
fail('should have rejected forged token');
|
||||
} catch (e) {
|
||||
expect(e.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
|
||||
}
|
||||
});
|
||||
|
||||
it('should pass hardcoded RS256 algorithm to jwt.verify, not the JWT header alg', async () => {
|
||||
const fakeClaim = {
|
||||
iss: 'https://accounts.google.com',
|
||||
aud: 'secret',
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { kid: '123', alg: 'ES256' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
await google.validateAuthData(
|
||||
{ id: 'the_user_id', id_token: 'the_token' },
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(['RS256']);
|
||||
});
|
||||
|
||||
it('should throw error if Google signing key is not found', async () => {
|
||||
const fakeDecodedToken = { kid: '789', alg: 'RS256' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.rejectWith(new Error('key not found'));
|
||||
|
||||
try {
|
||||
await google.validateAuthData(
|
||||
{ id: 'the_user_id', id_token: 'the_token' },
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
fail('should have thrown');
|
||||
} catch (e) {
|
||||
expect(e.message).toBe('Unable to find matching key for Key ID: 789');
|
||||
}
|
||||
});
|
||||
|
||||
it('(using client id as string) should verify id_token (google.com)', async () => {
|
||||
const fakeClaim = {
|
||||
@@ -521,8 +562,10 @@ describe('google auth adapter', () => {
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
|
||||
const fakeDecodedToken = { kid: '123', alg: 'RS256' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
const result = await google.validateAuthData(
|
||||
@@ -537,8 +580,10 @@ describe('google auth adapter', () => {
|
||||
iss: 'https://not.google.com',
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
|
||||
const fakeDecodedToken = { kid: '123', alg: 'RS256' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
try {
|
||||
@@ -561,8 +606,10 @@ describe('google auth adapter', () => {
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
|
||||
const fakeDecodedToken = { kid: '123', alg: 'RS256' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
try {
|
||||
@@ -583,8 +630,10 @@ describe('google auth adapter', () => {
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
|
||||
const fakeDecodedToken = { kid: '123', alg: 'RS256' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
try {
|
||||
@@ -897,7 +946,27 @@ describe('apple signin auth adapter', () => {
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
expect(result).toEqual(fakeClaim);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(fakeDecodedToken.header.alg);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(['RS256']);
|
||||
});
|
||||
|
||||
it('should pass hardcoded RS256 algorithm to jwt.verify, not the JWT header alg (GHSA-4q3h-vp4r-prv2)', async () => {
|
||||
const fakeClaim = {
|
||||
iss: 'https://appleid.apple.com',
|
||||
aud: 'secret',
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { kid: '123', alg: 'none' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
await apple.validateAuthData(
|
||||
{ id: 'the_user_id', token: 'the_token' },
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(['RS256']);
|
||||
});
|
||||
|
||||
it('should not verify invalid id_token', async () => {
|
||||
@@ -1236,7 +1305,27 @@ describe('facebook limited auth adapter', () => {
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
expect(result).toEqual(fakeClaim);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(fakeDecodedToken.header.alg);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(['RS256']);
|
||||
});
|
||||
|
||||
it('should pass hardcoded RS256 algorithm to jwt.verify, not the JWT header alg (GHSA-4q3h-vp4r-prv2)', async () => {
|
||||
const fakeClaim = {
|
||||
iss: 'https://www.facebook.com',
|
||||
aud: 'secret',
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { kid: '123', alg: 'none' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
|
||||
await facebook.validateAuthData(
|
||||
{ id: 'the_user_id', token: 'the_token' },
|
||||
{ clientId: 'secret' }
|
||||
);
|
||||
expect(jwt.verify.calls.first().args[2].algorithms).toEqual(['RS256']);
|
||||
});
|
||||
|
||||
it('should not verify invalid id_token', async () => {
|
||||
|
||||
@@ -1180,4 +1180,72 @@ describe('Pages Router', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('XSS Protection', () => {
|
||||
beforeEach(async () => {
|
||||
await reconfigureServer({
|
||||
appId: 'test',
|
||||
appName: 'exampleAppname',
|
||||
publicServerURL: 'http://localhost:8378/1',
|
||||
pages: { enableRouter: true },
|
||||
});
|
||||
});
|
||||
|
||||
it('should escape XSS payloads in token parameter', async () => {
|
||||
const xssPayload = '"><script>alert("XSS")</script>';
|
||||
const response = await request({
|
||||
url: `http://localhost:8378/1/apps/choose_password?token=${encodeURIComponent(xssPayload)}&username=test&appId=test`,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.text).not.toContain('<script>alert("XSS")</script>');
|
||||
expect(response.text).toContain('"><script>');
|
||||
});
|
||||
|
||||
it('should escape XSS in username parameter', async () => {
|
||||
const xssUsername = '<img src=x onerror=alert(1)>';
|
||||
const response = await request({
|
||||
url: `http://localhost:8378/1/apps/choose_password?username=${encodeURIComponent(xssUsername)}&appId=test`,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.text).not.toContain('<img src=x onerror=alert(1)>');
|
||||
expect(response.text).toContain('<img');
|
||||
});
|
||||
|
||||
it('should escape XSS in locale parameter', async () => {
|
||||
const xssLocale = '"><svg/onload=alert(1)>';
|
||||
const response = await request({
|
||||
url: `http://localhost:8378/1/apps/choose_password?locale=${encodeURIComponent(xssLocale)}&appId=test`,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.text).not.toContain('<svg/onload=alert(1)>');
|
||||
expect(response.text).toContain('"><svg');
|
||||
});
|
||||
|
||||
it('should handle legitimate usernames with quotes correctly', async () => {
|
||||
const username = "O'Brien";
|
||||
const response = await request({
|
||||
url: `http://localhost:8378/1/apps/choose_password?username=${encodeURIComponent(username)}&appId=test`,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
// Should be properly escaped as HTML entity
|
||||
expect(response.text).toContain('O'Brien');
|
||||
// Should NOT contain unescaped quote that breaks HTML
|
||||
expect(response.text).not.toContain('value="O\'Brien"');
|
||||
});
|
||||
|
||||
it('should handle legitimate usernames with ampersands correctly', async () => {
|
||||
const username = 'Smith & Co';
|
||||
const response = await request({
|
||||
url: `http://localhost:8378/1/apps/choose_password?username=${encodeURIComponent(username)}&appId=test`,
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
// Should be properly escaped
|
||||
expect(response.text).toContain('Smith & Co');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
-1
@@ -673,8 +673,10 @@ describe('server', () => {
|
||||
exp: Date.now(),
|
||||
sub: 'the_user_id',
|
||||
};
|
||||
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
|
||||
const fakeDecodedToken = { kid: '123', alg: 'RS256' };
|
||||
const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' };
|
||||
spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken);
|
||||
spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey);
|
||||
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
|
||||
const user = new Parse.User();
|
||||
user
|
||||
|
||||
@@ -1172,6 +1172,224 @@ describe('read-only masterKey', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw when trying to create a hook function', async () => {
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
url: `${Parse.serverURL}/hooks/functions`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { functionName: 'readOnlyTest', url: 'https://example.com/hook' },
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw when trying to create a hook trigger', async () => {
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
url: `${Parse.serverURL}/hooks/triggers`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { className: 'MyClass', triggerName: 'beforeSave', url: 'https://example.com/hook' },
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw when trying to update a hook function', async () => {
|
||||
// First create the hook with the real master key
|
||||
await request({
|
||||
url: `${Parse.serverURL}/hooks/functions`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': Parse.masterKey,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { functionName: 'readOnlyUpdateTest', url: 'https://example.com/hook' },
|
||||
});
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
url: `${Parse.serverURL}/hooks/functions/readOnlyUpdateTest`,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { url: 'https://example.com/hacked' },
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw when trying to delete a hook function', async () => {
|
||||
// First create the hook with the real master key
|
||||
await request({
|
||||
url: `${Parse.serverURL}/hooks/functions`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': Parse.masterKey,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { functionName: 'readOnlyDeleteTest', url: 'https://example.com/hook' },
|
||||
});
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
url: `${Parse.serverURL}/hooks/functions/readOnlyDeleteTest`,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { __op: 'Delete' },
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw when trying to run a job with readOnlyMasterKey', async () => {
|
||||
Parse.Cloud.job('readOnlyTestJob', () => {});
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
url: `${Parse.serverURL}/jobs/readOnlyTestJob`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: {},
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
|
||||
it('should allow reading hooks with readOnlyMasterKey', async () => {
|
||||
const res = await request({
|
||||
url: `${Parse.serverURL}/hooks/functions`,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
},
|
||||
});
|
||||
expect(Array.isArray(res.data)).toBe(true);
|
||||
});
|
||||
|
||||
it('should throw when trying to delete a file with readOnlyMasterKey', async () => {
|
||||
// Create a file with the real master key
|
||||
const uploadRes = await request({
|
||||
method: 'POST',
|
||||
url: `${Parse.serverURL}/files/readonly-delete-test.txt`,
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': Parse.masterKey,
|
||||
'Content-Type': 'text/plain',
|
||||
},
|
||||
body: 'file content',
|
||||
});
|
||||
const filename = uploadRes.data.name;
|
||||
expect(filename).toBeDefined();
|
||||
|
||||
// Attempt delete with readOnlyMasterKey — should be rejected
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
method: 'DELETE',
|
||||
url: `${Parse.serverURL}/files/${filename}`,
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
},
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.status).toBe(403);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
|
||||
// Verify file still exists
|
||||
const getRes = await request({ url: uploadRes.data.url });
|
||||
expect(getRes.status).toBe(200);
|
||||
});
|
||||
|
||||
it('should throw when trying to create a file with readOnlyMasterKey', async () => {
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
method: 'POST',
|
||||
url: `${Parse.serverURL}/files/readonly-create-test.txt`,
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'text/plain',
|
||||
},
|
||||
body: 'file content',
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.status).toBe(403);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw when trying to loginAs with readOnlyMasterKey', async () => {
|
||||
// Create a target user
|
||||
await Parse.User.signUp('readonly-loginas-test', 'password123');
|
||||
const userId = Parse.User.current().id;
|
||||
await Parse.User.logOut();
|
||||
|
||||
// Attempt loginAs with readOnlyMasterKey — should be rejected
|
||||
loggerErrorSpy.calls.reset();
|
||||
try {
|
||||
await request({
|
||||
method: 'POST',
|
||||
url: `${Parse.serverURL}/loginAs`,
|
||||
headers: {
|
||||
'X-Parse-Application-Id': Parse.applicationId,
|
||||
'X-Parse-Master-Key': 'read-only-test',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: { userId },
|
||||
});
|
||||
fail('should have thrown');
|
||||
} catch (res) {
|
||||
expect(res.data.code).toBe(Parse.Error.OPERATION_FORBIDDEN);
|
||||
expect(res.data.error).toBe('Permission denied');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('rest context', () => {
|
||||
|
||||
@@ -478,6 +478,75 @@ describe('Vulnerabilities', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Malformed $regex information disclosure', () => {
|
||||
it('should not leak database error internals for invalid regex pattern in class query', async () => {
|
||||
const logger = require('../lib/logger').default;
|
||||
const loggerErrorSpy = spyOn(logger, 'error').and.callThrough();
|
||||
const obj = new Parse.Object('TestObject');
|
||||
await obj.save({ field: 'value' });
|
||||
|
||||
try {
|
||||
await request({
|
||||
method: 'GET',
|
||||
url: `http://localhost:8378/1/classes/TestObject`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
},
|
||||
qs: {
|
||||
where: JSON.stringify({ field: { $regex: '[abc' } }),
|
||||
},
|
||||
});
|
||||
fail('Request should have failed');
|
||||
} catch (e) {
|
||||
expect(e.data.code).toBe(Parse.Error.INTERNAL_SERVER_ERROR);
|
||||
expect(e.data.error).toBe('An internal server error occurred');
|
||||
expect(typeof e.data.error).toBe('string');
|
||||
expect(JSON.stringify(e.data)).not.toContain('errmsg');
|
||||
expect(JSON.stringify(e.data)).not.toContain('codeName');
|
||||
expect(JSON.stringify(e.data)).not.toContain('errorResponse');
|
||||
expect(loggerErrorSpy).toHaveBeenCalledWith(
|
||||
'Sanitized error:',
|
||||
jasmine.stringMatching(/[Rr]egular expression/i)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('should not leak database error internals for invalid regex pattern in role query', async () => {
|
||||
const logger = require('../lib/logger').default;
|
||||
const loggerErrorSpy = spyOn(logger, 'error').and.callThrough();
|
||||
const role = new Parse.Role('testrole', new Parse.ACL());
|
||||
await role.save(null, { useMasterKey: true });
|
||||
try {
|
||||
await request({
|
||||
method: 'GET',
|
||||
url: `http://localhost:8378/1/roles`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
},
|
||||
qs: {
|
||||
where: JSON.stringify({ name: { $regex: '[abc' } }),
|
||||
},
|
||||
});
|
||||
fail('Request should have failed');
|
||||
} catch (e) {
|
||||
expect(e.data.code).toBe(Parse.Error.INTERNAL_SERVER_ERROR);
|
||||
expect(e.data.error).toBe('An internal server error occurred');
|
||||
expect(typeof e.data.error).toBe('string');
|
||||
expect(JSON.stringify(e.data)).not.toContain('errmsg');
|
||||
expect(JSON.stringify(e.data)).not.toContain('codeName');
|
||||
expect(JSON.stringify(e.data)).not.toContain('errorResponse');
|
||||
expect(loggerErrorSpy).toHaveBeenCalledWith(
|
||||
'Sanitized error:',
|
||||
jasmine.stringMatching(/[Rr]egular expression/i)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Postgres regex sanitizater', () => {
|
||||
it('sanitizes the regex correctly to prevent Injection', async () => {
|
||||
const user = new Parse.User();
|
||||
|
||||
@@ -77,7 +77,7 @@ const verifyIdToken = async ({ token, id }, { clientId, cacheMaxEntries, cacheMa
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, `id token is invalid for this user.`);
|
||||
}
|
||||
|
||||
const { kid: keyId, alg: algorithm } = authUtils.getHeaderFromToken(token);
|
||||
const { kid: keyId } = authUtils.getHeaderFromToken(token);
|
||||
const ONE_HOUR_IN_MS = 3600000;
|
||||
let jwtClaims;
|
||||
|
||||
@@ -89,7 +89,7 @@ const verifyIdToken = async ({ token, id }, { clientId, cacheMaxEntries, cacheMa
|
||||
|
||||
try {
|
||||
jwtClaims = jwt.verify(token, signingKey, {
|
||||
algorithms: algorithm,
|
||||
algorithms: ['RS256'],
|
||||
// the audience can be checked against a string, a regular expression or a list of strings and/or regular expressions.
|
||||
audience: clientId,
|
||||
});
|
||||
|
||||
@@ -136,7 +136,7 @@ const verifyIdToken = async ({ token, id }, { clientId, cacheMaxEntries, cacheMa
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'id token is invalid for this user.');
|
||||
}
|
||||
|
||||
const { kid: keyId, alg: algorithm } = authUtils.getHeaderFromToken(token);
|
||||
const { kid: keyId } = authUtils.getHeaderFromToken(token);
|
||||
const ONE_HOUR_IN_MS = 3600000;
|
||||
let jwtClaims;
|
||||
|
||||
@@ -148,7 +148,7 @@ const verifyIdToken = async ({ token, id }, { clientId, cacheMaxEntries, cacheMa
|
||||
|
||||
try {
|
||||
jwtClaims = jwt.verify(token, signingKey, {
|
||||
algorithms: algorithm,
|
||||
algorithms: ['RS256'],
|
||||
// the audience can be checked against a string, a regular expression or a list of strings and/or regular expressions.
|
||||
audience: clientId,
|
||||
});
|
||||
|
||||
+34
-105
@@ -4,6 +4,8 @@
|
||||
* @class GoogleAdapter
|
||||
* @param {Object} options - The adapter configuration options.
|
||||
* @param {string} options.clientId - Your Google application Client ID. Required for authentication.
|
||||
* @param {number} [options.cacheMaxEntries] - Maximum number of JWKS cache entries. Default: 5.
|
||||
* @param {number} [options.cacheMaxAge] - Maximum age of JWKS cache entries in ms. Default: 3600000 (1 hour).
|
||||
*
|
||||
* @description
|
||||
* ## Parse Server Configuration
|
||||
@@ -21,7 +23,6 @@
|
||||
* The adapter requires the following `authData` fields:
|
||||
* - **id**: The Google user ID.
|
||||
* - **id_token**: The Google ID token.
|
||||
* - **access_token**: The Google access token.
|
||||
*
|
||||
* ## Auth Payload
|
||||
* ### Example Auth Data Payload
|
||||
@@ -29,85 +30,67 @@
|
||||
* {
|
||||
* "google": {
|
||||
* "id": "1234567",
|
||||
* "id_token": "xxxxx.yyyyy.zzzzz",
|
||||
* "access_token": "abc123def456ghi789"
|
||||
* "id_token": "xxxxx.yyyyy.zzzzz"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ## Notes
|
||||
* - Ensure your Google Client ID is configured properly in the Parse Server configuration.
|
||||
* - The `id_token` and `access_token` are validated against Google's authentication services.
|
||||
* - The `id_token` is validated against Google's authentication services.
|
||||
*
|
||||
* @see {@link https://developers.google.com/identity/sign-in/web/backend-auth Google Authentication Documentation}
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// Helper functions for accessing the google API.
|
||||
var Parse = require('parse/node').Parse;
|
||||
|
||||
const https = require('https');
|
||||
const jwksClient = require('jwks-rsa');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const authUtils = require('./utils');
|
||||
|
||||
const TOKEN_ISSUER = 'accounts.google.com';
|
||||
const HTTPS_TOKEN_ISSUER = 'https://accounts.google.com';
|
||||
|
||||
let cache = {};
|
||||
|
||||
// Retrieve Google Signin Keys (with cache control)
|
||||
function getGoogleKeyByKeyId(keyId) {
|
||||
if (cache[keyId] && cache.expiresAt > new Date()) {
|
||||
return cache[keyId];
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
https
|
||||
.get(`https://www.googleapis.com/oauth2/v3/certs`, res => {
|
||||
let data = '';
|
||||
res.on('data', chunk => {
|
||||
data += chunk.toString('utf8');
|
||||
});
|
||||
res.on('end', () => {
|
||||
const { keys } = JSON.parse(data);
|
||||
const pems = keys.reduce(
|
||||
(pems, { n: modulus, e: exposant, kid }) =>
|
||||
Object.assign(pems, {
|
||||
[kid]: rsaPublicKeyToPEM(modulus, exposant),
|
||||
}),
|
||||
{}
|
||||
);
|
||||
|
||||
if (res.headers['cache-control']) {
|
||||
var expire = res.headers['cache-control'].match(/max-age=([0-9]+)/);
|
||||
|
||||
if (expire) {
|
||||
cache = Object.assign({}, pems, {
|
||||
expiresAt: new Date(new Date().getTime() + Number(expire[1]) * 1000),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
resolve(pems[keyId]);
|
||||
});
|
||||
})
|
||||
.on('error', reject);
|
||||
const getGoogleKeyByKeyId = async (keyId, cacheMaxEntries, cacheMaxAge) => {
|
||||
const client = jwksClient({
|
||||
jwksUri: 'https://www.googleapis.com/oauth2/v3/certs',
|
||||
cache: true,
|
||||
cacheMaxEntries,
|
||||
cacheMaxAge,
|
||||
});
|
||||
}
|
||||
|
||||
async function verifyIdToken({ id_token: token, id }, { clientId }) {
|
||||
let key;
|
||||
try {
|
||||
key = await authUtils.getSigningKey(client, keyId);
|
||||
} catch {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.OBJECT_NOT_FOUND,
|
||||
`Unable to find matching key for Key ID: ${keyId}`
|
||||
);
|
||||
}
|
||||
return key;
|
||||
};
|
||||
|
||||
async function verifyIdToken({ id_token: token, id }, { clientId, cacheMaxEntries, cacheMaxAge }) {
|
||||
if (!token) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, `id token is invalid for this user.`);
|
||||
}
|
||||
|
||||
const { kid: keyId, alg: algorithm } = authUtils.getHeaderFromToken(token);
|
||||
const { kid: keyId } = authUtils.getHeaderFromToken(token);
|
||||
const ONE_HOUR_IN_MS = 3600000;
|
||||
let jwtClaims;
|
||||
const googleKey = await getGoogleKeyByKeyId(keyId);
|
||||
|
||||
cacheMaxAge = cacheMaxAge || ONE_HOUR_IN_MS;
|
||||
cacheMaxEntries = cacheMaxEntries || 5;
|
||||
|
||||
const googleKey = await getGoogleKeyByKeyId(keyId, cacheMaxEntries, cacheMaxAge);
|
||||
const signingKey = googleKey.publicKey || googleKey.rsaPublicKey;
|
||||
|
||||
try {
|
||||
jwtClaims = jwt.verify(token, googleKey, {
|
||||
algorithms: algorithm,
|
||||
jwtClaims = jwt.verify(token, signingKey, {
|
||||
algorithms: ['RS256'],
|
||||
audience: clientId,
|
||||
});
|
||||
} catch (exception) {
|
||||
@@ -150,57 +133,3 @@ module.exports = {
|
||||
validateAppId: validateAppId,
|
||||
validateAuthData: validateAuthData,
|
||||
};
|
||||
|
||||
// Helpers functions to convert the RSA certs to PEM (from jwks-rsa)
|
||||
function rsaPublicKeyToPEM(modulusB64, exponentB64) {
|
||||
const modulus = new Buffer(modulusB64, 'base64');
|
||||
const exponent = new Buffer(exponentB64, 'base64');
|
||||
const modulusHex = prepadSigned(modulus.toString('hex'));
|
||||
const exponentHex = prepadSigned(exponent.toString('hex'));
|
||||
const modlen = modulusHex.length / 2;
|
||||
const explen = exponentHex.length / 2;
|
||||
|
||||
const encodedModlen = encodeLengthHex(modlen);
|
||||
const encodedExplen = encodeLengthHex(explen);
|
||||
const encodedPubkey =
|
||||
'30' +
|
||||
encodeLengthHex(modlen + explen + encodedModlen.length / 2 + encodedExplen.length / 2 + 2) +
|
||||
'02' +
|
||||
encodedModlen +
|
||||
modulusHex +
|
||||
'02' +
|
||||
encodedExplen +
|
||||
exponentHex;
|
||||
|
||||
const der = new Buffer(encodedPubkey, 'hex').toString('base64');
|
||||
|
||||
let pem = '-----BEGIN RSA PUBLIC KEY-----\n';
|
||||
pem += `${der.match(/.{1,64}/g).join('\n')}`;
|
||||
pem += '\n-----END RSA PUBLIC KEY-----\n';
|
||||
return pem;
|
||||
}
|
||||
|
||||
function prepadSigned(hexStr) {
|
||||
const msb = hexStr[0];
|
||||
if (msb < '0' || msb > '7') {
|
||||
return `00${hexStr}`;
|
||||
}
|
||||
return hexStr;
|
||||
}
|
||||
|
||||
function toHex(number) {
|
||||
const nstr = number.toString(16);
|
||||
if (nstr.length % 2) {
|
||||
return `0${nstr}`;
|
||||
}
|
||||
return nstr;
|
||||
}
|
||||
|
||||
function encodeLengthHex(n) {
|
||||
if (n <= 127) {
|
||||
return toHex(n);
|
||||
}
|
||||
const nHex = toHex(n);
|
||||
const lengthOfLengthByte = 128 + nHex.length / 2;
|
||||
return toHex(lengthOfLengthByte) + nHex;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,7 @@ class InstagramAdapter extends BaseAuthCodeAdapter {
|
||||
}
|
||||
|
||||
async getUserFromAccessToken(accessToken, authData) {
|
||||
const defaultURL = 'https://graph.instagram.com/';
|
||||
const apiURL = authData.apiURL || defaultURL;
|
||||
const apiURL = 'https://graph.instagram.com/';
|
||||
const path = `${apiURL}me?fields=id&access_token=${accessToken}`;
|
||||
|
||||
const response = await fetch(path);
|
||||
|
||||
@@ -20,6 +20,7 @@ import SchemaCache from '../Adapters/Cache/SchemaCache';
|
||||
import type { LoadSchemaOptions } from './types';
|
||||
import type { ParseServerOptions } from '../Options';
|
||||
import type { QueryOptions, FullQueryOptions } from '../Adapters/Storage/StorageAdapter';
|
||||
import { createSanitizedError } from '../Error';
|
||||
|
||||
function addWriteACL(query, acl) {
|
||||
const newQuery = _.cloneDeep(query);
|
||||
@@ -1354,7 +1355,19 @@ class DatabaseController {
|
||||
})
|
||||
)
|
||||
.catch(error => {
|
||||
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, error);
|
||||
if (error instanceof Parse.Error) {
|
||||
throw error;
|
||||
}
|
||||
const detailedMessage =
|
||||
typeof error === 'string'
|
||||
? error
|
||||
: error?.message || 'An internal server error occurred';
|
||||
throw createSanitizedError(
|
||||
Parse.Error.INTERNAL_SERVER_ERROR,
|
||||
detailedMessage,
|
||||
this.options,
|
||||
'An internal server error occurred'
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+4
-2
@@ -6,9 +6,11 @@ import defaultLogger from './logger';
|
||||
*
|
||||
* @param {number} errorCode - The Parse.Error code (e.g., Parse.Error.OPERATION_FORBIDDEN)
|
||||
* @param {string} detailedMessage - The detailed error message to log server-side
|
||||
* @param {object} config - Parse Server config with enableSanitizedErrorResponse
|
||||
* @param {string} [sanitizedMessage='Permission denied'] - The sanitized message to return to clients
|
||||
* @returns {Parse.Error} A Parse.Error with sanitized message
|
||||
*/
|
||||
function createSanitizedError(errorCode, detailedMessage, config) {
|
||||
function createSanitizedError(errorCode, detailedMessage, config, sanitizedMessage = 'Permission denied') {
|
||||
// On testing we need to add a prefix to the message to allow to find the correct call in the TestUtils.js file
|
||||
if (process.env.TESTING) {
|
||||
defaultLogger.error('Sanitized error:', detailedMessage);
|
||||
@@ -16,7 +18,7 @@ function createSanitizedError(errorCode, detailedMessage, config) {
|
||||
defaultLogger.error(detailedMessage);
|
||||
}
|
||||
|
||||
return new Parse.Error(errorCode, config?.enableSanitizedErrorResponse !== false ? 'Permission denied' : detailedMessage);
|
||||
return new Parse.Error(errorCode, config?.enableSanitizedErrorResponse !== false ? sanitizedMessage : detailedMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ import Config from '../Config';
|
||||
import logger from '../logger';
|
||||
const triggers = require('../triggers');
|
||||
const Utils = require('../Utils');
|
||||
import { createSanitizedHttpError } from '../Error';
|
||||
|
||||
export class FilesRouter {
|
||||
expressRouter({ maxUploadSize = '20Mb' } = {}) {
|
||||
@@ -112,6 +113,12 @@ export class FilesRouter {
|
||||
}
|
||||
|
||||
async createHandler(req, res, next) {
|
||||
if (req.auth.isReadOnly) {
|
||||
const error = createSanitizedHttpError(403, "read-only masterKey isn't allowed to create a file.", req.config);
|
||||
res.status(error.status);
|
||||
res.end(`{"error":"${error.message}"}`);
|
||||
return;
|
||||
}
|
||||
const config = req.config;
|
||||
const user = req.auth.user;
|
||||
const isMaster = req.auth.isMaster;
|
||||
@@ -266,6 +273,12 @@ export class FilesRouter {
|
||||
}
|
||||
|
||||
async deleteHandler(req, res, next) {
|
||||
if (req.auth.isReadOnly) {
|
||||
const error = createSanitizedHttpError(403, "read-only masterKey isn't allowed to delete a file.", req.config);
|
||||
res.status(error.status);
|
||||
res.end(`{"error":"${error.message}"}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { filesController } = req.config;
|
||||
const { filename } = req.params;
|
||||
|
||||
@@ -8,6 +8,7 @@ import { promiseEnforceMasterKeyAccess, promiseEnsureIdempotency } from '../midd
|
||||
import { jobStatusHandler } from '../StatusHandler';
|
||||
import _ from 'lodash';
|
||||
import { logger } from '../logger';
|
||||
import { createSanitizedError } from '../Error';
|
||||
|
||||
function parseObject(obj, config) {
|
||||
if (Array.isArray(obj)) {
|
||||
@@ -58,6 +59,13 @@ export class FunctionsRouter extends PromiseRouter {
|
||||
}
|
||||
|
||||
static handleCloudJob(req) {
|
||||
if (req.auth.isReadOnly) {
|
||||
throw createSanitizedError(
|
||||
Parse.Error.OPERATION_FORBIDDEN,
|
||||
"read-only masterKey isn't allowed to run a job.",
|
||||
req.config
|
||||
);
|
||||
}
|
||||
const jobName = req.params.jobName || req.body?.jobName;
|
||||
const applicationId = req.config.applicationId;
|
||||
const jobHandler = jobStatusHandler(req.config);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Parse } from 'parse/node';
|
||||
import PromiseRouter from '../PromiseRouter';
|
||||
import * as middleware from '../middlewares';
|
||||
import { createSanitizedError } from '../Error';
|
||||
|
||||
export class HooksRouter extends PromiseRouter {
|
||||
createHook(aHook, config) {
|
||||
@@ -12,6 +13,13 @@ export class HooksRouter extends PromiseRouter {
|
||||
}
|
||||
|
||||
handlePost(req) {
|
||||
if (req.auth.isReadOnly) {
|
||||
throw createSanitizedError(
|
||||
Parse.Error.OPERATION_FORBIDDEN,
|
||||
"read-only masterKey isn't allowed to create a hook.",
|
||||
req.config
|
||||
);
|
||||
}
|
||||
return this.createHook(req.body || {}, req.config);
|
||||
}
|
||||
|
||||
@@ -82,6 +90,13 @@ export class HooksRouter extends PromiseRouter {
|
||||
}
|
||||
|
||||
handlePut(req) {
|
||||
if (req.auth.isReadOnly) {
|
||||
throw createSanitizedError(
|
||||
Parse.Error.OPERATION_FORBIDDEN,
|
||||
"read-only masterKey isn't allowed to modify a hook.",
|
||||
req.config
|
||||
);
|
||||
}
|
||||
var body = req.body || {};
|
||||
if (body.__op == 'Delete') {
|
||||
return this.handleDelete(req);
|
||||
|
||||
@@ -341,6 +341,13 @@ export class UsersRouter extends ClassesRouter {
|
||||
req.config
|
||||
);
|
||||
}
|
||||
if (req.auth.isReadOnly) {
|
||||
throw createSanitizedError(
|
||||
Parse.Error.OPERATION_FORBIDDEN,
|
||||
"read-only masterKey isn't allowed to login as another user.",
|
||||
req.config
|
||||
);
|
||||
}
|
||||
|
||||
const userId = req.body?.userId || req.query.userId;
|
||||
if (!userId) {
|
||||
|
||||
Reference in New Issue
Block a user