{"record":{"id":"68a55877b379b5c5","repo":"XTLS/Xray-core","slug":"replay-detected","errorCode":null,"errorMessage":"replay detected","messagePattern":"replay detected","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/vless/encryption/server.go","lineNumber":224,"sourceCode":"\t\tticket, err := nfsAEAD.Open(nil, nil, encryptedTicket, nil)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ti.RWLock.RLock()\n\t\ts := i.Sessions[[16]byte(ticket)]\n\t\ti.RWLock.RUnlock()\n\t\tif s == nil {\n\t\t\tnoises := make([]byte, crypto.RandBetween(1279, 2279)) // matches 1-RTT's server hello length for \"random\", though it is not important, just for example\n\t\t\tvar err error\n\t\t\tfor err == nil {\n\t\t\t\trand.Read(noises)\n\t\t\t\t_, err = DecodeHeader(noises)\n\t\t\t}\n\t\t\tconn.Write(noises) // make client do new handshake\n\t\t\treturn nil, errors.New(\"expired ticket\")\n\t\t}\n\t\tif _, loaded := s.NfsKeys.LoadOrStore([32]byte(nfsKey), true); loaded { // prevents bad client also\n\t\t\treturn nil, errors.New(\"replay detected\")\n\t\t}\n\t\tc.UnitedKey = append(s.PfsKey, nfsKey...) // the same nfsKey links the upload & download (prevents server -> client's another request)\n\t\tc.PreWrite = make([]byte, 16)\n\t\trand.Read(c.PreWrite) // always trust yourself, not the client (also prevents being parsed as TLS thus causing false interruption for \"native\" and \"xorpub\")\n\t\tc.AEAD = NewAEAD(c.PreWrite, c.UnitedKey, c.UseAES)\n\t\tc.PeerAEAD = NewAEAD(encryptedTicket, c.UnitedKey, c.UseAES) // unchangeable ctx (prevents server -> server), and different ctx length for upload / download (prevents client -> client)\n\t\tif i.XorMode == 2 {\n\t\t\tc.Conn = NewXorConn(conn, NewCTR(c.UnitedKey, c.PreWrite), NewCTR(c.UnitedKey, iv), 16, 0) // it doesn't matter if the attacker sends client's iv back to the client\n\t\t}\n\t\treturn c, nil\n\t}\n\n\tif length < 1184+32+16 { // client may send more public keys in the future's version\n\t\treturn nil, errors.New(\"too short length\")\n\t}\n\tencryptedPfsPublicKey := make([]byte, length)\n\tif _, err := io.ReadFull(conn, encryptedPfsPublicKey); err != nil {\n\t\treturn nil, err","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/vless/encryption/server.go#L206-L242","documentation":"Error \"replay detected\" thrown in XTLS/Xray-core.","triggerScenarios":"Thrown at proxy/vless/encryption/server.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}