Skip to content

Commit 1b4fa4f

Browse files
committed
fix: open redirect vulnerability in completeAuthorization
1 parent b7784c7 commit 1b4fa4f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/oauth-provider.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,6 +2540,20 @@ class OAuthHelpersImpl implements OAuthHelpers {
25402540
* @returns A Promise resolving to an object containing the redirect URL
25412541
*/
25422542
async completeAuthorization(options: CompleteAuthorizationOptions): Promise<{ redirectTo: string }> {
2543+
const { clientId, redirectUri } = options.request;
2544+
2545+
if (!clientId || !redirectUri) {
2546+
throw new Error('Client ID and Redirect URI are required in the authorization request.');
2547+
}
2548+
2549+
// Re-validate the redirectUri to prevent open redirect vulnerabilities
2550+
const clientInfo = await this.lookupClient(clientId);
2551+
if (!clientInfo || !clientInfo.redirectUris.includes(redirectUri)) {
2552+
throw new Error(
2553+
'Invalid redirect URI. The redirect URI provided does not match any registered URI for this client.'
2554+
);
2555+
}
2556+
25432557
// Generate a unique grant ID
25442558
const grantId = generateRandomString(16);
25452559

0 commit comments

Comments
 (0)