Skip to content

Commit 7f9f854

Browse files
authored
fix: OAuth2 adapter app ID validation sends wrong token to introspection endpoint ([GHSA-69xg-f649-w5g2](GHSA-69xg-f649-w5g2)) (#10187)
1 parent 19a3f05 commit 7f9f854

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

spec/Adapters/Auth/oauth2.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,42 @@ describe('OAuth2Adapter', () => {
337337
);
338338
});
339339

340+
it('should send the correct access token to the introspection endpoint during app ID validation', async () => {
341+
const capturedTokens = [];
342+
const originalFetch = global.fetch;
343+
try {
344+
global.fetch = async (url, options) => {
345+
if (typeof url === 'string' && url === 'https://provider.com/introspect') {
346+
const body = options?.body?.toString() || '';
347+
const token = new URLSearchParams(body).get('token');
348+
capturedTokens.push(token);
349+
return {
350+
ok: true,
351+
json: () => Promise.resolve({
352+
active: true,
353+
sub: 'user123',
354+
aud: 'valid-app-id',
355+
}),
356+
};
357+
}
358+
return originalFetch(url, options);
359+
};
360+
361+
const authData = { access_token: 'myRealAccessToken', id: 'user123' };
362+
const user = await Parse.User.logInWith('mockOauth', { authData });
363+
expect(user.id).toBeDefined();
364+
365+
// With appidField configured, validateAppId and validateAuthData both call requestTokenInfo.
366+
// Both should receive the actual access token, not 'undefined' from argument mismatch.
367+
expect(capturedTokens.length).toBeGreaterThanOrEqual(2);
368+
for (const token of capturedTokens) {
369+
expect(token).toBe('myRealAccessToken');
370+
}
371+
} finally {
372+
global.fetch = originalFetch;
373+
}
374+
});
375+
340376
it('should reject account takeover when useridField is omitted and attacker uses their own token with victim ID', async () => {
341377
await reconfigureServer({
342378
auth: {

src/Adapters/Auth/oauth2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class OAuth2Adapter extends AuthAdapter {
7272
this.authorizationHeader = options.authorizationHeader;
7373
}
7474

75-
async validateAppId(authData) {
75+
async validateAppId(appIds, authData) {
7676
if (!this.appidField) {
7777
return;
7878
}

0 commit comments

Comments
 (0)