mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5462] [Bug]: Salamander finalmask causes Hysteria2 UDP listener to hang on invalid packet (same root cause as XTLS#6184) #3821
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#3821
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 @Pb110200 on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5462
Describe the bug
3x-ui version: 3.1.1
Xray-core version: 26.6.1
Protocol: Hysteria2 + TLS + salamander finalmask
OS: Ubuntu 22.04
Description
When
streamSettings.finalmask.udp[].type = "salamander"is configured on a Hysteria2 inbound, the first invalid UDP packet that hits the port permanently kills the listener. All legitimate client traffic is silently dropped at kernel level until xray.service is restarted.This is the exact same bug as XTLS/Xray-core#6184 (fixed by #6185), but that fix only covered the
sudokutype —salamanderhas the identical code path issue.Logs
ERROR - XRAY: transport/internet/finalmask: [mask] drop packet fromxx.xx.xx.xx:41868 with size 6
After this log, all subsequent legitimate client traffic gets silently dropped.
ss -uanmshows kernel receive buffer full.How to reproduce the problem
Inboundspage, create or edit a Hysteria2 inboundStream Settings, addUDP Mask 1with typesalamanderand a passwordecho -n 'X' | nc -u -w1 <server_ip> <port>ss -uanm— kernel receive buffer is full, dropped packet counter growsExpected behavior
Invalid UDP packets should be silently discarded without killing the listener. The
salamanderfinalmask should handle decode errors the same waysudokudoes after PR #6185 — skip the bad packet and continue reading.Actual behavior
Actual behavior
The first invalid UDP packet causes the listener to permanently stop responding. The xray process stays alive and accepts new TCP connections, but the UDP port is dead until
systemctl restart xrayor a full server reboot.Relevant logs
Screenshots
No response
3x-ui version
3.1.1
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 22.04
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 21, 2026):
The root cause has been confirmed in the xray-core source. This is a real bug, but the framing differs slightly from the issue description: it is not a salamander-specific gap analogous to the sudoku fix in XTLS/Xray-core#6185 — it is a shared infrastructure bug in
transport/internet/finalmask/finalmask.gothat affects all UDP mask types, including salamander.What happens
headerManagerConn.ReadFrom()infinalmask.goreads each UDP datagram into a full-size bufferb(65535 bytes). The pre-fix code contained:When a UDP packet shorter than the salamander salt prefix (8 bytes) arrives — as in the reported case with a 6-byte datagram — the check fires,
continuerestarts the outer loop, andc.PacketConn.ReadFrom(b)is now called withbcapped at 6 bytes. Every subsequent datagram is truncated to 6 bytes by the OS, fails the minimum-size check, and is dropped.bnever grows back. The goroutine keeps reading and discarding, the kernel receive buffer fills, and legitimate clients time out.The log line you observed is produced by exactly this check:
Fix status
This is corrected in xray-core PR XTLS/Xray-core#6331 ("Finalmask: Fix unexpected order and UDP's buf issue"), merged 2026-06-17. The fix renames the mutation to a loop-local variable:
so
bremains at full capacity across all outer-loop iterations regardless of what any single packet contains.Affected versions of 3x-ui
3x-ui's
go.modpins xray-core at commit94ffd50060f1(2026-06-01) in all releases up to and including the current latest, v3.3.1 (released 2026-06-12). That commit predates the merge of PR #6331 (2026-06-17), so the bug is present in every current release of 3x-ui.Regarding XTLS/Xray-core#6185
PR #6185 hardened sudoku's own
conn_udp.goReadFromloop so it continues on decode errors rather than returning them. That was a separate, sudoku-specific robustness improvement. It did not touchfinalmask.goand did not address the buffer-mutation bug described here.Workaround until a dependency update ships
There is no configuration-level workaround. The only option is to avoid salamander finalmask on Hysteria2 inbounds, or to configure firewall rules (
iptables/nftables/ufw) to drop non-client source addresses before they reach the Hysteria2 UDP port.Resolution path
The fix is entirely upstream in xray-core. A 3x-ui release that updates the
go.modpin to a commit at or after 2026-06-17 will include it.This reply was generated automatically; a maintainer may follow up.
@MHSanaei commented on GitHub (Jun 21, 2026):
Fixed by bumping the xray-core dependency past the upstream finalmask fix (XTLS/Xray-core#6331, merged 2026-06-17).
go.modnow pins xray-core atbe8009c62509(2026-06-19), which replaces the buggyb = b[:n]intransport/internet/finalmask/finalmask.gowith a loop-localbuf := b[:n]. The 65535-byte UDP read buffer is no longer shrunk by a short/invalid packet, so the salamander finalmask listener no longer hangs after a malformed datagram.This will ship in the next release. Thanks for the detailed report and root-cause pointer.