fix(32.2): WR-06 check the consent provider's redirect against the request's redirect URI
cabana loads the pending request on both decisions and refuses (500) a Decide answer whose scheme, user info, host, path or opaque part differ from the registered redirect URI. The admin SPA also refuses blob:, file:, about: and filesystem: and a destination that does not return to the host the consent card showed. Regenerated the admin OpenAPI document and rebuilt modules/boardwalk/dist.
This commit is contained in:
2
admin/src/api/schema.d.ts
vendored
2
admin/src/api/schema.d.ts
vendored
@@ -1705,7 +1705,7 @@ export interface paths {
|
||||
put?: never;
|
||||
/**
|
||||
* Allow or deny an MCP consent request
|
||||
* @description Allows or denies a pending MCP authorization request for the signed-in admin and answers the client redirect URI. Submitted scopes that were not requested or that the admin cannot grant are dropped, * collapses as for personal tokens, and 422 no_grantable_scopes answers when nothing is left. Needs X-Requested-With; the body is capped at 16 KiB and unknown fields are refused (400). Personal API tokens are refused (403 interactive_only).
|
||||
* @description Allows or denies a pending MCP authorization request for the signed-in admin and answers the client redirect URI. Submitted scopes that were not requested or that the admin cannot grant are dropped, * collapses as for personal tokens, and 422 no_grantable_scopes answers when nothing is left. Both decisions load the request first; a provider redirect that does not go back to the request's redirect URI (same scheme, host and path) is refused (500). Needs X-Requested-With; the body is capped at 16 KiB and unknown fields are refused (400). Personal API tokens are refused (403 interactive_only).
|
||||
*/
|
||||
post: {
|
||||
parameters: {
|
||||
|
||||
@@ -188,7 +188,41 @@ function scopeDisabled(name: string): boolean {
|
||||
return starChecked.value && name !== '*'
|
||||
}
|
||||
|
||||
/** The server-issued redirect, refused when its scheme could run script (T-32.2-09). */
|
||||
/** Schemes a consent redirect never uses: script, inline content and local files. */
|
||||
const FORBIDDEN_PROTOCOLS = new Set(['javascript:', 'data:', 'vbscript:', 'blob:', 'file:', 'about:', 'filesystem:'])
|
||||
|
||||
/**
|
||||
* Whether url returns to the place the consent screen showed: the
|
||||
* redirect host (with its port) for a URI with a host, or the URI without
|
||||
* query and fragment for one without (a custom scheme). Both sides go
|
||||
* through the URL parser, so case and default ports compare as the browser
|
||||
* sees them.
|
||||
*/
|
||||
function returnsTo(url: URL, host: string): boolean {
|
||||
if (host === '') {
|
||||
return false
|
||||
}
|
||||
try {
|
||||
if (url.host !== '') {
|
||||
return new URL(`${url.protocol}//${host}`).host === url.host
|
||||
}
|
||||
const want = new URL(host)
|
||||
const got = new URL(url.href)
|
||||
for (const u of [want, got]) {
|
||||
u.search = ''
|
||||
u.hash = ''
|
||||
}
|
||||
return want.href === got.href
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The server-issued redirect, refused when its scheme could run script or
|
||||
* open local content, or when it leaves for another place than the one the
|
||||
* screen named (T-32.2-09).
|
||||
*/
|
||||
function safeDestination(uri: string): string | null {
|
||||
let url: URL
|
||||
try {
|
||||
@@ -196,7 +230,7 @@ function safeDestination(uri: string): string | null {
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
if (url.protocol === 'javascript:' || url.protocol === 'data:' || url.protocol === 'vbscript:') {
|
||||
if (FORBIDDEN_PROTOCOLS.has(url.protocol) || !returnsTo(url, redirectHost.value)) {
|
||||
return null
|
||||
}
|
||||
return uri
|
||||
|
||||
Reference in New Issue
Block a user