Skip to content

Commit aeea420

Browse files
fix(eco): Improves domain checking for next URL in installation flow (#113118)
1 parent ba42f29 commit aeea420

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

static/app/components/backendJsonFormAdapter/projectMapperAdapter.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,10 @@ describe('ProjectMapperAdapter', () => {
369369
{
370370
organization: org,
371371
initialRouterConfig: {
372-
location: {pathname: '/', query: {next: 'https://evil.com/steal'}},
372+
location: {
373+
pathname: '/',
374+
query: {next: 'https://vercel.com.evil.example.com/steal'},
375+
},
373376
},
374377
}
375378
);

static/app/components/backendJsonFormAdapter/projectMapperAdapter.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,15 @@ export function ProjectMapperNextButton({config, value}: ProjectMapperNextButton
244244
return null;
245245
}
246246

247-
if (!nextUrl.startsWith(nextButton.allowedDomain)) {
248-
Sentry.captureMessage(`Got invalid next url: ${nextUrl}`);
247+
try {
248+
const parsedUrl = new URL(nextUrl);
249+
const allowedOrigin = new URL(nextButton.allowedDomain).origin;
250+
if (parsedUrl.origin !== allowedOrigin) {
251+
Sentry.captureMessage(`Got invalid next url: ${nextUrl}`);
252+
return null;
253+
}
254+
} catch {
255+
Sentry.captureMessage(`Failed to parse next url: ${nextUrl}`);
249256
return null;
250257
}
251258

0 commit comments

Comments
 (0)