/

CVE-2026-63577

Severity:

HIGH RISK

(7.5)

Name Constraint Bypass (CWE-295) in Bouncy Castle C#

CVE-2026-63577

Analyzed

Vulnerability type

Category:

Improper Certificate Validation

CWE:

CWE-295

Impact:

Certificate validation bypass and unauthorized identity acceptance

Severity:

HIGH RISK

(7.5)

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

A certificate-validation flaw in Bouncy Castle for C# can incorrectly accept a certificate whose directoryName falls outside the permitted subtree defined by a name-constrained intermediate CA. An attacker who controls such an intermediate CA, or can obtain certificates from it, may bypass intended PKIX name restrictions and have an unauthorized certificate accepted during path validation.

A certificate-validation flaw in Bouncy Castle for C# can incorrectly accept a certificate whose directoryName falls outside the permitted subtree defined by a name-constrained intermediate CA. An attacker who controls such an intermediate CA, or can obtain certificates from it, may bypass intended PKIX name restrictions and have an unauthorized certificate accepted during path validation.

Affected context

The issue occurs in Bouncy Castle C# deployments that perform PKIX certificate path validation with directoryName name constraints and use the affected PkixNameConstraintValidator.WithinDNSubtree logic. It can affect validation of subject distinguished names or directoryName subject alternative names when a constrained intermediate CA is involved and the certificate name contains additional RDNs before a copy of the permitted sequence.

The issue occurs in Bouncy Castle C# deployments that perform PKIX certificate path validation with directoryName name constraints and use the affected PkixNameConstraintValidator.WithinDNSubtree logic. It can affect validation of subject distinguished names or directoryName subject alternative names when a constrained intermediate CA is involved and the certificate name contains additional RDNs before a copy of the permitted sequence.

Exploit preconditions

  • Attack surface: Applications or services that validate X.509 certificate chains using Bouncy Castle C#.
  • Required access: Control of a name-constrained intermediate CA, or the ability to obtain certificates issued by one.
  • Trigger point: PKIX path validation of a certificate containing a subject distinguished name or directoryName subject alternative name.
  • Why exploitation is possible: The validator may locate the first permitted RDN sequence within a name rather than requiring it to be the name's initial prefix, allowing an out-of-scope name to satisfy the constraint.
  • Attack surface: Applications or services that validate X.509 certificate chains using Bouncy Castle C#.
  • Required access: Control of a name-constrained intermediate CA, or the ability to obtain certificates issued by one.
  • Trigger point: PKIX path validation of a certificate containing a subject distinguished name or directoryName subject alternative name.
  • Why exploitation is possible: The validator may locate the first permitted RDN sequence within a name rather than requiring it to be the name's initial prefix, allowing an out-of-scope name to satisfy the constraint.

Why this happens

The underlying bug is improper certificate validation in the directoryName name-constraint comparison. Instead of enforcing the RFC 5280 requirement that the permitted relative distinguished name sequence appear as the required initial prefix, the validator searches for the constraint's first RDN elsewhere in the name and compares subsequent RDNs from that position. This insecure comparison can treat a name outside the permitted subtree as valid, mapping to CWE-295: Improper Certificate Validation.

The underlying bug is improper certificate validation in the directoryName name-constraint comparison. Instead of enforcing the RFC 5280 requirement that the permitted relative distinguished name sequence appear as the required initial prefix, the validator searches for the constraint's first RDN elsewhere in the name and compares subsequent RDNs from that position. This insecure comparison can treat a name outside the permitted subtree as valid, mapping to CWE-295: Improper Certificate Validation.

Potential impact

  • A certificate outside an intermediate CA's permitted namespace may be accepted.
  • Applications may authenticate an unauthorized subject or service.
  • TLS, signing, or identity-assurance decisions could be weakened.
  • Trust boundaries relying on name constraints may be bypassed.
  • Downstream systems could be exposed to impersonation or policy circumvention.
  • A certificate outside an intermediate CA's permitted namespace may be accepted.
  • Applications may authenticate an unauthorized subject or service.
  • TLS, signing, or identity-assurance decisions could be weakened.
  • Trust boundaries relying on name constraints may be bypassed.
  • Downstream systems could be exposed to impersonation or policy circumvention.

General mitigation guidance

Mitigation generally focuses on using certificate-validation logic that strictly implements RFC 5280 name-constraint semantics and rejects directoryName values that do not begin with the permitted RDN sequence.

Defensive patterns include:

  • Use maintained validation components that correctly enforce name constraints.
  • Treat certificate names and intermediate CA relationships as untrusted inputs.
  • Apply independent policy checks for expected identities, namespaces, and certificate purposes.
  • Limit trust in intermediate CAs and issue certificates only within explicitly authorized namespaces.
  • Fail closed when name-constraint parsing or comparison is ambiguous.
  • Keep certificate-validation dependencies governed by security review and dependency-management policies.

Mitigation generally focuses on using certificate-validation logic that strictly implements RFC 5280 name-constraint semantics and rejects directoryName values that do not begin with the permitted RDN sequence.

Defensive patterns include:

  • Use maintained validation components that correctly enforce name constraints.
  • Treat certificate names and intermediate CA relationships as untrusted inputs.
  • Apply independent policy checks for expected identities, namespaces, and certificate purposes.
  • Limit trust in intermediate CAs and issue certificates only within explicitly authorized namespaces.
  • Fail closed when name-constraint parsing or comparison is ambiguous.
  • Keep certificate-validation dependencies governed by security review and dependency-management policies.

How teams detect issues like this

Detection approaches can include:

  • Static analysis and dependency review for certificate-validation libraries and name-constraint implementations.
  • Code review checks for substring, search-based, or position-insensitive comparisons of distinguished-name components.
  • Unit and integration tests containing valid prefixes, invalid prefixes, reordered RDNs, and names with additional leading RDNs.
  • Certificate-path testing that verifies both permitted and excluded directoryName subtrees.
  • Runtime monitoring for unexpected certificate subjects, issuers, or namespace relationships.
  • Policy enforcement requiring approved validation libraries and negative certificate-validation test coverage.

Detection approaches can include:

  • Static analysis and dependency review for certificate-validation libraries and name-constraint implementations.
  • Code review checks for substring, search-based, or position-insensitive comparisons of distinguished-name components.
  • Unit and integration tests containing valid prefixes, invalid prefixes, reordered RDNs, and names with additional leading RDNs.
  • Certificate-path testing that verifies both permitted and excluded directoryName subtrees.
  • Runtime monitoring for unexpected certificate subjects, issuers, or namespace relationships.
  • Policy enforcement requiring approved validation libraries and negative certificate-validation test coverage.

Sources

SourceLink
github.comgithub.com/bcgit/bc-csharp/commit/606e9153b97a265c70ca8293d21ec859344d7de8
github.comgithub.com/bcgit/bc-csharp/commit/75c3c576602886180ed92a63c89419e3bd63b392
github.comgithub.com/bcgit/bc-csharp/wiki/CVE-2026-63577

Frequently asked

questions

It may be exploitable through certificate-based network interactions when a vulnerable validator processes a certificate chain containing a malicious or improperly scoped certificate. Exploitability depends on the application accepting the affected certificate path and the attacker controlling, or obtaining certificates from, a relevant intermediate CA.

No. The described condition centers on a name-constrained intermediate CA. The attacker generally needs control of that intermediate or the ability to obtain a certificate from it, rather than direct control of the trust anchor.

Use certificate-validation logic that requires the permitted RDN sequence to be the correct initial prefix and that follows RFC 5280 name-constraint rules. Validation should fail closed for malformed or ambiguous names.

Combine dependency governance with adversarial certificate-path tests, explicit identity-policy checks, restricted intermediate-CA trust, and code review for position-insensitive distinguished-name comparisons.

It may be exploitable through certificate-based network interactions when a vulnerable validator processes a certificate chain containing a malicious or improperly scoped certificate. Exploitability depends on the application accepting the affected certificate path and the attacker controlling, or obtaining certificates from, a relevant intermediate CA.

No. The described condition centers on a name-constrained intermediate CA. The attacker generally needs control of that intermediate or the ability to obtain a certificate from it, rather than direct control of the trust anchor.

Use certificate-validation logic that requires the permitted RDN sequence to be the correct initial prefix and that follows RFC 5280 name-constraint rules. Validation should fail closed for malformed or ambiguous names.

Combine dependency governance with adversarial certificate-path tests, explicit identity-policy checks, restricted intermediate-CA trust, and code review for position-insensitive distinguished-name comparisons.

Find out what's already
exploitable in your codebase.