Skip to content

Fix: Prevent RELIABLE_RESET offset increase by using correct sentinel#6160

Open
basavaraj-sm05 wants to merge 4 commits into
microsoft:mainfrom
basavaraj-sm05:fix/reliable-reset-offset-check
Open

Fix: Prevent RELIABLE_RESET offset increase by using correct sentinel#6160
basavaraj-sm05 wants to merge 4 commits into
microsoft:mainfrom
basavaraj-sm05:fix/reliable-reset-offset-check

Conversation

@basavaraj-sm05

Copy link
Copy Markdown

Description

Fixes a bug where a peer could bypass the strictly-decreasing offset rule for RELIABLE_RESET frames.
Right now, QuicStreamProcessReliableResetFrame checks Stream->RecvMaxLength == 0 to see if this is the first RELIABLE_RESET we've received. But 0 is actually a valid ReliableOffset value!
If a peer sends a RELIABLE_RESET with offset 0, we update RecvMaxLength to 0. If they then send another one with offset 5000, the == 0 check still passes, and we end up increasing the offset to 5000 — which violates the spec.
So instead of checking against 0, this PR just uses the RemoteCloseResetReliable flag to check if we've seen a reliable reset frame yet.

Testing

Existing reliable reset tests pass fine since standard behavior isn't affected.
We might want to add a quick test case that sends a RELIABLE_RESET(offset=0) followed by a RELIABLE_RESET(offset=5000) to verify it gets rejected properly now.

Documentation

None needed, just an internal state fix.

@basavaraj-sm05
basavaraj-sm05 requested a review from a team as a code owner July 18, 2026 06:08

@guhetier guhetier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR.
Some nitpick on the comment, but looks good to me otherwise.
Adding a test for this corner case would be ideal.

Comment thread src/core/stream_recv.c Outdated
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.00%. Comparing base (dbbf8a6) to head (ba4576a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/core/sliding_window_extremum.c 35.71% 9 Missing ⚠️

❌ Your patch check has failed because the patch coverage (40.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6160      +/-   ##
==========================================
- Coverage   85.85%   85.00%   -0.86%     
==========================================
  Files          60       60              
  Lines       18974    18978       +4     
==========================================
- Hits        16291    16133     -158     
- Misses       2683     2845     +162     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@basavaraj-sm05

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Digiscrypt Technologies"

Comment thread src/test/lib/DataTest.cpp Outdated

//
// Set ReliableOffset to 0 — this is the corner case. The old code used
// RecvMaxLength == 0 as "first frame not yet received", which means

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's avoid comments referring to the past state of the code, that won't be relevant for future readers.
As far as they are concerned, this test validates the corner case where the reliable offset is 0.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fair enough! Removed the references to the old behavior and kept it focused on the corner case itself.

Comment thread src/test/lib/DataTest.cpp Outdated
Comment thread src/test/lib/DataTest.cpp Outdated
StreamReliableResetZeroOffset Context;

//
// We need to send at least 1 byte so that QueuedSendOffset > 0 and

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: for the sake of it, I'd send more than 1 byte, so there is data after the reliable reset offset.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good nit! Bumped it to 16 bytes so there's actually some data sitting after the reliable reset offset, which makes the test feel more realistic.

Comment thread src/test/lib/DataTest.cpp Outdated
Comment thread src/core/sliding_window_extremum.c
…nges, send more bytes, drop unnecessary sleep
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.

2 participants