fix(oauth): accept private-use redirect schemes and loopback ports

POST /oauth/register refused every single-label private-use scheme, so an
MCP client registering workbuddy:// could not connect at all, while the
error it got back advertised "a private custom scheme" as supported.

The cause was two validators that had drifted apart, both of which run on
registration. The provider required a dot in the scheme name, which RFC
8252 section 7.1 only recommends and which protected nothing
(javascript.evil:// passed it). The service behind it had no
custom-scheme branch whatsoever and no [::1], which is what actually
answered the reporter's second symptom, and its localhost exemption was
not gated on http:. So javascript://localhost/%0aalert(1), blob:, about:,
ftp: and wss: were all accepted through the settings UI, and the consent
flow assigns the stored URI to window.location.href. Only the CSP stood
between that and a navigation. Both now decide through one policy in
oauth.helpers.ts.

Widening the scheme set means the deny-list has to carry its own weight:
it grows by the browser, extension and OS-handler schemes that were
previously blocked only as a side effect of the dot rule, including
ms-msdt (Follina) and the ms- namespace by prefix. intent: is denied,
because Chrome follows its embedded fallback URL, which turns it into an
open redirect the authorization server cannot inspect.

Fixing registration alone would have moved the reporter's [::1]:{port}
failure one step later: TREK matched redirect URIs byte for byte while
RFC 8252 section 7.3 frees the port for loopback, so a native client on
an OS-assigned port got a 302 to consent and then invalid_redirect_uri.
The matcher now relaxes the port, and only the port, for http loopback.
Stored URIs are never canonicalised, so the %3A round-trips untouched.

Note this tightens POST /api/oauth/clients for inputs it accepts today.
That is the security half of the change and applies at create time only,
so no already-registered client changes behaviour.

Closes #2227
This commit is contained in:
Maurice
2026-09-04 12:15:53 +02:00
committed by Maurice
parent e09c0688ae
commit d77f1c1758
31 changed files with 492 additions and 53 deletions
+2 -1
View File
@@ -172,7 +172,8 @@ const settings: TranslationStrings = {
'settings.oauth.modal.clientName': 'اسم التطبيق',
'settings.oauth.modal.clientNamePlaceholder': 'مثال: Claude Web، تطبيق MCP الخاص بي',
'settings.oauth.modal.redirectUris': 'عناوين URI لإعادة التوجيه',
'settings.oauth.modal.redirectUrisHint': 'عنوان URI واحد لكل سطر. يُطلب HTTPS (localhost مستثنى). يُطبق تطابق دقيق.',
'settings.oauth.modal.redirectUrisHint':
'عنوان URI واحد لكل سطر. يُسمح بـ HTTPS أو HTTP محلي أو مخطط تطبيق خاص (myapp://). يُطبق تطابق دقيق، باستثناء منفذ العنوان المحلي.',
'settings.oauth.modal.scopes': 'النطاقات المسموح بها',
'settings.oauth.modal.scopesHint':
'list_trips وget_trip_summary متاحان دائماً — لا يُطلب نطاق. يساعدان الذكاء الاصطناعي في اكتشاف معرّفات الرحلات.',
+1 -1
View File
@@ -247,7 +247,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URIs de redirecionamento',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Uma URI por linha. HTTPS obrigatório (localhost isento). Correspondência exata.',
'Uma URI por linha. HTTPS, HTTP em loopback ou um esquema de aplicativo próprio (myapp://). Correspondência exata, exceto a porta de uma URI em loopback.',
'settings.oauth.modal.scopes': 'Escopos permitidos',
'settings.oauth.modal.scopesHint':
'list_trips e get_trip_summary estão sempre disponíveis — sem escopo necessário. Permitem à IA descobrir IDs de viagem.',
+1 -1
View File
@@ -142,7 +142,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URIs de redirecció',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Un URI per línia. HTTPS obligatori (localhost exempt). Coincidència exacta.',
'Un URI per línia. HTTPS, HTTP en bucle local o un esquema propi com myapp://. Coincidència exacta, excepte el port en bucle local.',
'settings.oauth.modal.scopes': 'Àmbits permesos',
'settings.oauth.modal.scopesHint':
'list_trips i get_trip_summary sempre estan disponibles — sense àmbit requerit. Permeten a la IA descobrir els IDs de viatge necessaris.',
+1 -1
View File
@@ -156,7 +156,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'Přesměrovací URI',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Jedno URI na řádek. Vyžadováno HTTPS (localhost vyjmuto). Vyžadována přesná shoda.',
'Jedno URI na řádek. HTTPS, HTTP na loopbacku nebo vlastní schéma aplikace (myapp://). Přesná shoda, kromě portu u loopback URI.',
'settings.oauth.modal.scopes': 'Povolená oprávnění',
'settings.oauth.modal.scopesHint':
'list_trips a get_trip_summary jsou vždy dostupné — bez požadovaného oprávnění. Umožňují AI zjistit potřebná ID výletů.',
+1 -1
View File
@@ -160,7 +160,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'Redirect-URIs',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Eine URI pro Zeile. HTTPS erforderlich (localhost ausgenommen). Exakte Übereinstimmung erforderlich.',
'Eine URI pro Zeile. HTTPS, Loopback-HTTP oder ein eigenes App-Schema (myapp://). Exakte Übereinstimmung, außer beim Port einer Loopback-URI.',
'settings.oauth.modal.scopes': 'Erlaubte Berechtigungen',
'settings.oauth.modal.scopesHint':
'list_trips und get_trip_summary sind immer verfügbar — keine Berechtigung nötig. Sie helfen der KI, Trip-IDs zu ermitteln.',
+2 -1
View File
@@ -204,7 +204,8 @@ const settings: TranslationStrings = {
'settings.oauth.modal.clientNamePlaceholder': 'e.g. Claude Web, My MCP App',
'settings.oauth.modal.redirectUris': 'Redirect URIs',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint': 'One URI per line. HTTPS required (localhost exempt). Exact match enforced.',
'settings.oauth.modal.redirectUrisHint':
'One URI per line. HTTPS, loopback HTTP, or a private app scheme (myapp://). Matched exactly, except for the port of a loopback URI.',
'settings.oauth.modal.scopes': 'Allowed Scopes',
'settings.oauth.modal.scopesHint':
'list_trips and get_trip_summary are always available — no scope required. They let the AI discover trip IDs needed to use any other tool.',
+1 -1
View File
@@ -159,7 +159,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URIs de redirección',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Un URI por línea. HTTPS obligatorio (localhost exento). Coincidencia exacta.',
'Un URI por línea. HTTPS, HTTP de bucle local o un esquema propio de la aplicación (myapp://). Coincidencia exacta, excepto el puerto de bucle local.',
'settings.oauth.modal.scopes': 'Ámbitos permitidos',
'settings.oauth.modal.scopesHint':
'list_trips y get_trip_summary siempre están disponibles — sin ámbito requerido. Permiten a la IA descubrir los IDs de viaje necesarios.',
+1 -1
View File
@@ -161,7 +161,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URIs de redirection',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Une URI par ligne. HTTPS requis (localhost exempté). Correspondance exacte.',
'Une URI par ligne. HTTPS, HTTP en boucle locale ou un schéma applicatif privé (myapp://). Correspondance exacte, sauf le port en boucle locale.',
'settings.oauth.modal.scopes': 'Portées autorisées',
'settings.oauth.modal.scopesHint':
"list_trips et get_trip_summary sont toujours disponibles — aucune portée requise. Ils permettent à l'IA de découvrir les IDs de voyage nécessaires.",
+1 -1
View File
@@ -204,7 +204,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'Redirect URIs',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Ένα URI ανά γραμμή. Απαιτείται HTTPS (το localhost εξαιρείται). Επιβάλλεται ακριβής αντιστοίχιση.',
'Ένα URI ανά γραμμή. HTTPS, HTTP σε loopback ή ιδιωτικό σχήμα εφαρμογής (myapp://). Ακριβής αντιστοίχιση, εκτός από τη θύρα σε loopback URI.',
'settings.oauth.modal.scopes': 'Επιτρεπόμενα Scopes',
'settings.oauth.modal.scopesHint':
'Τα list_trips και get_trip_summary είναι πάντα διαθέσιμα — δεν απαιτείται scope. Επιτρέπουν στο AI να εντοπίζει τα trip IDs που χρειάζονται για τη χρήση οποιουδήποτε άλλου εργαλείου.',
+1 -1
View File
@@ -159,7 +159,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'Átirányítási URI-k',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Soronként egy URI. HTTPS szükséges (localhost kivételével). Pontos egyezés szükséges.',
'Soronként egy URI. HTTPS, loopback HTTP vagy saját alkalmazásséma (myapp://). Pontos egyezés, kivéve a loopback URI portját.',
'settings.oauth.modal.scopes': 'Engedélyezett jogosultságok',
'settings.oauth.modal.scopesHint':
'A list_trips és get_trip_summary mindig elérhető — jogosultság nélkül. Segítenek az AI-nak megtalálni az utazás azonosítókat.',
+1 -1
View File
@@ -192,7 +192,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'Redirect URI',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://aplikasiku.com/callback\nhttps://aplikasiku.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Satu URI per baris. HTTPS wajib (localhost dikecualikan). Kecocokan tepat diberlakukan.',
'Satu URI per baris. HTTPS, HTTP loopback, atau skema aplikasi pribadi (myapp://). Kecocokan tepat, kecuali port pada URI loopback.',
'settings.oauth.modal.scopes': 'Cakupan yang Diizinkan',
'settings.oauth.modal.scopesHint':
'list_trips dan get_trip_summary selalu tersedia — tidak perlu cakupan. Keduanya memungkinkan AI menemukan ID perjalanan yang diperlukan untuk menggunakan alat lainnya.',
+1 -1
View File
@@ -159,7 +159,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URI di reindirizzamento',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Un URI per riga. HTTPS richiesto (localhost esente). Corrispondenza esatta richiesta.',
'Un URI per riga. HTTPS, HTTP di loopback o uno schema privato come myapp://. Corrispondenza esatta, tranne la porta di loopback.',
'settings.oauth.modal.scopes': 'Ambiti consentiti',
'settings.oauth.modal.scopesHint':
"list_trips e get_trip_summary sono sempre disponibili — nessun ambito richiesto. Permettono all'IA di scoprire gli ID viaggio necessari.",
+2 -1
View File
@@ -181,7 +181,8 @@ const settings: TranslationStrings = {
'settings.oauth.modal.clientNamePlaceholder': '例:Claude Web',
'settings.oauth.modal.redirectUris': 'リダイレクトURI',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback',
'settings.oauth.modal.redirectUrisHint': '1行につき1つ。HTTPS必須。',
'settings.oauth.modal.redirectUrisHint':
'1行につき1つ。HTTPS、ループバックHTTP、または独自のアプリスキーム(myapp://)が使えます。ループバックURIのポート番号を除き、完全一致が必要です。',
'settings.oauth.modal.scopes': '許可スコープ',
'settings.oauth.modal.scopesHint': 'list_trips と get_trip_summary は常に利用可能です。',
'settings.oauth.modal.selectAll': 'すべて選択',
+2 -1
View File
@@ -192,7 +192,8 @@ const settings: TranslationStrings = {
'settings.oauth.modal.clientNamePlaceholder': '예: Claude Web, My MCP App',
'settings.oauth.modal.redirectUris': '리디렉션 URI',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint': '한 줄에 URI 하나. HTTPS 필수 (localhost 예외). 정확히 일치해야 합니다.',
'settings.oauth.modal.redirectUrisHint':
'한 줄에 URI 하나. HTTPS, 루프백 HTTP 또는 앱 전용 스킴(myapp://)을 쓸 수 있습니다. 루프백 URI의 포트를 빼고 정확히 일치해야 합니다.',
'settings.oauth.modal.scopes': '허용 권한 범위',
'settings.oauth.modal.scopesHint':
'list_trips 및 get_trip_summary는 항상 사용 가능합니다 — 권한 범위 불필요. AI가 다른 도구를 사용하는 데 필요한 여행 ID를 찾을 수 있습니다.',
+1 -1
View File
@@ -158,7 +158,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': "Redirect-URI's",
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Eén URI per regel. HTTPS vereist (localhost uitgezonderd). Exacte overeenkomst vereist.',
'Eén URI per regel. HTTPS, loopback-HTTP of een eigen app-schema (myapp://). Exacte overeenkomst, behalve de poort van een loopback-URI.',
'settings.oauth.modal.scopes': 'Toegestane rechten',
'settings.oauth.modal.scopesHint':
"list_trips en get_trip_summary zijn altijd beschikbaar — geen recht vereist. Ze helpen de AI trip-ID's te ontdekken.",
+1 -1
View File
@@ -154,7 +154,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URI przekierowania',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Jeden URI na linię. Wymagane HTTPS (localhost zwolniony). Wymagana dokładna zgodność.',
'Jeden URI na linię. HTTPS, HTTP na loopbacku lub własny schemat aplikacji (myapp://). Dokładna zgodność, z wyjątkiem portu w URI loopback.',
'settings.oauth.modal.scopes': 'Dozwolone uprawnienia',
'settings.oauth.modal.scopesHint':
'list_trips i get_trip_summary są zawsze dostępne — bez wymaganych uprawnień. Umożliwiają AI odkrycie potrzebnych ID podróży.',
+1 -1
View File
@@ -157,7 +157,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URI перенаправления',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Один URI на строку. Требуется HTTPS (localhost исключён). Требуется точное совпадение.',
'Один URI на строку. HTTPS, локальный HTTP или собственная схема приложения (myapp://). Требуется точное совпадение, кроме порта локального URI.',
'settings.oauth.modal.scopes': 'Разрешённые области доступа',
'settings.oauth.modal.scopesHint':
'list_trips и get_trip_summary всегда доступны — область не требуется. Они помогают ИИ находить нужные ID поездок.',
+1 -1
View File
@@ -200,7 +200,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'Omdirigerings-URI:er',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://din-app.com/callback\nhttps://din-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'En URI per rad. HTTPS krävs (med undantag för localhost). Exakt matchning krävs.',
'En URI per rad. HTTPS, loopback-HTTP eller ett eget app-schema (myapp://). Exakt matchning, utom porten i en loopback-URI.',
'settings.oauth.modal.scopes': 'Tillåtna tillämpningsområden',
'settings.oauth.modal.scopesHint':
'list_trips och get_trip_summary är alltid tillgängliga – inget tillämpningsområden krävs. De gör det möjligt för AI:n att hämta de res-ID:n som behövs för att använda andra verktyg.',
+1 -1
View File
@@ -195,7 +195,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': "URI'leri Yönlendir",
'settings.oauth.modal.redirectUrisPlaceholder': 'https://uygulamaniz.com/callback\\nhttps://uygulamaniz.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Satır başına bir URI. HTTPS gerekli (yerel ana bilgisayar hariç). Tam eşleşme uygulandı.',
'Satır başına bir URI. HTTPS, geri döngü HTTP veya kendi uygulama şeması (myapp://). Geri döngü URI portu dışında tam eşleşme gerekir.',
'settings.oauth.modal.scopes': 'İzin Verilen Kapsamlar',
'settings.oauth.modal.scopesHint':
'list_trips ve get_trip_summary her zaman kullanılabilir; kapsam gerektirmez. Yapay zekanın başka herhangi bir aracı kullanmak için gereken yolculuk kimliklerini keşfetmesine olanak tanıyorlar.',
+1 -1
View File
@@ -159,7 +159,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URI перенаправлення',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Один URI на рядок. Потрібен HTTPS (localhost виключено). Потрібне точне співпадіння.',
'Один URI на рядок. HTTPS, локальний HTTP або власна схема застосунку (myapp://). Потрібне точне співпадіння, окрім порту локального URI.',
'settings.oauth.modal.scopes': 'Дозволені області доступу',
'settings.oauth.modal.scopesHint':
'list_trips і get_trip_summary завжди доступні — область не потрібна. Вони допомагають ШІ знаходити потрібні ID поїздок.',
+1 -1
View File
@@ -201,7 +201,7 @@ const settings: TranslationStrings = {
'settings.oauth.modal.redirectUris': 'URI chuyển hướng',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint':
'Một URI trên mỗi dòng. Yêu cầu HTTPS (miễn trừ localhost). Đối sánh chính xác được thực thi.',
'Một URI trên mỗi dòng. HTTPS, HTTP loopback hoặc lược đồ ứng dụng riêng (myapp://). Đối sánh chính xác, ngoại trừ cổng của URI loopback.',
'settings.oauth.modal.scopes': 'Phạm vi được phép',
'settings.oauth.modal.scopesHint':
'list_trips và get_trip_summary luôn có sẵn — không yêu cầu phạm vi. Họ cho phép AI khám phá ID chuyến đi cần thiết để sử dụng bất kỳ công cụ nào khác.',
+2 -1
View File
@@ -182,7 +182,8 @@ const settings: TranslationStrings = {
'settings.oauth.modal.clientNamePlaceholder': '例如 Claude Web、我的 MCP 應用程式',
'settings.oauth.modal.redirectUris': '重新導向 URI',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint': '每行一個 URI。需要 HTTPS(localhost 除外)。需要完全符合。',
'settings.oauth.modal.redirectUrisHint':
'每行一個 URI。支援 HTTPS、回送 HTTP 或自訂應用程式協定(myapp://)。需要完全符合,回送 URI 的連接埠除外。',
'settings.oauth.modal.scopes': '允許的授權範圍',
'settings.oauth.modal.scopesHint':
'list_trips 和 get_trip_summary 始終可用——不需要授權範圍。它們可幫助 AI 找到所需的行程 ID。',
+2 -1
View File
@@ -147,7 +147,8 @@ const settings: TranslationStrings = {
'settings.oauth.modal.clientNamePlaceholder': '例如 Claude Web、我的 MCP 应用',
'settings.oauth.modal.redirectUris': '重定向 URI',
'settings.oauth.modal.redirectUrisPlaceholder': 'https://your-app.com/callback\nhttps://your-app.com/auth',
'settings.oauth.modal.redirectUrisHint': '每行一个 URI。需要 HTTPS(localhost 除外)。要求精确匹配。',
'settings.oauth.modal.redirectUrisHint':
'每行一个 URI。支持 HTTPS、回环 HTTP 或自定义应用协议(myapp://)。要求精确匹配,回环 URI 的端口除外。',
'settings.oauth.modal.scopes': '允许的权限范围',
'settings.oauth.modal.scopesHint':
'list_trips 和 get_trip_summary 始终可用——无需权限范围。它们帮助 AI 发现所需的行程 ID。',