Skip to content

Commit 77a1f75

Browse files
waleedlatif1claude
andcommitted
fix(sap_s4hana): ignore tokenUrl on cloud_public to prevent UAA redirection
Why: resolveTokenUrl previously honored caller-supplied tokenUrl regardless of deploymentType, mirroring the same redirection class as the prior baseUrl bug. A cloud_public caller could send tokenUrl to an attacker host, causing the proxy to POST clientId:clientSecret as Basic auth to it. superRefine for cloud_public did not validate tokenUrl. Fix: derive UAA URL from subdomain+region for cloud_public; only honor tokenUrl for cloud_private/on_premise (already SSRF-checked). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d02d946 commit 77a1f75

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • apps/sim/app/api/tools/sap_s4hana/proxy

apps/sim/app/api/tools/sap_s4hana/proxy/route.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,13 @@ function assertSafeExternalUrl(rawUrl: string, label: string): URL {
281281
}
282282

283283
function resolveTokenUrl(req: ProxyRequest): string {
284-
if (req.tokenUrl) return req.tokenUrl
285-
return `https://${req.subdomain}.authentication.${req.region}.hana.ondemand.com/oauth/token`
284+
if (req.deploymentType === 'cloud_public') {
285+
return `https://${req.subdomain}.authentication.${req.region}.hana.ondemand.com/oauth/token`
286+
}
287+
if (!req.tokenUrl) {
288+
throw new Error('tokenUrl is required for OAuth on cloud_private/on_premise')
289+
}
290+
return req.tokenUrl
286291
}
287292

288293
function tokenCacheKey(req: ProxyRequest): string {

0 commit comments

Comments
 (0)