Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process/wg: do not check if transport data length is divisible by 16 #200

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

PaulosV
Copy link
Contributor

@PaulosV PaulosV commented Dec 16, 2023

This corrects an implementation flub where I assumed that the length of a WireGuard data packet would always be divisible by 16. That is verifiably false, and the receiving code of WireGuard does not assume that.

Zero-padding the message data to the multiples of 16 relates to memory alignment and is mainly a measure to "complicate traffic analysis". It does not always happen; the most common example is traffic approaching the inner MTU, which is set by default to 1420, but can be set to arbitrary values by the user.

1420 is not divisible by 16, and an IP packet of length 1420 is not padded any further by WireGuard. With additional 32 bytes of WireGuard headers and 32 bytes of UDP, IP and frame headers, the total frame length is 1494, which is, again, not divisible by 16.

So this check needs to go.
It may increase the number of false positives, I am going to do some tests about this.

Pavel Valach added 2 commits December 16, 2023 13:08
This corrects an implementation flub where I assumed that the length of a WireGuard data packet would always be divisible by 16. That is verifiably false, and the receiving code of WireGuard does not assume that.

Padding to the multiples of 16 relates to memory alignment and is mainly a performance measure. It does not always happen; the most common example is traffic approaching the inner MTU, which is set by default to 1420, but can be set to arbitrary values by the user.

1420 is not divisible by 16, and an IP packet of length 1420 is not padded any further by WireGuard. With additional 32 bytes of WireGuard headers and 32 bytes of UDP, IP and frame headers, the total frame length is 1494, which is, again, not divisible by 16.

So this check needs to go.
@PaulosV PaulosV changed the title Draft: process/wg: do not check if transport data length is divisible by 16 process/wg: do not check if transport data length is divisible by 16 Dec 16, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (84b4f7d) 40.90% compared to head (e0dbd6f) 40.91%.

Files Patch % Lines
process/wg.cpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
+ Coverage   40.90%   40.91%   +0.01%     
==========================================
  Files         100      100              
  Lines        8826     8826              
  Branches     1312     1312              
==========================================
+ Hits         3610     3611       +1     
+ Misses       4446     4443       -3     
- Partials      770      772       +2     
Flag Coverage Δ
tests 40.91% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hynekkar hynekkar self-assigned this Jan 24, 2024
@hynekkar hynekkar merged commit 47a2ded into CESNET:master Jan 24, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants