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:
- Initial connection: Custom peer verification runs ✓
- Resumed session: Custom peer verification is skipped ✗
An attacker could potentially exploit this by:
- Establishing a legitimate initial connection (passing custom verification)
- Resuming the session later when the certificate should no longer be valid
- 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
References
Current Status
This issue has been acknowledged and the linter warning is suppressed pending architectural review and decision on the appropriate mitigation strategy.
Security Issue: G123 - TLS Session Resumption Bypass
Location
arrangetls/tls.go:107-PeerVerifiers.SetTo()methodDescription
The
goseclinter reports a G123 warning indicating that usingtls.Config.VerifyPeerCertificatewithout also settingtls.Config.VerifyConnectionmay allow TLS session resumption to bypass custom certificate verification checks.Current Implementation
Security Concern
When TLS session resumption is enabled (the default), the
VerifyPeerCertificatecallback is not invoked for resumed sessions. This means:An attacker could potentially exploit this by:
Recommended Solutions
Option 1: Add VerifyConnection (Go 1.15+)
Set
tls.Config.VerifyConnectionwhich does run on both new and resumed sessions:Option 2: Disable Session Resumption
If session resumption is not needed:
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
References
Current Status
This issue has been acknowledged and the linter warning is suppressed pending architectural review and decision on the appropriate mitigation strategy.