REALITY: authenticated handshake fails with `padding: -4` when the target sends an empty EncryptedExtensions (since v26.10.21)
Integrity requirements
- [x] I have read all the comments in the issue template and ensured that this issue meet the requirements.
- [x] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- [x] I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
- [x] I searched issues and did not find any similar issues.
- [x] The problem can be successfully reproduced in the latest Release
Description
Since v26.10.21 (REALITY 83f621788ca8), every authenticated REALITY connection fails when the target sends an empty EncryptedExtensions (no SNI ack, no ALPN, nothing else). With "show": true the server prints:
hs.handshake() err: payload[0]: 8, padding: -4
v26.9.9 (REALITY 8cdf7bf9c7f0) works with the same target.
Cause:
- XTLS/REALITY
3c98159("Sync upstream Go 1.27+", #30) added tohandshake_server_tls13.go:
An authenticated connection always carries SNI unlessif !hs.c.didResume && hs.clientHello.serverName != "" { encryptedExtensions.serverNameAck = true }serverNamescontains"", so REALITY's own EncryptedExtensions now always has the 4-byte emptyserver_nameextension. Before this commitencryptedExtensionsMsghad no such field. [REALITY] SECTION: mimic recorded handshakeLeninconn.gopads each handshake record to the length recorded from the target and returnspayload[0]: %v, padding: %vwhen its own record is longer (payload[0]: 8is EncryptedExtensions).- REALITY's own EncryptedExtensions has no ALPN, so it is now 4 bytes longer than an empty one. A target whose EncryptedExtensions is empty gives a 28-byte record (including the 5-byte record header) against REALITY's 32, hence padding -4. Any extension on the target side (an SNI ack, ALPN, ...) is at least 4 bytes and absorbs it.
Not setting serverNameAck in the REALITY server (the pre-sync behaviour) looks sufficient, since padding then matches any target; I have not tested a patch.
This is easy to miss: the fallback path does not reach this code, so probing the node without the key looks fine, and without show the server logs only an Info line (REALITY: processed invalid connection ...: handshake did not complete successfully) while the client gets EOF. We hit it on a production node whose target neither acks SNI nor negotiates ALPN. To check a target, look for any extension besides supported versions and key share:
openssl s_client -connect <Domain>:443 -servername <Domain> -tls1_3 -alpn h2,http/1.1 -tlsextdebug </dev/null 2>/dev/null | grep 'TLS server extension'
Reproduction Method
All on loopback (Linux, OpenSSL 3.5.5). Three openssl s_server targets with the same self-signed certificate for example.test:
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout k.pem -out c.pem -days 30 -subj /CN=example.test -addext subjectAltName=DNS:example.test
# A: empty EncryptedExtensions
openssl s_server -accept 127.0.0.1:20443 -cert c.pem -key k.pem -tls1_3 -www -quiet
# B: acks SNI (s_server acks only when -servername installs its callback and the name matches)
openssl s_server -accept 127.0.0.1:20444 -cert c.pem -key k.pem -tls1_3 -www -quiet -servername example.test -cert2 c.pem -key2 k.pem
# C: no SNI ack, but negotiates ALPN
openssl s_server -accept 127.0.0.1:20445 -cert c.pem -key k.pem -tls1_3 -www -quiet -alpn h2,http/1.1
# something to fetch through the proxy
python3 -m http.server 18080 --bind 127.0.0.1
Start the server (config below, target pointing at A, B or C) and the client (always v26.10.21), then curl -x socks5h://127.0.0.1:11080 http://127.0.0.1:18080/:
| server | target | target EE record | result |
|---|---|---|---|
| v26.10.21 | A | 28 | curl: (56) Recv failure: Connection reset by peer; padding: -4 |
| v26.10.21 | B | 32 | 200 |
| v26.10.21 | C | 37 | 200 |
| v26.9.9 | A | 28 | 200 |
| v26.9.9 | B | 32 | 200 |
The finalRules allow rule only lets the test reach the loopback HTTP server.
Client config
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 11080,
"protocol": "socks",
"settings": {
"udp": false
}
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"address": "127.0.0.1",
"port": 18443,
"id": "b152e703-a01f-4286-bf56-e6c80fb5a0bc",
"flow": "xtls-rprx-vision",
"encryption": "none"
},
"streamSettings": {
"method": "raw",
"security": "reality",
"realitySettings": {
"serverName": "example.test",
"fingerprint": "chrome",
"password": "YwiwpCoxfiEPH-mBtnbbfRDw623xDBffrQfw313lHVQ",
"shortId": "0123456789abcdef"
}
}
}
]
}
Server config
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 18443,
"protocol": "vless",
"settings": {
"users": [
{
"id": "b152e703-a01f-4286-bf56-e6c80fb5a0bc",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"method": "raw",
"security": "reality",
"realitySettings": {
"show": true,
"target": "127.0.0.1:20443",
"serverNames": [
"example.test"
],
"privateKey": "4Dkro7AN2awrVSrhsDt8UJ1BjbJ6T5IDVtwIzfMl0lI",
"shortIds": [
"0123456789abcdef"
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {
"finalRules": [
{
"action": "allow",
"ip": [
"127.0.0.1/32"
]
}
]
}
}
]
}
For B and C only target changes (127.0.0.1:20444, 127.0.0.1:20445).
Client log
v26.10.21, target A.
Xray 26.10.21 (Xray, Penetrates Everything.) 1b1647c (go1.27.3 linux/amd64)
A unified platform for anti-censorship.
2026/10/23 21:07:47.823954 [Info] infra/conf/serial: Reading config: &{Name:client.json Format:json}
2026/10/23 21:07:47.824630 [Debug] app/log: Logger started
2026/10/23 21:07:47.824636 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:11080
2026/10/23 21:07:47.824755 [Info] transport/internet/tcp: listening tcp on 127.0.0.1:11080
2026/10/23 21:07:47.824860 [Warning] core: Xray 26.10.21 started
2026/10/23 21:07:49.323669 [Info] [2250713741] proxy/socks: TCP Connect request to tcp:127.0.0.1:18080
2026/10/23 21:07:49.323682 [Info] [2250713741] app/dispatcher: default route for tcp:127.0.0.1:18080
2026/10/23 21:07:49.323685 [Info] [2250713741] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:18443
2026/10/23 21:07:49.323687 [Debug] [2250713741] transport/internet: dialing to tcp:127.0.0.1:18443
2026/10/23 21:07:49.323704 from tcp:127.0.0.1:42064 accepted tcp:127.0.0.1:18080
2026/10/23 21:07:55.342185 [Info] [2250713741] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:18443
2026/10/23 21:07:55.342193 [Debug] [2250713741] transport/internet: dialing to tcp:127.0.0.1:18443
2026/10/23 21:07:55.543628 [Info] [2250713741] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:18443
2026/10/23 21:07:55.543660 [Debug] [2250713741] transport/internet: dialing to tcp:127.0.0.1:18443
2026/10/23 21:07:55.945348 [Info] [2250713741] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:18443
2026/10/23 21:07:55.945394 [Debug] [2250713741] transport/internet: dialing to tcp:127.0.0.1:18443
2026/10/23 21:07:56.547540 [Info] [2250713741] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:18443
2026/10/23 21:07:56.547551 [Debug] [2250713741] transport/internet: dialing to tcp:127.0.0.1:18443
2026/10/23 21:07:57.349883 [Info] [2250713741] app/proxyman/outbound: app/proxyman/outbound: failed to process outbound traffic > proxy/vless/outbound: failed to find an available destination > common/retry: [EOF] > common/retry: all retry attempts failed
2026/10/23 21:07:57.353160 [Debug] app/log: Logger closing
Server log
v26.10.21, target A, complete (ClientTime redacted).
Xray 26.10.21 (Xray, Penetrates Everything.) 1b1647c (go1.27.3 linux/amd64)
A unified platform for anti-censorship.
2026/10/23 21:07:47.824032 [Info] infra/conf/serial: Reading config: &{Name:server-20443.json Format:json}
2026/10/23 21:07:47.824445 [Warning] infra/conf: REALITY: Listening on non-443 ports will increase the likelihood of your server's IP being blocked by the GFW
2026/10/23 21:07:47.824953 [Debug] app/log: Logger started
2026/10/23 21:07:47.825038 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:18443
2026/10/23 21:07:47.826271 [Info] transport/internet/tcp: listening tcp on 127.0.0.1:18443
2026/10/23 21:07:47.826355 [Warning] core: Xray 26.10.21 started
REALITY remoteAddr: 127.0.0.1:51408
REALITY remoteAddr: 127.0.0.1:51408 hs.c.AuthKey[:16]: [149 191 243 197 29 149 140 255 64 89 189 94 188 109 240 229] AEAD: *gcm.GCM
REALITY remoteAddr: 127.0.0.1:51408 hs.c.ClientVer: [26 10 21]
REALITY remoteAddr: 127.0.0.1:51408 hs.c.ClientTime:
REALITY remoteAddr: 127.0.0.1:51408 hs.c.ClientShortId: [1 35 69 103 137 171 205 239]
REALITY remoteAddr: 127.0.0.1:51408 hs.c.conn == conn: true
REALITY remoteAddr: 127.0.0.1:51408 len(s2cSaved): 1860 Server Hello: 1215
REALITY remoteAddr: 127.0.0.1:51408 len(s2cSaved): 645 Change Cipher Spec: 6
REALITY remoteAddr: 127.0.0.1:51408 len(s2cSaved): 639 Encrypted Extensions: 28
REALITY remoteAddr: 127.0.0.1:51408 len(s2cSaved): 611 Certificate: 451
REALITY remoteAddr: 127.0.0.1:51408 len(s2cSaved): 160 Certificate Verify: 102
REALITY remoteAddr: 127.0.0.1:51408 len(s2cSaved): 58 Finished: 58
REALITY remoteAddr: 127.0.0.1:51408 is using X25519MLKEM768 for TLS' communication: true
REALITY remoteAddr: 127.0.0.1:51408 is using ML-DSA-65 for cert's extra signature: false
REALITY remoteAddr: 127.0.0.1:51408 hs.handshake() err: payload[0]: 8, padding: -4
REALITY remoteAddr: 127.0.0.1:51408 hs.c.isHandshakeComplete.Load(): false
2026/10/23 21:07:55.342025 [Info] transport/internet/tcp: REALITY: processed invalid connection from 127.0.0.1:51408: handshake did not complete successfully
REALITY remoteAddr: 127.0.0.1:44126
REALITY remoteAddr: 127.0.0.1:44126 hs.c.AuthKey[:16]: [16 1 162 90 235 57 120 197 206 184 199 245 67 107 147 30] AEAD: *gcm.GCM
REALITY remoteAddr: 127.0.0.1:44126 hs.c.ClientVer: [26 10 21]
REALITY remoteAddr: 127.0.0.1:44126 hs.c.ClientTime:
REALITY remoteAddr: 127.0.0.1:44126 hs.c.ClientShortId: [1 35 69 103 137 171 205 239]
REALITY remoteAddr: 127.0.0.1:44126 hs.c.conn == conn: true
REALITY remoteAddr: 127.0.0.1:44126 len(s2cSaved): 1858 Server Hello: 1215
REALITY remoteAddr: 127.0.0.1:44126 len(s2cSaved): 643 Change Cipher Spec: 6
REALITY remoteAddr: 127.0.0.1:44126 len(s2cSaved): 637 Encrypted Extensions: 28
REALITY remoteAddr: 127.0.0.1:44126 len(s2cSaved): 609 Certificate: 451
REALITY remoteAddr: 127.0.0.1:44126 len(s2cSaved): 158 Certificate Verify: 100
REALITY remoteAddr: 127.0.0.1:44126 len(s2cSaved): 58 Finished: 58
REALITY remoteAddr: 127.0.0.1:44126 is using X25519MLKEM768 for TLS' communication: true
REALITY remoteAddr: 127.0.0.1:44126 is using ML-DSA-65 for cert's extra signature: false
REALITY remoteAddr: 127.0.0.1:44126 hs.handshake() err: payload[0]: 8, padding: -4
REALITY remoteAddr: 127.0.0.1:44126 hs.c.isHandshakeComplete.Load(): false
2026/10/23 21:07:55.343264 [Info] transport/internet/tcp: REALITY: processed invalid connection from 127.0.0.1:44126: handshake did not complete successfully
REALITY remoteAddr: 127.0.0.1:44142
REALITY remoteAddr: 127.0.0.1:44142 hs.c.AuthKey[:16]: [193 76 77 10 179 50 176 149 4 203 100 181 51 150 246 238] AEAD: *gcm.GCM
REALITY remoteAddr: 127.0.0.1:44142 hs.c.ClientVer: [26 10 21]
REALITY remoteAddr: 127.0.0.1:44142 hs.c.ClientTime:
REALITY remoteAddr: 127.0.0.1:44142 hs.c.ClientShortId: [1 35 69 103 137 171 205 239]
REALITY remoteAddr: 127.0.0.1:44142 hs.c.conn == conn: true
REALITY remoteAddr: 127.0.0.1:44142 len(s2cSaved): 1860 Server Hello: 1215
REALITY remoteAddr: 127.0.0.1:44142 len(s2cSaved): 645 Change Cipher Spec: 6
REALITY remoteAddr: 127.0.0.1:44142 len(s2cSaved): 639 Encrypted Extensions: 28
REALITY remoteAddr: 127.0.0.1:44142 len(s2cSaved): 611 Certificate: 451
REALITY remoteAddr: 127.0.0.1:44142 len(s2cSaved): 160 Certificate Verify: 102
REALITY remoteAddr: 127.0.0.1:44142 len(s2cSaved): 58 Finished: 58
REALITY remoteAddr: 127.0.0.1:44142 is using X25519MLKEM768 for TLS' communication: true
REALITY remoteAddr: 127.0.0.1:44142 is using ML-DSA-65 for cert's extra signature: false
REALITY remoteAddr: 127.0.0.1:44142 hs.handshake() err: payload[0]: 8, padding: -4
REALITY remoteAddr: 127.0.0.1:44142 hs.c.isHandshakeComplete.Load(): false
2026/10/23 21:07:55.544827 [Info] transport/internet/tcp: REALITY: processed invalid connection from 127.0.0.1:44142: handshake did not complete successfully
REALITY remoteAddr: 127.0.0.1:44156
REALITY remoteAddr: 127.0.0.1:44156 hs.c.AuthKey[:16]: [209 253 246 80 96 173 90 227 228 203 100 84 123 4 219 171] AEAD: *gcm.GCM
REALITY remoteAddr: 127.0.0.1:44156 hs.c.ClientVer: [26 10 21]
REALITY remoteAddr: 127.0.0.1:44156 hs.c.ClientTime:
REALITY remoteAddr: 127.0.0.1:44156 hs.c.ClientShortId: [1 35 69 103 137 171 205 239]
REALITY remoteAddr: 127.0.0.1:44156 hs.c.conn == conn: true
REALITY remoteAddr: 127.0.0.1:44156 len(s2cSaved): 1859 Server Hello: 1215
REALITY remoteAddr: 127.0.0.1:44156 len(s2cSaved): 644 Change Cipher Spec: 6
REALITY remoteAddr: 127.0.0.1:44156 len(s2cSaved): 638 Encrypted Extensions: 28
REALITY remoteAddr: 127.0.0.1:44156 len(s2cSaved): 610 Certificate: 451
REALITY remoteAddr: 127.0.0.1:44156 len(s2cSaved): 159 Certificate Verify: 101
REALITY remoteAddr: 127.0.0.1:44156 len(s2cSaved): 58 Finished: 58
REALITY remoteAddr: 127.0.0.1:44156 is using X25519MLKEM768 for TLS' communication: true
REALITY remoteAddr: 127.0.0.1:44156 is using ML-DSA-65 for cert's extra signature: false
REALITY remoteAddr: 127.0.0.1:44156 hs.handshake() err: payload[0]: 8, padding: -4
REALITY remoteAddr: 127.0.0.1:44156 hs.c.isHandshakeComplete.Load(): false
2026/10/23 21:07:55.946602 [Info] transport/internet/tcp: REALITY: processed invalid connection from 127.0.0.1:44156: handshake did not complete successfully
REALITY remoteAddr: 127.0.0.1:44166
REALITY remoteAddr: 127.0.0.1:44166 hs.c.AuthKey[:16]: [35 134 35 60 37 132 182 144 16 130 173 43 201 153 68 217] AEAD: *gcm.GCM
REALITY remoteAddr: 127.0.0.1:44166 hs.c.ClientVer: [26 10 21]
REALITY remoteAddr: 127.0.0.1:44166 hs.c.ClientTime:
REALITY remoteAddr: 127.0.0.1:44166 hs.c.ClientShortId: [1 35 69 103 137 171 205 239]
REALITY remoteAddr: 127.0.0.1:44166 hs.c.conn == conn: true
REALITY remoteAddr: 127.0.0.1:44166 len(s2cSaved): 1858 Server Hello: 1215
REALITY remoteAddr: 127.0.0.1:44166 len(s2cSaved): 643 Change Cipher Spec: 6
REALITY remoteAddr: 127.0.0.1:44166 len(s2cSaved): 637 Encrypted Extensions: 28
REALITY remoteAddr: 127.0.0.1:44166 len(s2cSaved): 609 Certificate: 451
REALITY remoteAddr: 127.0.0.1:44166 len(s2cSaved): 158 Certificate Verify: 100
REALITY remoteAddr: 127.0.0.1:44166 len(s2cSaved): 58 Finished: 58
REALITY remoteAddr: 127.0.0.1:44166 is using X25519MLKEM768 for TLS' communication: true
REALITY remoteAddr: 127.0.0.1:44166 is using ML-DSA-65 for cert's extra signature: false
REALITY remoteAddr: 127.0.0.1:44166 hs.handshake() err: payload[0]: 8, padding: -4
REALITY remoteAddr: 127.0.0.1:44166 hs.c.isHandshakeComplete.Load(): false
2026/10/23 21:07:56.548657 [Info] transport/internet/tcp: REALITY: processed invalid connection from 127.0.0.1:44166: handshake did not complete successfully
AI-assisted (Claude); the results above were measured, not estimated.
The tempting fix in the mimic layer is the wrong layer. Clamping a negative padding to zero lets a 32 byte EncryptedExtensions go out against a 28 byte recorded one, and the rest of the flight is sliced off the recorded stream in order, so Certificate and everything after it shifts by the same 4 bytes. Dropping serverNameAck on the REALITY side, as you suggest, keeps every later message on its recorded offset, not just this one. It is also safe on the client side: the server_name acknowledgment in EncryptedExtensions is empty and optional, and nothing in the client handshake depends on receiving it.
Is this regression being taken internally, or are you open to someone outside picking it up?
Reproduced this at 1b1647cd and tested the patch the report says was not tried yet (dropping the ack in REALITY's server). It clears the failure, and the two targets that work today keep working.
Rig is the report's, on loopback with OpenSSL 3.5.5: xray client -> vless + xtls-rprx-vision + reality -> v26.10.21 server with "show": true; targets A (empty EncryptedExtensions), B (-servername example.test -cert2 ..., acks SNI), C (-alpn h2,http/1.1); curl -x socks5h://... to a local http.server through the finalRules allow rule.
| build | target A | target B | target C |
|---|---|---|---|
| v26.10.21, untouched reality pin | 0/2, padding: -4 x10 |
2/2 | 2/2 |
| v26.10.21 + the hunk below | 2/2, no padding line | 2/2 | 2/2 |
The entire change, in XTLS/REALITY handshake_server_tls13.go (the block 3c98159 added):
- if !hs.c.didResume && hs.clientHello.serverName != "" {
- encryptedExtensions.serverNameAck = true
- }
With it REALITY's own EncryptedExtensions is 28 bytes and matches an empty target EE; on target B the same record is 4 bytes shorter than the target's, and the mimic pads positively as it always did. Nothing else in the server path reads that field.
Client side is safe for the same reason the reporter gives: handshake_client_tls13.go only rejects an ack the client did not ask for (hs.hello.serverName == ""), an xray REALITY client always sends SNI, and both B and C still complete against the patched server.
I did not touch XTLS/REALITY and have not proposed a parallel fix anywhere: the module pin is 83f621788ca8 and my build used a local replace. So landing it means a REALITY commit plus a go.mod bump here; the matrix above is what that bump would be validated against.
I had the same bug on 26.10.21 with some camouflage target. As soon as I installed version 26.3.27 instead of the latest version, everything started to work fine. Didn't test it on other versions or targets though.
空的EncryptedExtensions是常见的流量吗?
4. 空的EncryptedExtensions是常见的流量吗?
我不确定这属不属于常见流量 目前的设计似乎把这种流量排除在外
能发现这个bug总得是遇到可以触发的目标服务器吧 如果这种实现多就修一下 没有就算了
用 Tranco 榜单抽样, 对每个域名以 openssl s_client -tls1_3 -alpn h2,http/1.1 (SNI 即域名) 握一次, 统计 EncryptedExtensions 为空 (既不确认 SNI 也不选 ALPN) 的数量. 分母是样本里的全部域名, 握手失败的也计入:
| 样本 | 域名数 | 空 EE | 占比 |
|---|---|---|---|
| 排名 1-3000 | 3000 | 31 | 1.0% |
| 3000 名以后随机抽样 | 6000 | 35 | 0.6% |
另外挑了 4 个 EE 为空的真实站点做 target, 端到端对照 (服务端 show: true): v26.10.21 每条连接都 padding: -4; 去掉 serverNameAck 那三行后全部正常; 换成确认 SNI 的 target, 两个版本都正常.
我个人认为不算罕见: 配置里只对少数几类域名给出警告, 其余的普通站点里约 0.6%-1% 是空 EE; 一旦用上, 每条连接都失败, 不开 show 时只有一条 Info 级日志, 无密钥的探测走回落也照常通过, 使用者很难自己定位; 而且同样的 target 在 26.9.9 上正常, 已在用的节点升级后会直接断掉.
算不算罕见, 要不要修, 最终由你决定.
AI-assisted (Claude); the numbers above were measured, not estimated.
有必要再说吧 而且不支持 ALPN 的 target 本身也是不鼓励使用的