Skip to content

fix: discard server Initial packets that carry a token - #3814

Merged
mxinden merged 3 commits into
mozilla:mainfrom
uwezkhan:client-initial-token
Aug 3, 2026
Merged

mxinden merged 3 commits into
mozilla:mainfrom
uwezkhan:client-initial-token

Conversation

@uwezkhan

Copy link
Copy Markdown
Contributor

preprocess_packet validates a received Initial's Token Length only in the server arm, through is_valid_initial. A client-received Initial matches none of those arms, so the token that decode_long already parsed is ignored and the packet goes on to be decrypted and processed. RFC 9000, Section 17.2.2 says a server MUST set the Token Length of an Initial to 0, and a client that receives an Initial with a non-zero Token Length MUST discard it or close with PROTOCOL_VIOLATION. A server, or an off-path injector that derived the public Initial keys, can hand the client an Initial that carries a token and neqo accepts it.

Before: the client silently accepted the illegal token. After: preprocess_packet drops the packet as soon as a client sees an Initial with a non-empty token, beside the existing client Initial/Handshake path check so coalesced and replayed packets are covered too. Discarding is the safer of the two behaviors the RFC permits here, because the token length sits outside packet protection and closing on it would let an off-path packet end the connection; the tradeoff is that a genuinely misbehaving server gets no error signal back.

@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.78%. Comparing base (be2c8d9) to head (de2f9b1).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3814   +/-   ##
=======================================
  Coverage   96.77%   96.78%           
=======================================
  Files         120      120           
  Lines       40854    40887   +33     
  Branches    40854    40887   +33     
=======================================
+ Hits        39538    39573   +35     
+ Misses       1291     1289    -2     
  Partials       25       25           
Flag Coverage Δ
freebsd 94.15% <100.00%> (+15.31%) ⬆️
linux 96.96% <100.00%> (ø)
macos 95.09% <100.00%> (+0.01%) ⬆️
windows 95.14% <100.00%> (+0.01%) ⬆️

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

Components Coverage Δ
neqo-common 99.23% <ø> (+0.13%) ⬆️
neqo-http3 95.40% <ø> (+<0.01%) ⬆️
neqo-qpack 97.26% <ø> (ø)
neqo-transport 97.72% <100.00%> (-0.01%) ⬇️
neqo-udp 95.37% <ø> (ø)
mtu 89.13% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 9.32%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 4 regressed benchmarks
✅ 77 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory simulated/10-streams/each-1048576-bytes 9.7 MB 12.4 MB -21.83%
❌ Simulation simulated/10-streams/each-1048576-bytes 230.1 ms 247.3 ms -6.96%
❌ Simulation coalesce_acked_from_zero 1 ranges 1.4 µs 1.4 µs -4.03%
❌ Simulation coalesce_acked_from_zero 3 ranges 1.8 µs 1.9 µs -3.14%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing uwezkhan:client-initial-token (de2f9b1) with main (76673b1)

Open in CodSpeed

Comment thread neqo-transport/src/connection/mod.rs Resolved
@uwezkhan
uwezkhan requested a review from omansfeld as a code owner July 30, 2026 08:30

@mxinden mxinden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the help!

@mxinden
mxinden enabled auto-merge August 1, 2026 12:35
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

No significant performance differences relative to 7f7750d.

All results
streams/walltime/1-streams/each-1000-bytes: Change within noise threshold.
       time:   [543.90 µs 545.88 µs 548.18 µs]
       thrpt:  [1.7397 MiB/s 1.7471 MiB/s 1.7534 MiB/s]
change:
       time:   [-1.0956% -0.5959% -0.0694] (p = 0.02 < 0.05)
       thrpt:  [+0.0694% +0.5994% +1.1077]
       Change within noise threshold.
Found 11 outliers among 100 measurements (11.00%)
1 (1.00%) high mild
10 (10.00%) high severe
streams/walltime/1000-streams/each-1-bytes: Change within noise threshold.
       time:   [11.143 ms 11.159 ms 11.176 ms]
       thrpt:  [87.384 KiB/s 87.515 KiB/s 87.643 KiB/s]
change:
       time:   [+1.5414% +1.7608% +1.9872] (p = 0.00 < 0.05)
       thrpt:  [-1.9485% -1.7303% -1.5180]
       Change within noise threshold.
streams/walltime/1000-streams/each-1000-bytes: Change within noise threshold.
       time:   [32.040 ms 32.083 ms 32.127 ms]
       thrpt:  [29.684 MiB/s 29.725 MiB/s 29.765 MiB/s]
change:
       time:   [+2.0454% +2.2589% +2.4591] (p = 0.00 < 0.05)
       thrpt:  [-2.4001% -2.2090% -2.0044]
       Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
streams-flow-controlled/walltime/1-streams/each-4194304-bytes: Change within noise threshold.
       time:   [27.312 ms 27.357 ms 27.403 ms]
       thrpt:  [145.97 MiB/s 146.21 MiB/s 146.46 MiB/s]
change:
       time:   [+2.0654% +2.2913% +2.5099] (p = 0.00 < 0.05)
       thrpt:  [-2.4485% -2.2400% -2.0236]
       Change within noise threshold.
streams-flow-controlled/walltime/10-streams/each-1048576-bytes: Change within noise threshold.
       time:   [71.632 ms 72.021 ms 72.427 ms]
       thrpt:  [138.07 MiB/s 138.85 MiB/s 139.60 MiB/s]
change:
       time:   [+0.7550% +1.5840% +2.4128] (p = 0.00 < 0.05)
       thrpt:  [-2.3559% -1.5593% -0.7493]
       Change within noise threshold.
Found 10 outliers among 100 measurements (10.00%)
1 (1.00%) low mild
9 (9.00%) high mild
transfer/walltime/pacing-false/varying-seeds: Change within noise threshold.
       time:   [18.424 ms 18.434 ms 18.445 ms]
       thrpt:  [216.87 MiB/s 216.99 MiB/s 217.11 MiB/s]
change:
       time:   [+1.6094% +1.6841% +1.7611] (p = 0.00 < 0.05)
       thrpt:  [-1.7306% -1.6562% -1.5839]
       Change within noise threshold.
transfer/walltime/pacing-true/varying-seeds: Change within noise threshold.
       time:   [18.740 ms 18.753 ms 18.766 ms]
       thrpt:  [213.16 MiB/s 213.30 MiB/s 213.45 MiB/s]
change:
       time:   [+0.4840% +0.5722% +0.6632] (p = 0.00 < 0.05)
       thrpt:  [-0.6589% -0.5689% -0.4817]
       Change within noise threshold.
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) low mild
2 (2.00%) high mild
transfer/walltime/pacing-false/same-seed: Change within noise threshold.
       time:   [18.506 ms 18.518 ms 18.530 ms]
       thrpt:  [215.87 MiB/s 216.00 MiB/s 216.14 MiB/s]
change:
       time:   [+0.8118% +0.9003% +0.9810] (p = 0.00 < 0.05)
       thrpt:  [-0.9715% -0.8923% -0.8053]
       Change within noise threshold.
transfer/walltime/pacing-true/same-seed: Change within noise threshold.
       time:   [18.679 ms 18.691 ms 18.703 ms]
       thrpt:  [213.87 MiB/s 214.01 MiB/s 214.15 MiB/s]
change:
       time:   [+0.0826% +0.1684% +0.2600] (p = 0.00 < 0.05)
       thrpt:  [-0.2593% -0.1681% -0.0825]
       Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) low mild

Download data for profiler.firefox.com or download performance comparison data.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Failed Interop Tests

QUIC Interop Runner, client vs. server, differences relative to main at be2c8d9.

neqo-pr as clientneqo-pr as server
neqo-pr vs. go-x-net: BP BA
neqo-pr vs. haproxy: M BP BA
neqo-pr vs. lsquic: baseline result missing
neqo-pr vs. msquic: A L1 C1
neqo-pr vs. mvfst: A 🚀BA
neqo-pr vs. neqo: A
neqo-pr vs. nginx: BP BA
neqo-pr vs. ngtcp2: CM
neqo-pr vs. picoquic: A
neqo-pr vs. quic-go: A
neqo-pr vs. quic-zig: B
neqo-pr vs. quiche: BP BA
neqo-pr vs. s2n-quic: ⚠️BA CM
neqo-pr vs. tquic: S BP BA
neqo-pr vs. xquic: ⚠️S R Z A L1 C1
aioquic vs. neqo-pr: CM
go-x-net vs. neqo-pr: CM
kwik vs. neqo-pr: BP BA CM
msquic vs. neqo-pr: 🚀C1 CM
mvfst vs. neqo-pr: Z L1 C1 CM
neqo vs. neqo-pr: A
openssl vs. neqo-pr: LR M A CM
quic-go vs. neqo-pr: CM
quiche vs. neqo-pr: 🚀C1 CM
quinn vs. neqo-pr: L1 ⚠️C1 V2 CM
s2n-quic vs. neqo-pr: CM
tquic vs. neqo-pr: CM
xquic vs. neqo-pr: M CM
All results

Succeeded Interop Tests

QUIC Interop Runner, client vs. server

neqo-pr as client

neqo-pr as server

Unsupported Interop Tests

QUIC Interop Runner, client vs. server

neqo-pr as client

neqo-pr as server

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Client/server transfer results

Performance differences relative to 10c9e0c.

Transfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.

Client vs. server Mean±σ Min–Max Median±MAD MiB/s±σ ΔMedian
neqo-neqo-newreno 79.9 ± 3.3 73.9 – 100.0 79.2 ± 2.1 400.5 ± 16.3 💔 +0.9 (+1.1%)

Table above only shows statistically significant changes. See all results below.

All results

Transfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.

Client vs. server Mean±σ Min–Max Median±MAD MiB/s±σ ΔMedian
google-google 464.2 ± 2.2 460.7 – 471.2 463.7 ± 1.6 68.9 ± 0.3
google-neqo-cubic 267.3 ± 2.0 264.6 – 273.0 267.1 ± 1.9 119.7 ± 0.9 +0.4 (+0.1%)
neqo-google-cubic 770.7 ± 2.7 763.5 – 780.2 770.3 ± 2.4 41.5 ± 0.1 +1.4 (+0.2%)
neqo-neqo-cubic 79.6 ± 2.9 71.7 – 88.9 79.7 ± 2.6 401.9 ± 14.5 +1.0 (+1.2%)
neqo-neqo-cubic-nopacing ⚠️ 80.2 ± 3.7 73.8 – 102.6 79.6 ± 2.2 399.2 ± 18.6 +0.0 (+0.0%)
neqo-neqo-newreno 79.9 ± 3.3 73.9 – 100.0 79.2 ± 2.1 400.5 ± 16.3 💔 +0.9 (+1.1%)
neqo-neqo-newreno-nopacing ⚠️ 80.5 ± 3.6 74.0 – 101.4 79.7 ± 2.1 397.3 ± 17.9 +0.0 (+0.0%)
neqo-quiche-cubic 191.9 ± 1.9 188.0 – 198.9 191.7 ± 1.6 166.7 ± 1.7 -0.0 (-0.0%)
neqo-s2n-cubic 214.9 ± 1.9 209.8 – 220.5 214.8 ± 1.2 148.9 ± 1.3 +0.2 (+0.1%)
quiche-neqo-cubic ⚠️ 136.8 ± 4.5 132.7 – 167.5 135.8 ± 1.6 233.9 ± 7.8 -0.3 (-0.2%)
quiche-quiche 134.8 ± 3.2 128.1 – 146.0 134.6 ± 2.9 237.4 ± 5.7
s2n-neqo-cubic 217.1 ± 1.6 213.5 – 223.0 216.9 ± 1.2 147.4 ± 1.1 -0.7 (-0.3%)
s2n-s2n ⚠️ 291.5 ± 25.8 278.0 – 390.9 284.7 ± 2.5 109.8 ± 9.7

Download data for profiler.firefox.com or download performance comparison data.

@mxinden
mxinden added this pull request to the merge queue Aug 3, 2026
Merged via the queue into mozilla:main with commit 30b2247 Aug 3, 2026
194 of 198 checks passed
mxinden-bot pushed a commit to mxinden-bot/neqo that referenced this pull request Aug 14, 2026
User-visible changes since v0.30.1:

- Update nss-rs to 0.14.4, now requiring NSS >= 3.126:
  mozilla#3874
- WebTransport getStats() support:
  mozilla#3835
- Reliable reset handling for HTTP/3:
  mozilla#3777
- Optionally close a connection after N consecutive PTOs:
  mozilla#3662
- Reject 0-RTT downgrade of h3 datagram and WebTransport settings:
  mozilla#3852
- Reject connection-specific header fields in HTTP/3 messages:
  mozilla#3806
- Reject qpack dynamic reference at or above required insert count:
  mozilla#3807
- Discard server Initial packets that carry a token:
  mozilla#3814
@mxinden mxinden mentioned this pull request Aug 14, 2026
mxinden-bot pushed a commit to mxinden-bot/neqo that referenced this pull request Aug 24, 2026
User-visible changes since v0.30.1:

- Update nss-rs to 0.14.4, now requiring NSS >= 3.126:
  mozilla#3874
- WebTransport getStats() support:
  mozilla#3835
- Reliable reset handling for HTTP/3:
  mozilla#3777
- Optionally close a connection after N consecutive PTOs:
  mozilla#3662
- Reject 0-RTT downgrade of h3 datagram and WebTransport settings:
  mozilla#3852
- Reject connection-specific header fields in HTTP/3 messages:
  mozilla#3806
- Reject qpack dynamic reference at or above required insert count:
  mozilla#3807
- Discard server Initial packets that carry a token:
  mozilla#3814
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.

4 participants