mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2026-10-13 21:34:25 +00:00
[PR #128] [CLOSED] fix: apply S4 transport padding to keepalive packets #153
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amneziawg-go#153
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?
📋 Pull Request Information
Original PR: https://github.com/amnezia-vpn/amneziawg-go/pull/128
Author: @wizier
Created: 3/31/2026
Status: ❌ Closed
Base:
master← Head:fix/s4-keepalive-padding📝 Commits (1)
3ff8929fix: apply S4 transport padding to keepalive packets📊 Changes
1 file changed (+8 additions, -11 deletions)
View changed files
📝
device/send.go(+8 -11)📄 Description
Bug
When S4 (transport padding) is non-zero, keepalive packets are sent without S4 padding, but the receiving side expects all transport packets to include it. This causes keepalives to be silently dropped, preventing the responder from ever calling
timersHandshakeComplete().Root cause
In
device/send.go,RoutineSequentialSenderonly adds S4 padding inside theif len(elem.packet) != MessageKeepaliveSizebranch:Keepalive packets (
len == MessageKeepaliveSize) skip the padding entirely.On the receive side,
DeterminePacketTypeAndPaddingunconditionally expects S4 padding on all transport packets:A keepalive without padding is smaller than
padding + MessageTransportHeaderSize, so it fails the size check and is classified asMessageUnknownType→ dropped.Impact
After a handshake, the initiator immediately sends a keepalive to the responder. Since the keepalive is dropped, the responder never receives key confirmation and
lastHandshakeNanostays at 0. The handshake only fully completes on the responder side when actual data traffic flows through the tunnel.When S4 = 0 there is no issue — padding is 0, keepalive passes the size check normally.
Fix
Move the padding logic out of the
dataSentguard so it applies to all transport packets including keepalives.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.