From 39501357a5c3f5a8a32ad7c2499b97fa37230b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 14 Nov 2026 07:52:37 +0000 Subject: [PATCH] Stop removing X25519MLKEM768 from reality ClientHello Xray-core v26.9.8 and later REALITY servers reject a ClientHello that has no X25519MLKEM768 key share ahead of X25519 and fall back to the target, so sing-box reality clients failed against them with "reality verification failed". Removing the group and share also made the chrome hello differ from the browser it imitates. Send the fingerprint's key shares unchanged, as Xray-core does. The randomized fingerprint picked the X25519MLKEM768 group and key share with separate coin flips. A group without a share makes post-quantum preferring servers send a HelloRetryRequest, which uTLS cannot answer for X25519MLKEM768 and REALITY cannot relay; a share without the group is rejected by OpenSSL with illegal_parameter. Always offer both. --- common/tls/reality_client.go | 17 ----------------- common/tls/utls_client.go | 2 ++ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/common/tls/reality_client.go b/common/tls/reality_client.go index be4806fe..2ef71854 100644 --- a/common/tls/reality_client.go +++ b/common/tls/reality_client.go @@ -30,7 +30,6 @@ import ( "github.com/sagernet/sing-box/adapter" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/option" - "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/debug" E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/logger" @@ -146,22 +145,6 @@ func (e *RealityClientConfig) ClientHandshake(ctx context.Context, conn net.Conn if err != nil { return nil, err } - for _, extension := range uConn.Extensions { - if ce, ok := extension.(*utls.SupportedCurvesExtension); ok { - ce.Curves = common.Filter(ce.Curves, func(curveID utls.CurveID) bool { - return curveID != utls.X25519MLKEM768 - }) - } - if ks, ok := extension.(*utls.KeyShareExtension); ok { - ks.KeyShares = common.Filter(ks.KeyShares, func(share utls.KeyShare) bool { - return share.Group != utls.X25519MLKEM768 - }) - } - } - err = uConn.BuildHandshakeState() - if err != nil { - return nil, err - } if len(uConfig.NextProtos) > 0 { for _, extension := range uConn.Extensions { diff --git a/common/tls/utls_client.go b/common/tls/utls_client.go index 16d0352d..7c34bff2 100644 --- a/common/tls/utls_client.go +++ b/common/tls/utls_client.go @@ -363,6 +363,8 @@ func init() { weights := utls.DefaultWeights weights.TLSVersMax_Set_VersionTLS13 = 1 weights.FirstKeyShare_Set_CurveP256 = 0 + weights.CurveIDs_Append_X25519 = 1 + weights.KeyShare_Append_RandomGroups = 1 randomizedFingerprint = utls.HelloRandomized randomizedFingerprint.Seed, _ = utls.NewPRNGSeed() randomizedFingerprint.Weights = &weights