PYSEC-2026-35: cryptography has incomplete DNS name constraint enforcement on peer names
cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. Prior to version 46.0.6, DNS name constraints were only validated against SANs within child certificates, and not the "peer name" presented during each validation. Consequently, cryptography would allow a peer named bar.example.com to validate against a wildcard leaf certificate for .example.com, even if the leaf's parent certificate (or upwards) contained an excluded subtree constraint for bar.example.com. This issue has been patched in version 46.0.6.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 46.0.6
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments using cryptography before version 46.0.6 and validating certificate chains with DNS name constraints may be affected. The described bypass requires a wildcard leaf certificate and an ancestor certificate that excludes the peer's DNS name through an excluded subtree constraint.
What does an attacker need to exploit the constraint bypass?
An attacker needs a certificate chain in which a wildcard leaf certificate, such as *.example.com, can match the presented peer name while a parent or higher certificate excludes that specific name, such as bar.example.com. The issue arises because the peer name was not checked against DNS name constraints during validation.
Is the default configuration affected?
The available information does not state whether a default configuration uses DNS name constraints or performs the affected validation flow. Exposure depends on use of cryptography before 46.0.6 with certificate chains containing relevant DNS excluded-subtree constraints.
What remediation is available?
Upgrade cryptography to version 46.0.6 or later. This version patches DNS name-constraint validation so that the peer name is checked.