Skip to content

crypto/tls: weak certificate cache can expose caller-mutated certificate bytes #79863

Description

@jvdprng

Description

The TLS weak certificate cache keys parsed certificates by the DER byte string but stores and returns the parsed *x509.Certificate. If the parsed certificate contains Raw slices that alias caller-owned input, caller mutation after parsing can become visible through later cache hits for the same DER key.

This requires local caller mutation of certificate bytes. It is a fragile API aliasing issue, not a remote attack by itself.

Specification or documentation

This is a Go API/cache behavior issue rather than an external specification violation. Callers generally expect parsed certificate state returned from a cache to be stable for the cached DER value.

Code references

  • go/src/crypto/tls/cache.go:14 defines the weak certificate cache.
  • go/src/crypto/tls/cache.go:19 keys the cache by string(der).
  • go/src/crypto/tls/cache.go:26 parses the certificate.
  • go/src/crypto/tls/cache.go:31 through go/src/crypto/tls/cache.go:39 stores and returns weak pointers to parsed certificate objects.

Test case

This should be a Go unit test only. It can parse through the cache with mutable DER input, mutate the returned certificate's raw bytes or the caller-owned input if aliased, and then assert that a later cache hit returns stable data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions