v13: adding a user crashes xray (panic) when a REALITY SNI domain contains "ss" - substring tag->protocol mapping in `xray_api.py`
Version: 13.0.3 (upgraded from 12.3.x), non-docker, Ubuntu 22.04, Xray from the 13.0.3 bundle
Symptom
Creating a user (admin API POST /api/v2/admin/user/, same path as the panel UI) immediately kills hiddify-xray:
panic: interface conversion: protocol.Account is *shadowsocks.MemoryAccount, not *vless.MemoryAccount
github.com/xtls/xray-core/proxy/vless.(*MemoryValidator).Add(...)
proxy/vless/validator.go:42
github.com/xtls/xray-core/proxy/vless/inbound.(*Handler).AddUser(...)
proxy/vless/inbound/inbound.go:241
github.com/xtls/xray-core/app/proxyman/command.(*AddUserOperation).ApplyInbound(...)
app/proxyman/command/command.go:51
...
hiddify-xray.service: Main process exited, code=exited, status=2/INVALIDARGUMENTThe follow-up install.sh apply_users then hit #5562 / #5565 on our box (units disabled, certs wiped), so a single "add user" took the whole server down.
Root cause
hiddifypanel/drivers/xray_api.py, __add_uuid_to_tag() picks the account type by substring match of the inbound tag against proto_map, first match wins, in dict order:
proto_map = {
"vless": "vless", "realityin": "vless", "xtls": "vless", "quic": "vless",
"trojan": "trojan", "vmess": "vmess",
"ss": "shadowsocks", # <- checked before "reality"
"v2ray": "shadowsocks", "kcp": "vless", "dispatcher": "trojan",
"reality": "vless",
}In v13 the xray inbound tags became human-readable and include the SNI domain, e.g.:
vless | reality terminator REALITY Termination swisstransfer.com"ss" matches inside swisstransfer.com before "reality" is reached, so the driver sends a shadowsocks account to a VLESS inbound via AlterInbound/AddUser, and xray panics (the API handler does not recover, the whole process exits).
Any REALITY/fallback domain containing ss (or vmess/trojan/quic/kcp... as a substring) triggers it. Tags without such substrings work, which is why it looks random between servers.
Steps to reproduce
- v13.0.3, add a REALITY domain whose name contains
ss(e.g.swisstransfer.com), apply. - Add any user in the panel or via
POST /api/v2/admin/user/. journalctl -u hiddify-xray-> the panic above, xray is down.
Suggested fix
- Map by the inbound's actual
protocolfield (fromxray.jsonorxray api lsi), not by the tag text; or at least match whole tokens / check the most specific keys first and never match inside the domain part of the tag. - Optionally: skip/validate tags whose protocol doesn't match before calling
AddUser- a wrong call should not be able to crash xray (the panic itself is arguably also worth reporting to XTLS/Xray-core:vless.MemoryValidator.Adddoes an unchecked type assertion on an API-supplied account).
Related: #5562, #5565, #5566.
Source: hiddify/Hiddify-Manager