Описание
OAuth2 Client Secret Exposed via Unauthenticated JavaScript Endpoint (CWE-200)
Summary
When OAuth2 authentication is enabled for the RabbitMQ Management UI and the configured flow, IDP use
a client secret, the oauth_client_secret configuration value is included in the JavaScript served by the unauthenticated endpoint /js/oidc-oauth/bootstrap.js. Any user who can reach the management UI port can retrieve the OAuth2 client secret without authentication.
Workarounds
One of:
- Avoid using the OAuth 2 flow that needs a client secret
- Disable
rabbitmq_managementand use the Prometheus plugin for monitoring - Switch from
rabbitmq_auth_backend_oauth2to any other authN/authZ backend
Vulnerability Details
Files:
deps/rabbitmq_management/src/rabbit_mgmt_wm_auth.erl, line 186deps/rabbitmq_management/src/rabbit_mgmt_oauth_bootstrap.erl, lines 35-50deps/rabbitmq_management/src/rabbit_mgmt_dispatcher.erl, lines 45-49 (route registration)
Code Path:
- The route
/js/oidc-oauth/bootstrap.jsis registered as a plain Cowboy handler (rabbit_mgmt_dispatcher.erl:46):
- The handler
rabbit_mgmt_oauth_bootstrapdoes NOT implement Cowboy REST'sis_authorized/2callback — it's a plain handler with onlyinit/2(rabbit_mgmt_oauth_bootstrap.erl:35):
bootstrap_oauthcallsrabbit_mgmt_wm_auth:authSettings()and embeds the result in JavaScript (rabbit_mgmt_oauth_bootstrap.erl:40-50):
authSettings()explicitly includesoauth_client_secret(rabbit_mgmt_wm_auth.erl:186):
Attack Scenario
- Administrator configures
management.oauth_client_secret = my-confidential-secretin RabbitMQ config - Any unauthenticated user sends:
GET /js/oidc-oauth/bootstrap.js - Response contains JavaScript:
set_oauth_settings({"oauth_enabled":true,...,"oauth_client_secret":"my-confidential-secret",...}); - Attacker extracts
oauth_client_secretfrom the response
With the client secret, an attacker can:
- Exchange stolen authorization codes for access tokens at the token endpoint
- Impersonate the RabbitMQ management UI to the OAuth2 provider
- Potentially access user data or other resources authorized to the client
- Perform token exchange attacks if the OAuth2 provider supports it
Impact
- Credential exposure for the affected configuration: OAuth2 client secret is accessible without any authentication
- Token theft: Attacker can complete the authorization code flow using stolen authorization codes
- Client impersonation: Attacker can make requests to the OAuth2 provider as the RabbitMQ management UI client
- Scope escalation: If the client has additional scopes beyond what the management UI uses, attacker gains access to those scopes
Affected Configuration
Any RabbitMQ deployment with:
- Management UI enabled (
rabbitmq_managementplugin) - OAuth2 authentication enabled (
management.oauth_enabled = true) management.oauth_client_secretconfigured
Workarounds
One of:
- Switch to different setup or IDP, avoiding client secret flow use entirely
- Disable the
rabbitmq_auth_backend_oauth2plugin and use a different
Steps to Reproduce
- Configure RabbitMQ with OAuth2 for management UI:
- Without authenticating, request:
- Response contains:
Workaround
One of the following:
- Switch to an OAuth 2 flow that does not require a client secret
- Disable
rabbitmq_auth_backend_oauth2and use one of the other supported authN, authZ options
Suggested Fix
Remove oauth_client_secret from the auth settings served to the browser. The management UI is a public client (browser-based SPA) and should use the authorization code flow with PKCE (RFC 7636), which does not require a client secret.
If the oauth_client_secret configuration must be supported for backward compatibility, the rabbit_mgmt_oauth_bootstrap handler should require authentication before including it in the response.
References
- CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
- CWE-522: Insufficiently Protected Credentials
- OAuth 2.0 Security Best Current Practice (RFC 6819) Section 5.3.5: Client secrets must be kept confidential
- OAuth 2.0 for Browser-Based Apps (RFC draft): Public clients should use PKCE instead of client secrets
- Commit tested: a155ee5
Пакеты
rabbitmq
>= 4.3.0, < 4.3.3
4.3.3
rabbitmq
>= 4.2.0, < 4.2.9
4.2.9