Skip to content

Commit

Permalink
crypto/tls: Fix nil dereference in greased ECH acceptance signal
Browse files Browse the repository at this point in the history
When greasing the ECH acceptance signal in the HRR, the server uses
`c.config.Rand`, which may be `nil`. This prevents the nil dereference
by using `c.config.rand()`, which first checks if `c.config.Rand ==
nil`'.

This bug was found when interop testing with boringSSL.
  • Loading branch information
cjpatton committed Sep 7, 2021
1 parent 808f8fc commit 125d852
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/crypto/tls/handshake_server_tls13.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func (hs *serverHandshakeStateTLS13) doHelloRetryRequest(selectedGroup CurveID)
// "encrypted_client_hello" extension with a payload of 8 random bytes;
// see Section 10.9.4 for details.
helloRetryRequest.ech = make([]byte, 8)
if _, err := io.ReadFull(c.config.Rand, helloRetryRequest.ech); err != nil {
if _, err := io.ReadFull(c.config.rand(), helloRetryRequest.ech); err != nil {
c.sendAlert(alertInternalError)
return fmt.Errorf("tls: internal error: rng failure: %s", err)
}
Expand Down

0 comments on commit 125d852

Please sign in to comment.