Skip to content

crypto/tls: LRU ClientSessionCache inserts nil entries when deleting missing keys #79861

Description

@jvdprng

Description

ClientSessionCache.Put documents that calling Put(key, nil) deletes a cache entry. In the built-in LRU cache, deleting a missing key can insert a nil-valued entry and evict a valid entry when the cache is full.

This only causes cache churn or lost resumption opportunities.

Specification or documentation

This is a Go API documentation issue rather than an external protocol violation. The relevant contract is the crypto/tls.ClientSessionCache.Put documentation for nil states.

Code references

  • go/src/crypto/tls/handshake_client.go:401 through go/src/crypto/tls/handshake_client.go:404 uses Put(cacheKey, nil) to delete expired sessions.
  • go/src/crypto/tls/handshake_client.go:421 through go/src/crypto/tls/handshake_client.go:424 uses the same deletion convention when no valid verified chain remains.
  • go/src/crypto/tls/common.go:395 through go/src/crypto/tls/common.go:398 documents that Put with nil should remove the cache entry.
  • go/src/crypto/tls/common.go:1707 through go/src/crypto/tls/common.go:1734 implements lruSessionCache.Put and lets missing-key nil puts reach the insertion or eviction path.

Test case

This should be a crypto/tls unit test for NewLRUClientSessionCache(1): insert a valid session under one key, call Put("missing", nil), and assert that the existing entry remains and the missing key is not present.

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