Summary
Bouncy Castle for C# contains an improper certificate validation flaw in URI name-constraint processing. A crafted subjectAltName URI may cause the validator to compare constraints against an incorrectly extracted host, potentially allowing a certificate that should be rejected to pass certification path validation.
Bouncy Castle for C# contains an improper certificate validation flaw in URI name-constraint processing. A crafted subjectAltName URI may cause the validator to compare constraints against an incorrectly extracted host, potentially allowing a certificate that should be rejected to pass certification path validation.
Affected context
The issue affects applications using Bouncy Castle's C# PKIX certification path validation with permitted or excluded uniformResourceIdentifier name constraints. Risk is higher when certificate chains include a name-constrained subordinate CA and certificate subjectAltName values are obtained from, or influenced by, an untrusted certificate issuer.
The issue affects applications using Bouncy Castle's C# PKIX certification path validation with permitted or excluded uniformResourceIdentifier name constraints. Risk is higher when certificate chains include a name-constrained subordinate CA and certificate subjectAltName values are obtained from, or influenced by, an untrusted certificate issuer.
Exploit preconditions
- Attack surface: Certificate path validation involving URI name constraints
- Required access: Ability to issue, obtain, or introduce a certificate containing a chosen subjectAltName URI through a name-constrained subordinate CA
- Trigger point: Processing the URI during PKIX name-constraint validation
- Why exploitation is possible: Host extraction relies on string slicing before correctly isolating the RFC 3986 authority component, so characters in URI userinfo, path, query, or fragment data can affect the host value compared with the actual URI authority
- Attack surface: Certificate path validation involving URI name constraints
- Required access: Ability to issue, obtain, or introduce a certificate containing a chosen subjectAltName URI through a name-constrained subordinate CA
- Trigger point: Processing the URI during PKIX name-constraint validation
- Why exploitation is possible: Host extraction relies on string slicing before correctly isolating the RFC 3986 authority component, so characters in URI userinfo, path, query, or fragment data can affect the host value compared with the actual URI authority
Why this happens
The underlying bug is improper validation of certificate identity data under CWE-295: Improper Certificate Validation. The validator derives a host by slicing a URI string without first parsing its authority component according to URI syntax. As a result, delimiter characters such as @ or : can cause the value compared with name constraints to differ from the URI's actual host, weakening the intended certification-path policy.
The underlying bug is improper validation of certificate identity data under CWE-295: Improper Certificate Validation. The validator derives a host by slicing a URI string without first parsing its authority component according to URI syntax. As a result, delimiter characters such as @ or : can cause the value compared with name constraints to differ from the URI's actual host, weakening the intended certification-path policy.
Potential impact
- A certificate that violates permitted or excluded URI name constraints may be accepted
- Applications may establish trust in an unintended certificate subject or endpoint
- TLS, signing, or other certificate-based trust decisions could be weakened
- Downstream authorization or identity checks may rely on a certificate chain that should have been rejected
- A certificate that violates permitted or excluded URI name constraints may be accepted
- Applications may establish trust in an unintended certificate subject or endpoint
- TLS, signing, or other certificate-based trust decisions could be weakened
- Downstream authorization or identity checks may rely on a certificate chain that should have been rejected
General mitigation guidance
Mitigation generally focuses on using a maintained cryptographic validation implementation with standards-compliant URI parsing and certificate constraint handling.
Defensive patterns include:
- Ensure certificate path validation parses URI authority components according to the applicable URI standard before applying constraints
- Prefer safe, standards-conformant library behavior over custom string-based host extraction
- Treat certificate subjectAltName values and subordinate CA issuance policies as untrusted inputs
- Apply explicit constraints on which subordinate CAs may issue certificates and which URI namespaces they may use
- Use least privilege and narrow trust stores for services that perform certificate validation
- Add regression tests covering URI userinfo, port, path, query, and fragment delimiters
Mitigation generally focuses on using a maintained cryptographic validation implementation with standards-compliant URI parsing and certificate constraint handling.
Defensive patterns include:
- Ensure certificate path validation parses URI authority components according to the applicable URI standard before applying constraints
- Prefer safe, standards-conformant library behavior over custom string-based host extraction
- Treat certificate subjectAltName values and subordinate CA issuance policies as untrusted inputs
- Apply explicit constraints on which subordinate CAs may issue certificates and which URI namespaces they may use
- Use least privilege and narrow trust stores for services that perform certificate validation
- Add regression tests covering URI userinfo, port, path, query, and fragment delimiters
How teams detect issues like this
Detection can combine dependency inventory with validation-focused testing and code review.
Useful approaches include:
- Identify uses of affected Bouncy Castle C# components in dependency and software composition inventories
- Review certificate validation code for string slicing or delimiter-based host extraction
- Test permitted and excluded URI name constraints with authority components containing userinfo, ports, paths, queries, and fragments
- Add policy checks requiring standards-compliant URI parsing and rejection of ambiguous certificate identities
- Monitor certificate issuance and chain-validation failures for unexpected URI namespace activity
- Use static analysis or automated code review tools to flag custom certificate validation and URI parsing logic
Detection can combine dependency inventory with validation-focused testing and code review.
Useful approaches include:
- Identify uses of affected Bouncy Castle C# components in dependency and software composition inventories
- Review certificate validation code for string slicing or delimiter-based host extraction
- Test permitted and excluded URI name constraints with authority components containing userinfo, ports, paths, queries, and fragments
- Add policy checks requiring standards-compliant URI parsing and rejection of ambiguous certificate identities
- Monitor certificate issuance and chain-validation failures for unexpected URI namespace activity
- Use static analysis or automated code review tools to flag custom certificate validation and URI parsing logic
Sources
| Source | Link |
|---|---|
| github. | github.com/ |
| github. | github.com/ |

