refraction-networking / utls

Fork of the Go standard TLS library, providing low-level access to the ClientHello for mimicry purposes.
BSD 3-Clause "New" or "Revised" License
1.71k stars 247 forks source link

bug: `(*Conn).Handshake()` is called upon `(*UConn).Read()` #291

Closed gaukas closed 7 months ago

gaukas commented 7 months ago

This should be considered a high priority bug.

In crypto/tls, upon calling (*Conn).Read(), (*Conn).Handshake() will be called if TLS handshake is not yet performed.

However, UConn in uTLS did not correctly inherit this behavior. By fully inheriting (*Conn).Read(), it also calls (*Conn).Handshake() instead of (*UConn).Handshake(), where the latter is the function performing a uTLS handshake and the former one performs default crypto/tls handshake.

gaukas commented 7 months ago

This behavior is not restricted to Read(), but also multiple other functions where UConn directly inherits from Conn.

guysv commented 7 months ago

but basically if you explicitly call UConn.Handshake before UConn.Read you're good right?

gaukas commented 7 months ago

but basically if you explicitly call UConn.Handshake before UConn.Read you're good right?

Correct. This issue is more about an inconsistent behavior that when someone switch from crypto/tls to uTLS, where the former does not require an explicit call to Handshake, uTLS may use the default version of handshake if Handshake() is not explicitly called.