Skip to content

Identity providers (SAML and OIDC) do not validate signatures by default when the setting is absent from the configuration #53713

Open
1 of 4 issues completed

Description

@pedroigor

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

identity-brokering

Describe the bug

Identity providers (both SAML and OIDC) persist configurations where signature validation settings are absent, and the broker implementations treat an absent setting as disabled. The resulting provider accepts unsigned or arbitrarily-signed assertions/tokens, yielding an authenticated session for any existing linked account.

SAML (SAMLIdentityProviderConfig): isValidateSignature() and isWantAssertionsSigned() evaluate Boolean.valueOf(null) → false. SAMLIdentityProviderFactory.create() adds no defaults. Unsigned, dummy-signed, or arbitrarily-signed assertions are accepted.

OIDC (OIDCIdentityProviderConfig): isValidateSignature() evaluates Boolean.parseBoolean(null) → false. When disabled, OIDCIdentityProvider.verify() returns true without verifying the ID token signature, and validateJwt() falls back to the userinfo endpoint. OIDCIdentityProviderFactory.parseOIDCConfig() only enables validation when the discovery document contains a jwks_uri.

Affected provisioning paths:

Additionally, for SAML, when wantAssertionsSigned=true but validateSignature=false (or absent), SAMLEndpoint.handleLoginResponse() only checks that a <ds:Signature> element is present on the assertion, not that it is valid:

boolean signed = AssertionUtil.isSignedElement(assertionElement);
final boolean assertionSignatureNotExistsWhenRequired = config.isWantAssertionsSigned() && !signed;
final boolean signatureNotValid = signed && config.isValidateSignature() && !AssertionUtil.isSignatureValid(assertionElement, getIDPKeyLocator());
final boolean hasNoSignatureWhenRequired = !signed && config.isValidateSignature() && !isMessageFullySigned(holder);

signatureNotValid is gated on isValidateSignature(), so a placeholder signature satisfies wantAssertionsSigned. An administrator who enables only "Want Assertions signed" receives no protection against forged assertions.

What exists so far is spread across separate issues and none of them tracks the server-side defaults: #48717 fixed the SAML Admin Console defaults only (PR #49813: "No server-side or backend defaults are modified"); #48719 is scoped to idpEntityId and explicitly excludes other fields; #48232 is an umbrella framed around Admin UI defaults for SAML; #44473 only couples validateSignature with JWT authorization grant / client assertions for OIDC.

Acknowledgement

This was originally reported by Ilyas to the Keycloak security team. It was later classified as a security hardening. The same defaults were previously discussed in the context of #48717.

Version

26.8.0 (also reproduced on 26.7.4)

Regression

  • The issue is a regression

Expected behavior

Keycloak should be secure by default regardless of the protocol or the provisioning path. When signature validation settings are absent from an identity provider configuration, the server should either:

Disabling signature validation, if still supported, should be an explicit opt-out rather than the implicit default. The OIDC Admin Console should default the Validate signatures switch to enabled, as done for SAML.

For SAML, when wantAssertionsSigned=true, the assertion signature should be cryptographically verified against the IdP signing keys regardless of validateSignature, or the two settings should be coupled so that wantAssertionsSigned=true cannot be persisted with validateSignature=false.

Actual behavior

A SAML or OIDC identity provider created via realm import, Admin REST API, or admin CLI (and, for OIDC, the Admin Console) without explicitly enabling signature validation accepts forged assertions / ID tokens.

For SAML, with wantAssertionsSigned=true and validateSignature=false, an assertion carrying an arbitrary <ds:Signature> element (dummy digest and signature value) is also accepted.

How to Reproduce?

SAML:

  1. Create a SAML IdP via REST without the signature settings:
    POST /admin/realms/{realm}/identity-provider/instances
    {"alias":"saml","providerId":"saml","enabled":true,
     "config":{"singleSignOnServiceUrl":"https://idp.example/sso","nameIDPolicyFormat":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}}
    
  2. Link an existing user to the IdP (federated identity).
  3. Start a broker login and POST a forged, unsigned (or signed with an arbitrary key) SAML Response containing an assertion for the linked user's NameID to the broker endpoint.
  4. Observe the login succeeds and tokens are issued.
  5. Repeat with config.wantAssertionsSigned=true and validateSignature unset, sending an assertion with a placeholder <ds:Signature> element: the login still succeeds.

OIDC:

  1. Create an OIDC IdP via REST (or the Admin Console) without config.validateSignature:
    POST /admin/realms/{realm}/identity-provider/instances
    {"alias":"oidc","providerId":"oidc","enabled":true,
     "config":{"issuer":"https://op.example","authorizationUrl":"https://op.example/auth","tokenUrl":"https://op.example/token","clientId":"kc","clientSecret":"secret"}}
    
  2. Observe the persisted configuration has no validateSignature and OIDCIdentityProviderConfig.isValidateSignature() returns false.
  3. Any ID token returned by the (attacker-controlled or compromised) token endpoint, including one with alg=none or signed by an arbitrary key, is accepted without signature verification.

Controls: setting validateSignature=true rejects a mismatched signer and the placeholder signature; an unlinked identity falls to first-broker-login.

Anything else?

Related settings to review

While the signature validation defaults are the critical part, the same "absent means insecure" pattern applies to other identity provider settings. These are listed here so they can be considered together when deciding on a server-side defaults/validation mechanism (see also #48232 and the kcwarden IdP auditors):

Higher impact (authenticity / integrity)

Setting Current default when absent Notes
OIDC pkceEnabled / pkceMethod false / unset (OAuth2IdentityProviderConfig) RFC 9700 (OAuth 2.0 Security BCP) requires PKCE for the authorization code flow. Default to true + S256.
SAML idpEntityId null → issuer validation skipped (SAMLEndpoint) Tracked in #48719.
SAML wantAuthnRequestsSigned false Unsigned AuthnRequests are treated as anonymous by the IdP; increases exposure to IdP confusion / login CSRF.
SAML postBindingResponse false (HTTP-Redirect) Redirect binding places the response in the URL (logs, Referer, length limits) and was the surface for #53354. POST should be the default.

Defence in depth

Setting Current default when absent Notes
SAML wantAssertionsEncrypted false Mitigates XSW and PII exposure; likely a warning rather than a default since many IdPs do not encrypt.
OIDC clientAuthMethod client_secret_post OIDC Core defaults to client_secret_basic and RFC 6749 §2.3.1 does not recommend credentials in the body; the actual security improvement is asymmetric authentication (private_key_jwt / mTLS) per the OAuth Security BCP. client_secret_basic_unencoded should be considered for deprecation.
syncMode LEGACY / IMPORT Upstream changes (e.g. group removal) never propagate; authorization drift.
OIDC disableNonce, disableTypeClaimCheck false (secure) Already secure; consider deprecating the opt-outs.

Rather than adjusting each *IdentityProviderConfig getter individually, a server-side normalisation/validation step applied on create and import (covering REST, CLI, realm import and the Admin Console uniformly) that fills in secure defaults for absent keys and warns or rejects on explicitly insecure values would address this class of issue.

Sub-issues

Sub-issues

1 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    area/identity-brokering
    on Oct 7, 2026
  2. changed the title [-]SAML Identity Provider created via realm import, Admin REST API or admin CLI does not validate signatures by default[/-] [+]SAML Identity Provider does not validate assertion signatures by default when created via realm import, Admin REST API or admin CLI[/+] on Oct 7, 2026
  3. added
    area/oidc
    area/saml
    on Oct 7, 2026
  4. changed the title [-]SAML Identity Provider does not validate assertion signatures by default when created via realm import, Admin REST API or admin CLI[/-] [+]Identity providers (SAML and OIDC) do not validate signatures by default when the setting is absent from the configuration[/+] on Oct 7, 2026
  5. added theissue type on Oct 8, 2026
  6. self-assigned this
    on Oct 9, 2026
  7. added 2 commits that reference this issue on Oct 13, 2026
    f9d8635
    4d48087
  8. 74 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/identity-brokeringarea/oidcarea/samlkind/weaknessteam/core-iamteam/core-protocols

Fields

No fields configured for weakness.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions