Fix: OpenVPN TCP data packet drops due to improper replay window - #3
Open
tangyuanfu wants to merge 1 commit into
Open
Fix: OpenVPN TCP data packet drops due to improper replay window #3tangyuanfu wants to merge 1 commit into
tangyuanfu wants to merge 1 commit into
Conversation
OpenVPN's --replay-window only applies to UDP mode. TCP provides
its own ordered, reliable transport and does not need replay protection.
Previously, windowSize=0 (TCP) created an empty replayWindow whose
acceptLocked() only accepted strictly monotonic packetIDs. Normal
TCP retransmission or slight out-of-order delivery was rejected as
'replayed tls data packet', causing data loss and session failure.
Fix: newReplayWindow returns nil when windowSize==0. All callers
(data_codec_aead.go, data_codec_cbc.go, data_codec_static.go,
data_codec_stream.go) already guard with:
if c.replayWindow != nil && !c.replayWindow.Accept(...)
so the nil case naturally skips replay checks for TCP connections.
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.
Symptoms
Errors occur:
replayed tls data packet— Triggered by the replay window check on TCP.Root Cause Analysis
1. Replay window check should not run on TCP
In
sing-openvpn(the embedded OpenVPN implementation), the functiondataReplayWindowParametersindata_codec.go(lines 35–36) forced a zero-sized replay window for TCP:A window of zero means
packetID == highest + 1— no tolerance for normal TCP retransmission or slight out-of-order delivery. However, the Accept() check was still called. Any TCP retransmission was flagged as "replayed" and the packet was dropped.OpenVPN official behavior: The
--replay-windowoption is documented as only relevant for UDP. OpenVPN's own implementation skips replay checking whenproto tcp-clientorproto tcp-serveris set. Over TCP, the transport layer already guarantees ordering and handles loss recovery — there is no need for replay protection.Fix applied:
In
replay_window.go,newReplayWindow():This causes all
replayWindow != nil && !replayWindow.Accept(packetID)checks to naturally skip for TCP connections. Result:replayed tls data packeterrors stopped completely.Summary
replayed tls data packetnewReplayWindowreturns nil forwindowSize==0