/

CVE-2026-42790

Severity:

HIGH RISK

(8.1)

Improper TLS Certificate Hostname Validation (CWE-295) in Erlang OTP public_key

CVE-2026-42790

Modified

Vulnerability type

Category:

Improper Certificate Validation

CWE:

CWE-295, CWE-297

Impact:

TLS Identity Spoofing / Authentication Bypass

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Erlang/OTP's public_key certificate handling implements TLS hostname verification in a way that allows DNS nameConstraints on an intermediate CA to be bypassed using a Common Name–only leaf certificate.

By omitting subjectAltName DNS entries and relying on Common Name fallback, a constrained subordinate CA can issue certificates that OTP TLS clients may accept for hostnames outside the permitted DNS subtree.

Affected context

The issue arises in Erlang/OTP systems that use the ssl application with peer verification enabled and rely on the public_key library for X.509 path validation and hostname checking.

It specifically impacts TLS client scenarios where:

  • The remote endpoint presents a certificate chain anchored in a trusted CA store
  • An intermediate CA is restricted with DNS nameConstraints
  • Hostname verification is performed using public_key:pkix_verify_hostname/3 or the standard strict HTTPS matcher

In these contexts, a CN-only leaf certificate can be accepted as a valid identity for a hostname that should be outside the constrained DNS namespace.

Exploit preconditions

  • Attack surface: TLS client connections in Erlang/OTP using ssl:connect/3 (or similar) with verify_peer enabled and hostname verification based on public_key:pkix_verify_hostname/3.
  • Required attacker capability: Ability to obtain or control issuance from a subordinate CA that is constrained by DNS nameConstraints but is otherwise trusted by the client's CA store. This may stem from CA mis-issuance, compromise, or malicious operation of a constrained CA.
  • Certificate characteristics: The attacker can issue a leaf certificate:
  • Chained to a DNS-constrained intermediate (e.g., permitted;DNS:allowed.example.com)
  • With no subjectAltName DNS entries
  • With a subject Common Name set to an out-of-scope target hostname (e.g., victim.example.com).
  • Trigger point: When the Erlang/OTP TLS client performs:
  1. Path validation via pubkey_cert:validate_names/6 (nameConstraints check only SAN DNS entries)
  2. Hostname verification via public_key:pkix_verify_hostname/3, which falls back to the subject CN.
  • Why exploitation is possible:
  • DNS nameConstraints are only applied to SAN DNS names; a certificate with no SAN is treated as unconstrained.
  • Hostname verification still accepts the CN as a presented identity, even under strict HTTPS match mode.
  • Combined, these behaviors allow a constrained CA to effectively mint certificates for arbitrary external hostnames that OTP clients will treat as valid.

Why this happens

The vulnerability is rooted in two interacting certificate validation behaviors:

  1. Partial enforcement of DNS nameConstraints: The function pubkey_cert:validate_names/6 only evaluates DNS nameConstraints against DNS-typed entries in the subjectAltName extension. In practice this means:
  • If a leaf certificate contains SAN DNS names, they are correctly constrained by permitted/excluded DNS subtrees.
  • If a leaf certificate omits SAN entirely, the DNS nameConstraints logic is not triggered at all, even though the certificate is issued by a constrained intermediate CA.

This reflects an incomplete implementation of RFC 5280 semantics and maps to CWE-297: Improper Validation of Certificate with Host Mismatch, because constraints intended to restrict namespace delegation do not fully apply.

  1. Common Name fallback for hostname verification: The function public_key:pkix_verify_hostname/3, including the strict pkix_verify_hostname_match_fun(https) mode, falls back to extracting id-at-commonName attributes from the subject distinguished name when no subjectAltName is present. It then matches the reference hostname against the CN value.

This CN fallback undermines the intended role of SAN as the canonical place for DNS identities and leads to CWE-295: Improper Certificate Validation, because the client accepts an identity source (CN) that bypasses the DNS nameConstraints enforcement.

Taken together, these design choices create an abstract bug pattern where:

  • Namespace constraints are only applied to one identity channel (SAN DNS), while
  • Hostname matching still trusts an alternate channel (CN) that is not constrained.

This discrepancy between constraint enforcement and identity selection enables identity spoofing within TLS, despite apparently correct use of strict verification APIs.

Potential impact

  • An attacker controlling or abusing a constrained subordinate CA could have their certificates accepted for hostnames outside the permitted DNS subtree.
  • Erlang/OTP TLS clients may establish seemingly secure HTTPS or TLS connections to an attacker-controlled endpoint, believing it to be the legitimate target host.
  • Confidential data in transit (credentials, session tokens, API keys) could be intercepted or modified by a man-in-the-middle attacker.
  • Service-to-service authentication relying on certificate-based identity could be bypassed, enabling lateral movement or impersonation of internal services.
  • Security assumptions around "restricted" or partitioned PKI hierarchies may be invalidated, weakening zero-trust or micro-segmentation designs that rely on strict nameConstraints.

General mitigation guidance

Mitigations focus on aligning hostname verification with modern PKI best practices and ensuring that namespace constraints apply consistently to all identity sources:

  • Prefer SAN-based identity exclusively: Treat subjectAltName as the only authoritative source of DNS identities. Avoid CN fallback in hostname validation logic and ensure verification routines reject CN-only certificates by default for DNS hostnames.
  • Harden nameConstraints enforcement: Ensure that DNS nameConstraints semantics are applied in a way that prevents constrained intermediates from issuing usable certificates without properly constrained identities. This may include:
  • Treating CN DNS names as subject to DNS constraints if they are ever used.
  • Or better, rejecting certificates that lack SAN when constraints are present and DNS-based identities are expected.
  • Adopt stricter hostname verification policies: Where possible, configure or wrap TLS stacks so that:
  • Only SAN DNS names are considered for hostname verification.
  • CN is ignored for DNS-name matching, especially when strict verification is requested.
  • Reduce trust in broadly or loosely constrained CAs: Architect systems so that:
  • Critical services rely on private or dedicated CAs with narrowly scoped trust.
  • Constrained intermediates are not relied upon as the sole mechanism for segregating namespaces.
  • Defense-in-depth at the application layer: Complement TLS-level checks with:
  • Explicit verification that the certificate's SAN matches expected host or service names.
  • Additional authorization checks (e.g., service identity claims, mTLS SPIFFE IDs, or application-level tokens) before granting access.

How teams detect issues like this

Detection efforts can aim both at code-level patterns and at operational certificate usage:

  • Static analysis and code review:
  • Identify all uses of public_key:pkix_verify_hostname/3 and ssl:connect/3 with verify_peer, and check how hostname verification is configured.
  • Flag any logic that falls back to subject Common Name for DNS hostname matching, especially in "strict" modes.
  • Review implementations of certificate path validation and nameConstraints handling (e.g., pubkey_cert:validate_names/6) to ensure that constraints are consistently applied to all identity sources.
  • Policy and configuration checks:
  • Enforce secure TLS configurations through centralized policy (e.g., internal guidelines or linters) that mandate SAN-only verification for DNS names.
  • Use CI/CD checks or code owners to review changes to TLS configuration or PKI validation logic.
  • Runtime monitoring and PKI hygiene:
  • Periodically scan issued certificates (both internal and external) to detect:
  • CN-only certificates used in production.
  • Certificates issued by constrained intermediates with CN values outside the permitted DNS subtree.
  • Monitor TLS traffic metadata (e.g., via TLS inspection in controlled environments or connection logs) to identify sessions where CN-only certificates are accepted.
  • Automated tooling:
  • Leverage PKI linting tools and certificate analyzers to detect non-compliant certificates and misapplied nameConstraints.
  • Integrate security scanners or SAST tools (where available) that know about CN fallback and improper certificate validation patterns.

Sources

SourceLink
cna.erlef.orgcna.erlef.org/cves/CVE-2026-42790.html
github.comgithub.com/erlang/otp/commit/0769050c69d73762672b0db1347b6993a5b31759
github.comgithub.com/erlang/otp/commit/21abed64eb2026b5f82f432709e4e932f9be389a
github.comgithub.com/erlang/otp/commit/fb67c6d1836f51105a96d8b769e71e4215a79457
github.comgithub.com/erlang/otp/security/advisories/GHSA-22cw-4ph4-6447
osv.devosv.dev/vulnerability/EEF-CVE-2026-42790
erlang.orgerlang.org/doc/system/versions.html#order-of-versions
access.redhat.comaccess.redhat.com/errata/RHSA-2026:39809
access.redhat.comaccess.redhat.com/errata/RHSA-2026:54757
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-42790
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2482286
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-42790.json

Frequently asked

questions

Exploitability depends on the attacker's ability to obtain or influence certificates from a DNS-constrained intermediate CA that is trusted by the Erlang/OTP client. In environments where such intermediates exist (e.g., enterprise PKIs, delegated public CAs, or service mesh CAs) and clients rely on OTP for TLS, the issue can meaningfully expand the attacker's ability to impersonate services or domains.

The attacker must be able to present the crafted certificate chain to the Erlang/OTP TLS client. This typically implies at least network-level position (e.g., man-in-the-middle on a client–server connection) or control of an endpoint that the client connects to. In addition, they need the capability to obtain CN-only leaf certificates from a constrained intermediate that the client trusts.

The most robust pattern is to:

  • Enforce SAN-only hostname verification for DNS names.
  • Remove or disable Common Name fallback in verification logic.
  • Ensure that when nameConstraints are present, certificates without SAN that are intended for DNS-based identities are rejected rather than silently treated as unconstrained.

These changes align clients with modern PKI guidance and prevent constrained CAs from being used outside their intended namespace.

Prevention involves both design and process measures:

  • Design TLS validation layers around explicit, up-to-date standards (e.g., RFC 6125) that favor SAN and deprecate CN for DNS identities.
  • Treat certificate validation as a centralized, reusable component rather than reimplementing hostname checks separately.
  • Incorporate security reviews and automated tests that cover edge cases like nameConstraints, SAN vs. CN precedence, and strict verification modes.
  • Continuously monitor PKI changes and security advisories for the TLS libraries in use, updating validation logic as standards evolve.
Find out what's already
exploitable in your codebase.