Skip to content

Commit bf81938

Browse files
waleedlatif1claude
andcommitted
fix: validate OIDC discovered endpoints against SSRF
The discovery URL itself was SSRF-validated, but endpoint URLs returned in the discovery document (tokenEndpoint, userInfoEndpoint, jwksEndpoint) were stored without validation. A malicious OIDC issuer on a public IP could return internal network URLs in the discovery response. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 44b8aba commit bf81938

File tree

1 file changed

+19
-0
lines changed
  • apps/sim/app/api/auth/sso/register

1 file changed

+19
-0
lines changed

apps/sim/app/api/auth/sso/register/route.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,25 @@ export async function POST(request: NextRequest) {
198198
oidcConfig.userInfoEndpoint = oidcConfig.userInfoEndpoint || discovery.userinfo_endpoint
199199
oidcConfig.jwksEndpoint = oidcConfig.jwksEndpoint || discovery.jwks_uri
200200

201+
// Validate discovered endpoints against SSRF — these are fetched server-side
202+
const endpointsToValidate = [
203+
{ name: 'tokenEndpoint', url: oidcConfig.tokenEndpoint },
204+
{ name: 'userInfoEndpoint', url: oidcConfig.userInfoEndpoint },
205+
{ name: 'jwksEndpoint', url: oidcConfig.jwksEndpoint },
206+
]
207+
for (const { name, url } of endpointsToValidate) {
208+
if (typeof url === 'string') {
209+
const result = await validateUrlWithDNS(url, `OIDC ${name}`)
210+
if (!result.isValid) {
211+
logger.warn(`Discovered OIDC ${name} failed SSRF validation`, {
212+
url,
213+
error: result.error,
214+
})
215+
return NextResponse.json({ error: result.error }, { status: 400 })
216+
}
217+
}
218+
}
219+
201220
logger.info('Merged OIDC endpoints (user-provided + discovery)', {
202221
providerId,
203222
issuer,

0 commit comments

Comments
 (0)