Summary
A flaw in TLS Raw Public Key (RPK) handling allows un-negotiated raw public keys to be accepted as if they were X.509 certificates, bypassing normal chain validation and trust checks.
When RPK is compiled in but not properly negotiated, a peer can present a raw public key that is implicitly trusted, creating a high-severity risk in any environment that relies on certificate-based authentication.
Affected context
This vulnerability occurs in TLS deployments built with Raw Public Key (RPK) support enabled (e.g., via broad feature flags such as --enable-all), where peers are expected to use X.509 certificates for authentication.
It manifests when the connection does not explicitly negotiate the use of RPK, yet the implementation still accepts a received raw public key as valid identity material.
The issue is most relevant for systems that rely on certificate chain validation, PKI trust stores, or mutual TLS for strong endpoint authentication.
Exploit preconditions
- Attack surface: TLS handshake between client and server in deployments with RPK support compiled in.
- Required access: Ability to act as or intercept a TLS endpoint (e.g., as a malicious server to a client, or malicious client to a server).
- Trigger point: Presentation of an un-negotiated raw public key in the certificate slot during the handshake where X.509 is implicitly expected.
- Why exploitation is possible: The implementation fails to enforce alignment between negotiated certificate type and received certificate type, so
ParseCertRelative()accepts a raw public key without chain validation or trust verification.
Why this happens
The underlying bug is a logic error in certificate type negotiation and validation, mapping directly to CWE-295: Improper Certificate Validation.
The code path responsible for parsing and validating peer credentials (ParseCertRelative()) does not check whether the raw public key type was actually negotiated before accepting it.
As a result, a raw public key—by definition lacking a certificate chain and associated trust anchors—is treated as a valid credential, bypassing PKI-based verification and undermining the trust model of TLS.
Potential impact
- A malicious server may be trusted by clients without presenting a valid, CA-signed X.509 certificate.
- A malicious client can be accepted in mutual TLS scenarios without possessing a legitimate client certificate.
- TLS connections can appear authenticated while actually lacking proper PKI-based trust validation.
- Man-in-the-middle attacks could be facilitated if an attacker can inject or terminate TLS sessions using raw public keys.
General mitigation guidance
Mitigation focuses on enforcing strict certificate-type negotiation and trust validation.
Recommended patterns include:
- Defaulting the expected certificate type to X.509 when no explicit negotiation occurs, in line with RFC 7250 and RFC 8446.
- Adding checks that compare the negotiated certificate type with the actual type received from the peer and rejecting any mismatch.
- Ensuring that raw public keys are only accepted in contexts where RPK use has been explicitly negotiated and where alternate trust policies (e.g., pre-shared keys or pinned keys) are in place.
- Treating any credential lacking a verifiable trust chain as untrusted unless constrained by a well-defined, minimal trust store or pinning strategy.
- Reviewing build configurations to avoid inadvertently enabling optional credential formats in deployments that expect strict PKI-based authentication.
How teams detect issues like this
Effective detection approaches may combine code-level analysis and runtime inspection:
- Static analysis and code review: Look for certificate parsing paths that bypass or conditionally skip chain validation when handling alternate credential formats such as raw public keys.
- Policy enforcement: Define coding standards that require explicit certificate-type negotiation checks and validation logic for every supported credential type.
- Configuration auditing: Examine build flags and TLS configuration options to identify where RPK or other non-X.509 mechanisms are enabled, and verify that corresponding trust policies exist.
- Automated security testing: Use TLS handshake fuzzing and protocol test suites to verify that un-negotiated certificate types (including RPK) are consistently rejected, and that trust checks trigger as expected.

