mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6232] [Bug]: Hysteria2 clients whose auth value is empty in the database fail authentication #4229
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4229
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @koi-lee on GitHub (Aug 17, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6232
Bug Description
When creating or editing a Hysteria2 client in the 3X-UI panel, the password is stored in the
passwordfield in the SQLite database. However, xray-core's Hysteria2 implementation only reads theauthfield for authentication. This results in theauthfield being empty, causing404 authentication failederrors when clients try to connect.Environment
Steps to Reproduce
authentication failed/404Root Cause
The panel stores the password in the
passwordcolumn of theclientstable inx-ui.db, but leaves theauthcolumn empty.xray-core's Hysteria2 implementation reads the
authfield for authentication, notpassword. Sinceauthis empty, all authentication attempts fail.Database Evidence
Result shows
passwordhas the value butauthis empty for all Hysteria2 clients.Expected Behavior
When a Hysteria2 client's password is set or changed in the panel, the
authfield should be automatically populated with the same value.Current Workaround
Manual SQL fix:
This can be run as a cron job every minute to keep
authin sync:Additional Notes
fix-hy2-auth.pycron workaround has been running stably, but a proper fix in the panel code would be much bettersubId/ subscription link generation if theauthfield is used there@github-actions[bot] commented on GitHub (Aug 17, 2026):
Thank you for the detailed report. The symptom you describe is real, but the stated root cause is not what the code does:
passwordandauthare two separate credentials by design, and the panel does not usepasswordfor Hysteria at all.What I confirmed in the source:
authkey, and only when it is non-empty —internal/web/service/xray.go:240-243. The client list for that config is read from theclientstable (ListForInbound,internal/web/service/xray.go:181), which is why a row with an emptyauthproduces a Hysteria user with no credential at all, and why yourUPDATEhas an effect.passwordis consumed only by Trojan and Shadowsocks (internal/web/service/xray.go:229-239). The client form states this in the field tooltips: "Only used by Trojan and Shadowsocks clients; ignored for VLESS, VMess, Hysteria, and WireGuard" and "Credential used only by Hysteria clients" (internal/web/translation/en-US.json:732and:827). Copyingpasswordintoauthis therefore not a correct fix — it would overwrite the Hysteria credential of every client that legitimately has both set to different values.auth, notpassword(internal/sub/service.go:1006,internal/sub/json_service.go:515,internal/sub/clash_service.go:310), so a link generated by the panel is consistent with the config.Recommended fix on your side, instead of the cron job:
Credentialstab, and set or regenerate theHysteria Authfield, then save./etc/cron.d/fix-hy2-auth. As written, that statement also setsauthto the Trojan/Shadowsocks password for every non-Hysteria client that has one. If such a client is later attached to a Hysteria inbound,fillProtocolDefaults(internal/web/service/client_crud.go:164-167) only mints an auth when the field is empty, so the client would silently keep the Trojan password as its Hysteria credential. A direct DB write also does not reach the running Xray until the config is regenerated.Two things I could not resolve, hence the request for information below:
authfor a Hysteria inbound:fillProtocolDefaults(internal/web/service/client_crud.go:149-172) is called on create, update, attach and bulk-attach, andAddInbound/addInboundClientreject a Hysteria client with an empty auth withempty client ID(internal/web/service/inbound.go:1008-1011,internal/web/service/client_inbound_apply.go:379-382). I could not find a panel UI path in v3.6.0 that leavesauthempty. The one gap I did find is thatUpdateInbound(internal/web/service/inbound.go:1398) has no equivalent credential validation, so an inbound update sent through the REST API can persist Hysteria clients withoutauth; the protocol selector is disabled for existing inbounds in the UI (frontend/src/pages/inbounds/form/InboundFormModal.tsx:591), but the API accepts a protocol change. My confidence that this is what happened on your panel is low without more detail.clientstable has noprotocolcolumn — seeClientRecordininternal/database/model/model.go:901-934(TableName() == "clients");protocolis a column oninbounds. The query you pasted should therefore fail withno such column: protocol, so it is not the query that produced your evidence.To move this forward, please provide:
For visibility on the missing validation in
UpdateInbound:Title:
UpdateInbounddoes not validate per-protocol client credentials, so a Hysteria client can be persisted with an emptyauthSeverity: Medium
Category: Correctness
Why this matters:
AddInboundrejects a Hysteria client with an emptyauth(internal/web/service/inbound.go:1008-1011), butUpdateInboundperforms no such check. A client persisted that way is written to theclientstable bySyncInboundand then rendered into the Xray config as a user object with onlyemail(internal/web/service/xray.go:240-243), which can never authenticate, with no error surfaced in the panel.Recommendation: Apply the same per-protocol credential validation in
UpdateInboundthatAddInboundalready performs, or fill the missing credential viafillProtocolDefaultsbefore persisting.@MHSanaei for a decision on whether the validation gap is worth closing.
I also edited the title for accuracy; it previously read: "[Bug] Hysteria2 client "auth" field not synced with "password" field — causes authentication failure".
This reply was generated automatically; a maintainer may follow up.
@mvanhorn commented on GitHub (Aug 19, 2026):
Implemented in https://github.com/MHSanaei/3x-ui/pull/6268.