Skip to content

Session Context Bug fix#3724

Merged
RubenCerna2079 merged 11 commits into
mainfrom
dev/rubencerna/fix-session-context-insertion-bug
Jul 21, 2026
Merged

Session Context Bug fix#3724
RubenCerna2079 merged 11 commits into
mainfrom
dev/rubencerna/fix-session-context-insertion-bug

Conversation

@RubenCerna2079

@RubenCerna2079 RubenCerna2079 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

Solves bug related to how we handle specific queries with session-context.

What is this change?

  • Sets the claims inside the X-MS-CLIENT-PRINCIPAL header as parameters before using them inside of a query.

How was this tested?

  • Integration Tests
  • Unit Tests

Added test that ensures that invalid queries are not run through headers with session context.

Sample Request(s)

N/A

@RubenCerna2079 RubenCerna2079 changed the title Bug fix Session Context Bug fix Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix a SQL Server session-context vulnerability/bug by ensuring user-claim keys used with sp_set_session_context are parameterized (instead of being embedded as a string literal), and it adds a unit test intended to guard against regressions.

Changes:

  • Parameterize the @key argument passed to sp_set_session_context in MsSqlQueryExecutor.GetSessionParamsQuery.
  • Add a new EasyAuth unit test intended to ensure “invalid query” content in the EasyAuth header does not cause unintended database side-effects.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Core/Resolvers/MsSqlQueryExecutor.cs Parameterizes session-context keys to avoid claim-type string injection into sp_set_session_context.
src/Service.Tests/Authentication/EasyAuthAuthenticationUnitTests.cs Adds a test intended to validate that malicious EasyAuth header content does not lead to unintended behavior/side-effects.

Comment thread src/Service.Tests/Authentication/EasyAuthAuthenticationUnitTests.cs Outdated
Comment thread src/Core/Resolvers/MsSqlQueryExecutor.cs
Comment thread src/Service.Tests/Authentication/EasyAuthAuthenticationUnitTests.cs Outdated
@github-project-automation github-project-automation Bot moved this from Todo to Review In Progress in Data API builder Jul 15, 2026
…ncerna/fix-session-context-insertion-bug' into dev/rubencerna/fix-session-context-insertion-bug
Comment thread src/Service.Tests/Authentication/EasyAuthAuthenticationUnitTests.cs Outdated

@souvikghosh04 souvikghosh04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Please address the comments.

Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated
Comment thread src/Service.Tests/UnitTests/SqlQueryExecutorUnitTests.cs Outdated

@Aniruddh25 Aniruddh25 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.

Approving, but please move test to the right file.

@RubenCerna2079
RubenCerna2079 enabled auto-merge (squash) July 21, 2026 21:02
@RubenCerna2079
RubenCerna2079 merged commit eb800ee into main Jul 21, 2026
12 checks passed
@RubenCerna2079
RubenCerna2079 deleted the dev/rubencerna/fix-session-context-insertion-bug branch July 21, 2026 21:53
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Data API builder Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants