GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [7.1.2 Cherry-pick] Validate PRELOGIN option offsets before reading option data by github-actions[bot] · Pull Request #4977 · dotnet/SqlClient

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Cherry-pick of #4902 (ff241b6) into release/7.1.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@priyankatiwari08 @github-actions
Validate PRELOGIN option offsets before reading option data (#4902)
c838dab
* Validate PRELOGIN option offsets before reading option data

ConsumePreLoginHandshake read the VERSION, ENCRYPT, INSTANCE, MARS and
FEDAUTHREQUIRED option headers and data without checking that they lie
within the received PRELOGIN response. A malformed response could cause an
IndexOutOfRangeException to escape from SqlConnection.Open/OpenAsync.

Read each option header through a helper that verifies the 4-byte header and
the option data it points to are within the response, and report a
CorruptedTdsStream parsing error otherwise. Responses that were previously
accepted are unaffected.

Add simulated-server tests covering out-of-range offsets, data truncated at
the end of the response, and truncated option headers for each option, on
both sync and async open paths, plus a well-formed control.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 7ef2b899-d3ce-43cc-91d5-a321d447d1d4

* Validate declared PRELOGIN option lengths and all option headers

Options the client reads must declare exactly their defined data length
(VERSION 6 bytes; ENCRYPT, INSTANCE, MARS and FEDAUTHREQUIRED 1 byte), so a
short option can no longer be read together with the bytes of the option that
follows it. Every other option header (THREADID, TRACEID, unknown options and
ENCRYPT under TDS 8) is now validated as well: the header and the declared
data must lie within the response.

Rename the helper parameter to expectedBytes and add tests for length
mismatches, a short option overlapping the next option's data, and bounds
violations in options the client does not read.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 7ef2b899-d3ce-43cc-91d5-a321d447d1d4

* Validate PRELOGIN total size and simplify option header parsing

- Read and validate each option header once, before dispatching on the
  option, using ReadPreLoginOptionHeader, which returns the data offset
  and length instead of advancing a ref offset.
- Treat THREADID, TRACEID and unrecognized options in a single branch
  that skips the option after its header is validated; drop Debug.Fail.
- Require the option tokens, headers, data and terminator to describe
  exactly the bytes of the response, rejecting undescribed bytes, data
  claimed by more than one option without a gap, and a missing
  terminator.
- Make the test TDS server write ENCRYPT and TRACEID data only when it
  writes the matching option header.
- Add tests for unknown options and for the total-size check.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 7ef2b899-d3ce-43cc-91d5-a321d447d1d4

---------

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 7ef2b899-d3ce-43cc-91d5-a321d447d1d4
@github-actions github-actions Bot added this to the 7.1.2 milestone Nov 3, 2026
@github-actions
github-actions Bot requested a review from a team as a code owner November 3, 2026 17:39
@github-project-automation github-project-automation Bot added this to SqlClient Board Nov 3, 2026
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Nov 3, 2026
@azure-pipelines

azure-pipelines Bot commented Nov 3, 2026

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mdaigle

mdaigle commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/azp run

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mdaigle
mdaigle approved these changes Nov 6, 2026
View reviewed changes
@azure-pipelines

azure-pipelines Bot commented Nov 6, 2026

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.18310% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.44%. Comparing base (be5e575) to head (c838dab).
⚠️ Report is 4 commits behind head on release/7.1.

Files with missing lines Patch % Lines
...t/src/Microsoft/Data/SqlClient/Parser/TdsParser.cs 97.18% 2 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/7.1    #4977      +/-   ##
===============================================
- Coverage        66.91%   65.44%   -1.48%     
===============================================
  Files              291      300       +9     
  Lines            45107    68099   +22992     
===============================================
+ Hits             30182    44564   +14382     
- Misses           14925    23535    +8610     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 65.44% <97.18%> (?)

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

☔ 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@priyankatiwari08
priyankatiwari08 merged commit 77fc845 into release/7.1 Nov 6, 2026
202 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@priyankatiwari08
priyankatiwari08 deleted the dev/automation/pr-4902-to-7.1.2 branch November 6, 2026 16:00
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Nov 6, 2026
This was referenced Nov 13, 2026
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 BobJWalker/Trident#182
Closed
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 BobJWalker/Trident#183
Closed
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 ChaosEngine/MyRainbow#477
Merged
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 giis-uniovi/qacover#649
Closed
Bump the dotnet-dependencies group with 4 updates Chris-Wolfgang/Etl-DbClient#641
Merged
Bump Microsoft.Data.SqlClient and Microsoft.Data.SqlClient.SNI.runtime angaravasist/sqloryn#15
Closed
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 NServiceBusCommunity/NServiceBus.Community.Attachments#959
Merged
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 bellerophon-dotnet/bellerophon#8
Closed
Bump Microsoft.Data.SqlClient.Extensions.Azure from 7.1.1 to 7.1.2 bellerophon-dotnet/bellerophon#9
Closed
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 AndreasReitberger/SharedMauiCoreLibrary#536
Merged
Bump Microsoft.Data.SqlClient from 5.1.5 to 7.1.2 Sneha-Hiremath-Seko/github-copilot-demo#10
Open
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 SimonCropp/LocalDb#1172
Merged
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 wallymathieu/todo-minimal-api-ef#250
Merged
Bump the sql group with 2 updates Chookees/ALog#73
Closed
Bump Microsoft.Data.SqlClient and Microsoft.OpenApi vindbrann/Autoprint#9
Closed
Bump Microsoft.Data.SqlClient and Microsoft.OpenApi vindbrann/Autoprint#34
Closed
Bump AWSSDK.S3 and 21 others standardbeagle/BifrostQL#53
Closed
This was referenced Nov 27, 2026
Bump Microsoft.Data.SqlClient and 4 others BabychPV/ECR#1008
Open
Bump the dotnet group with 16 updates phlppgdfry/docurelay-field#6
Closed
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 PxTools/PCAxis.Menu.MsSqlDatamodelMenu#118
Open
Bump the dotnet group with 16 updates phlppgdfry/docurelay-field#8
Open
Bump the minor-and-patches group with 24 updates MrtKrs/ErpIntegrationApi#1
Open
Bump the microsoft-core group with 9 updates MrtKrs/ErpIntegrationApi#2
Open
Bump Microsoft.Data.SqlClient from 5.2.3 to 8.0.0 abbgrade/PsDac#63
Open
Bump Microsoft.Data.SqlClient from 7.1.1 to 8.0.0 wesilios/Dapper.SpecificationExtension#108
Open
Bump Microsoft.Data.SqlClient from 7.0.2 to 8.0.0 Kraftlyftingasamband-Islands/kraft.results#817
Open
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 MBakkar2705/traceability-api-dotnet#49
Merged
Bump Microsoft.AspNetCore.Authentication.JwtBearer and 17 others farooqngp/edu-eco#44
Open
Bump Microsoft.Data.SqlClient and System.Text.Json devopsabcs-engineering/gh-advsec-devsecops#83
Open
Bump Microsoft.Data.SqlClient from 7.1.1 to 7.1.2 statisticssweden/DataportalXML#82
Open
Bump Microsoft.Bcl.Cryptography and 8 others mishka1c/mRemoteNX#14
Closed
Bump the microsoft group with 12 updates ericksonlopezf/dotnet-sql-builder#24
Open
Bump the microsoft group with 12 updates protobuf-net/protobuf-net#1399
Open
Bump the dotnet group with 12 updates newbothi/reservamed#50
Open
Bump coverlet.collector and 10 others newbothi/reservamed#51
Open
Bump Microsoft.Data.SqlClient from 7.1.1 to 8.0.0 olesme/ohirok.reqnroll#5
Closed
Bump Aspire.Hosting.Azure.ServiceBus and 21 others softvasco/ledger-core#134
Open
Bump FsCheck.Xunit.v3 and 17 others softvasco/ledger-core#135
Open
chore: Bump Microsoft.Data.SqlClient and System.Security.Cryptography.Pkcs Lethabarb/grow2notes#262
Open
Bump Microsoft.Data.SqlClient from 6.1.4 to 8.0.0 rpgrca/EjerciciosEnNET#745
Open
Bump Microsoft.Data.SqlClient and Microsoft.EntityFrameworkCore.SqlServer JASSBR/comptoir#27
Open
Bump Microsoft.Data.SqlClient and System.Security.Cryptography.Pkcs moberghr/beacon#288
Open
Bump the microsoft group with 17 updates ibrahimsamak/Azure-Kubernetes-AKS-ACR#60
Open
Bump Microsoft.AspNetCore.Authentication.JwtBearer and 7 others ahmedgndy/AlMotaheda_ERP#21
Open
Bump the minor-and-patch group with 13 updates Ashish-ingh123/billingrecon#13
Open
Bump coverlet.collector and 10 others Ashish-ingh123/billingrecon#14
Open
Bump Microsoft.Data.SqlClient and System.Security.Cryptography.Pkcs Ashish-ingh123/billingrecon#15
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mdaigle mdaigle mdaigle approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

SqlClient Board
Status: Done

Milestone

7.1.2

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mdaigle @priyankatiwari08
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.