Skip to content

Security: TLS session resumption may bypass VerifyPeerCertificate checks (G123) #207

Description

@schmidtw

Security Issue: G123 - TLS Session Resumption Bypass

Location

arrangetls/tls.go:107 - PeerVerifiers.SetTo() method

Description

The gosec linter reports a G123 warning indicating that using tls.Config.VerifyPeerCertificate without also setting tls.Config.VerifyConnection may allow TLS session resumption to bypass custom certificate verification checks.

Current Implementation

func (pvs PeerVerifiers) SetTo(tc *tls.Config) {
    if tc != nil && len(pvs.v) > 0 {
        tc.VerifyPeerCertificate = pvs.VerifyPeerCertificate
    }
}

Security Concern

When TLS session resumption is enabled (the default), the VerifyPeerCertificate callback is not invoked for resumed sessions. This means:

  1. Initial connection: Custom peer verification runs ✓
  2. Resumed session: Custom peer verification is skipped

An attacker could potentially exploit this by:

  1. Establishing a legitimate initial connection (passing custom verification)
  2. Resuming the session later when the certificate should no longer be valid
  3. Bypassing the custom verification logic on the resumed session

Recommended Solutions

Option 1: Add VerifyConnection (Go 1.15+)

Set tls.Config.VerifyConnection which does run on both new and resumed sessions:

func (pvs PeerVerifiers) SetTo(tc *tls.Config) {
    if tc != nil && len(pvs.v) > 0 {
        tc.VerifyPeerCertificate = pvs.VerifyPeerCertificate
        tc.VerifyConnection = func(cs tls.ConnectionState) error {
            return pvs.VerifyPeerCertificate(nil, cs.PeerCertificates)
        }
    }
}

Option 2: Disable Session Resumption

If session resumption is not needed:

tc.SessionTicketsDisabled = true
tc.ClientSessionCache = nil

Option 3: Accept the Risk

If session resumption behavior is acceptable (e.g., session lifetime is short, certificate revocation is handled elsewhere), document this decision and suppress the warning.

Impact Assessment Needed

  • Determine if session resumption is currently used/needed
  • Assess security impact based on use cases
  • Review certificate verification requirements
  • Decide on appropriate mitigation strategy

References

Current Status

This issue has been acknowledged and the linter warning is suppressed pending architectural review and decision on the appropriate mitigation strategy.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions