{"record":{"id":"0c32cf39879ad13d","repo":"XTLS/Xray-core","slug":"the-highest-bit-of-the-last-byte-of-the-peer-sent","errorCode":null,"errorMessage":"the highest bit of the last byte of the peer-sent X25519 public key is not 0","messagePattern":"the highest bit of the last byte of the peer-sent X25519 public key is not 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/vless/encryption/server.go","lineNumber":151,"sourceCode":"\tvar lastCTR cipher.Stream\n\tfor j, k := range i.NfsSKeys {\n\t\tif lastCTR != nil {\n\t\t\tlastCTR.XORKeyStream(relays, relays[:32]) // recover this relay\n\t\t}\n\t\tindex := 32\n\t\tif _, ok := k.(*mlkem.DecapsulationKey768); ok {\n\t\t\tindex = 1088\n\t\t}\n\t\tif i.XorMode > 0 {\n\t\t\tNewCTR(i.NfsPKeysBytes[j], iv).XORKeyStream(relays, relays[:index]) // we don't use buggy elligator2, because we have PSK :)\n\t\t}\n\t\tif k, ok := k.(*ecdh.PrivateKey); ok {\n\t\t\tpublicKey, err := ecdh.X25519().NewPublicKey(relays[:index])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif publicKey.Bytes()[31] > 127 { // we just don't want the observer can change even one bit without breaking the connection, though it has nothing to do with security\n\t\t\t\treturn nil, errors.New(\"the highest bit of the last byte of the peer-sent X25519 public key is not 0\")\n\t\t\t}\n\t\t\tnfsKey, err = k.ECDH(publicKey)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\tif k, ok := k.(*mlkem.DecapsulationKey768); ok {\n\t\t\tvar err error\n\t\t\tnfsKey, err = k.Decapsulate(relays[:index])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\tif j == len(i.NfsSKeys)-1 {\n\t\t\tbreak\n\t\t}\n\t\trelays = relays[index:]\n\t\tlastCTR = NewCTR(nfsKey, iv)","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/vless/encryption/server.go#L133-L169","documentation":"Anti-censorship constraint in ServerInstance.Handshake: for an X25519 relay, the peer-sent public key's final byte has its high bit set (>127). The protocol deliberately rejects such keys (comment: avoiding elligator2 since a PSK exists) to keep the relay bytes indistinguishable from real TLS key shares; a set high bit marks the input as invalid or hostile.","triggerScenarios":"Thrown at proxy/vless/encryption/server.go:151 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as protocol failure: close the connection (possibly a prober or corrupted handshake)","Verify client and server share correct PSK/public key configuration","Ensure client implementations respect the high-bit restriction when crafting relays"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","contentChangedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}