Skip to content

Address CodeQL findings: PKCS#1 padding (SM03799) and weak hash (SM02196) - #4517

Merged
cheenamalhotra merged 3 commits into
mainfrom
dev/cheena/codeql-suppress-pkcs1-always-encrypted
Aug 10, 2026
Merged

Address CodeQL findings: PKCS#1 padding (SM03799) and weak hash (SM02196)#4517
cheenamalhotra merged 3 commits into
mainfrom
dev/cheena/codeql-suppress-pkcs1-always-encrypted

Conversation

@cheenamalhotra

@cheenamalhotra cheenamalhotra commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Addresses two CodeQL/SDL findings.

SM03799 — RSA PKCS#1 v1.5 signature padding (Always Encrypted)

CodeQL flags RSASignaturePadding.Pkcs1 in the Always Encrypted signing/verification paths, recommending PSS instead.

These are false positives. The encrypted CEK blob and column master key metadata signatures are defined by an external standard — they are produced and verified by SQL Server tooling and other client drivers. Switching to PSS would produce blobs no other client could verify. Suppression comments are added, matching the existing SM03796 suppressions already present for RSA-OAEP(SHA1) in the same file.

  • EncryptedColumnEncryptionKeyParameters.csSignHash/SignData (both NET and NETFRAMEWORK paths) and VerifyHash/VerifyData
  • ColumnMasterKeyMetadata.csSign() and Verify()

SM02196 — weak hash algorithm (PackageValidator)

  • PortablePdb.CreateHashAlgorithmSHA1 removed from the PDB checksum algorithm map. Modern compilers record SHA-2 checksums, and an unrecognized algorithm already degrades to an inconclusive result rather than a failure, so this is a no-op in practice while removing an SDL-banned hash.
  • AssemblyInspector.ComputePublicKeyToken — suppressed. SHA-1 is mandated by ECMA-335 for strong-name public key tokens and is used purely as an identity computation, not a security boundary.

Validation

  • Microsoft.Data.SqlClient.csproj (net9.0) builds clean — 0 warnings, 0 errors
  • PackageValidator tests: 61/61 passing

Checklist

  • Tests added or updated — N/A, no behavioral change requiring new tests
  • Public API changes documented — N/A, no API changes
  • Verified against customer repro (if applicable) — N/A
  • Ensure no breaking changes introduced

Always Encrypted requires RSA PKCS#1 v1.5 signature padding for both the
encrypted CEK blob and the column master key metadata. These formats are
fixed by the Always Encrypted specification and are produced/consumed by
SQL Server tooling and other drivers, so switching to PSS would break
interoperability.

Annotate the sign/verify call sites in EncryptedColumnEncryptionKeyParameters
and ColumnMasterKeyMetadata with CodeQL [SM03799] suppression comments,
matching the existing SM03796 suppressions for RSA-OAEP(SHA1).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 31c7a5d9-05c5-4a0c-bf1b-9bad1fc87d12
Copilot AI lite review requested due to automatic review settings August 8, 2026 05:04
@cheenamalhotra
cheenamalhotra requested a review from a team as a code owner August 8, 2026 05:04
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Aug 8, 2026
@cheenamalhotra cheenamalhotra added this to the 7.1.0-preview3 milestone Aug 8, 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 suppresses CodeQL rule SM03799 at Always Encrypted RSA signature call sites where RSASignaturePadding.Pkcs1 is required for interoperability with the Always Encrypted external specification, aligning with existing SM03796 suppressions in the same area.

Changes:

  • Add // CodeQL [SM03799] suppressions for RSA PKCS#1 v1.5 signing/verification used by encrypted CEK blobs (NET + NETFRAMEWORK paths).
  • Add // CodeQL [SM03799] suppressions for column master key metadata signing/verification.

Reviewed changes

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

File Description
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncrypted/EncryptedColumnEncryptionKeyParameters.cs Adds CodeQL suppressions for PKCS#1 v1.5 signature generation/verification in encrypted CEK handling.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncrypted/ColumnMasterKeyMetadata.cs Adds CodeQL suppressions for PKCS#1 v1.5 signature generation/verification for CMK metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Drop SHA1 from the portable PDB checksum algorithm map. Modern compilers
record SHA-2 checksums, and an unrecognized algorithm already degrades to
an inconclusive result rather than a failure, so this is a no-op in
practice while removing an SDL-banned hash.

Suppress the finding on ComputePublicKeyToken, where SHA-1 is mandated by
ECMA-335 for strong-name public key tokens and is used purely as an
identity computation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 31c7a5d9-05c5-4a0c-bf1b-9bad1fc87d12
Copilot AI review requested due to automatic review settings August 8, 2026 05:19
@cheenamalhotra cheenamalhotra changed the title Suppress CodeQL SM03799 for Always Encrypted PKCS#1 signatures Address CodeQL findings: PKCS#1 padding (SM03799) and weak hash (SM02196) Aug 8, 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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/AlwaysEncrypted/ColumnMasterKeyMetadata.cs:150

  • XML doc comment has a stray trailing quote after the closing tag, which makes the documentation XML malformed and can surface as CS1570/CS1587 warnings (and potentially fail the build with TreatWarningsAsErrors).
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="signature"/> is <see langword="null"/>.</exception>"

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 8, 2026 05:25
@cheenamalhotra cheenamalhotra moved this from To triage to In review in SqlClient Board Aug 8, 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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@cheenamalhotra cheenamalhotra added Hotfix 6.1.7 PRs targeting main that should be backported to release/6.1 branch for future hotfix Hotfix 7.0.3 PRs targeting main that should be backported to release/7.0 branch for next release. labels Aug 8, 2026
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.74%. Comparing base (9b20e5e) to head (882f759).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4517      +/-   ##
==========================================
- Coverage   64.63%   62.74%   -1.90%     
==========================================
  Files         288      283       -5     
  Lines       44088    67045   +22957     
==========================================
+ Hits        28497    42066   +13569     
- Misses      15591    24979    +9388     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 62.74% <100.00%> (?)

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.

@cheenamalhotra
cheenamalhotra merged commit c642196 into main Aug 10, 2026
365 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Aug 10, 2026
@cheenamalhotra
cheenamalhotra deleted the dev/cheena/codeql-suppress-pkcs1-always-encrypted branch August 10, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hotfix 6.1.7 PRs targeting main that should be backported to release/6.1 branch for future hotfix Hotfix 7.0.3 PRs targeting main that should be backported to release/7.0 branch for next release.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants