Skip to content

Fail closed when a KeyStore or TrustStore element of Ssl cannot be loaded #4332

Open

Description

@ppkarwasz

When a TrustStore (or KeyStore) element of Ssl cannot be loaded, for example because the file is missing or the password is wrong, TrustStoreConfiguration#createKeyStoreConfiguration throws StoreConfigurationException, PluginBuilder logs an error and returns null for the element, and SslConfiguration#createSSLConfiguration receives null exactly as if the element had been absent. The SSLContext is then initialized with null trust managers, i.e. the JVM default trust store. Independently, SslConfiguration#createSslContext catches any initialization error and falls back to SSLContext.getDefault().

This is not a vulnerability: the configuration is trusted input under the threat model and the failure is reported at ERROR level by the status logger. It is, however, a fail-open behavior for a security-relevant element: a deployer who restricted trust to a private CA ends up with the default trust store after a password rotation or a missing volume mount. This issue originates from a private security report classified as hardening.

Proposal: when a KeyStore or TrustStore child element is present but invalid, the Ssl element should fail to build and the enclosing appender should fail to start. One way is to let the store factories return a configuration object that records the failure instead of throwing, and have SslConfiguration reject it; the default-context fallback in createSslContext should also be removed. This fits the TLS configuration rework tracked in #2792 and #3902.

Reported by @August829

Activity

  1. added this to the 2.27.0 milestone on Sep 21, 2026
  2. ppkarwasz commented on Sep 25, 2026

    @ppkarwasz
    MemberAuthor

    The property-based configuration has the same fail-open behavior, with less noise:
    in SslConfigurationFactory.createSslConfiguration, a failure to create the trust store (or key store) configuration from
    log4j2.trustStore* / log4j2.keyStore* is caught and only logged at WARN
    ("Unable to create trust store configuration due to: …").
    The factory then continues without it and, if neither store could be created, returns null,
    so HTTPS configuration sources silently use the JVM defaults.

    It would make sense to fail closed there too, consistently with the <Ssl> element.

  3. added
    bug
    configuration
    priority: P2
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfigurationpriority: P2

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions