Repository navigation
XTLS Vision: Do not send outer close_notify after switching to direct copy - #6816
Closed
4RH1T3CT0R7 wants to merge 1 commit into
Closed
4RH1T3CT0R7 wants to merge 1 commit into
4RH1T3CT0R7 wants to merge 1 commit into
Conversation
… copy Once a Vision writer sends CommandPaddingDirect, the peer reads the raw socket, but the outer TLS/REALITY conn is still closed normally at the end and its Close() writes an encrypted close_notify onto that socket. The peer forwards those bytes to the inner TLS endpoint, which fails with "bad record MAC". Remember that the command was sent and close the raw conn first, so the outer alert write fails instead of reaching the peer. Fixes XTLS#6794
Member
|
这样没法抑制来自其他组件稀奇古怪的close调用 我想到了一个更好的办法 |
RPRX
pushed a commit
that referenced
this pull request
Sep 27, 2026
#6834) #6816 (comment) #6794 (comment) #6834 (comment) Fixes #6794 (comment) Fixes #6124 (comment) Fixes #4878 (comment) --------- Co-authored-by: Artem Lytkin <[email protected]>
GFW-knocker
pushed a commit
to GFW-knocker/Xray-core
that referenced
this pull request
Oct 2, 2026
XTLS#6834) XTLS#6816 (comment) XTLS#6794 (comment) XTLS#6834 (comment) Fixes XTLS#6794 (comment) Fixes XTLS#6124 (comment) Fixes XTLS#4878 (comment) --------- Co-authored-by: Artem Lytkin <[email protected]> (cherry picked from commit e5e85ca) [GFW-knocker: hand-merged import block in tls/tls.go (the fork no longer imports slices there); code applied unchanged. Covers vless and mvless, which share proxy.VisionReader/VisionWriter.]
onesyue
pushed a commit
to onesyue/Xray-core
that referenced
this pull request
Oct 4, 2026
XTLS#6834) XTLS#6816 (comment) XTLS#6794 (comment) XTLS#6834 (comment) Fixes XTLS#6794 (comment) Fixes XTLS#6124 (comment) Fixes XTLS#4878 (comment) --------- Co-authored-by: Artem Lytkin <[email protected]> (cherry picked from commit e5e85ca)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a Vision writer sends
CommandPaddingDirect, the peer reads the raw socket. At teardown the outer TLS/REALITY conn is still closed as usual, and itsClose()writes an encrypted close_notify onto that same socket. The peer can't tell those 24 bytes apart from relayed data, so it forwards them to the inner TLS endpoint, which fails withbad record MAC. This shows up when the origin closes without its own close_notify, or when the client keeps reading to EOF.The fix: the writer records that it sent
CommandPaddingDirect(UplinkWriterDirectCopySent/DownlinkWriterDirectCopySent). When VLESS inbound/outboundProcessreturns, if that flag is set, it closes the conn returned byUnwrapRawConnfirst. The later outerClose()then fails to write its alert instead of sending it to the peer. When no switch happened, close works as before. With VLESS encryption,UnwrapRawConnstops at the TLS layer, so that close_notify still goes out correctly.TestVlessXtlsVisionDirectCopyCloseuses a TLS 1.3 destination that closes without close_notify, in both directions. On main it fails every run withbad record MAC(Windows and Linux), and it passes with this change. Reverting either the inbound or the outbound half makes the matching direction fail again. I also rango test ./proxy/...and the VLESS scenario tests, plus a race-built run under Linux: no new races, only the existingNumberOfPacketToFilter/cert ones.This probably also explains some of the reports in #4878.