Skip to content

[release/11.0.2xx] Avoid redundant dataflow in security analyzers - #56581

Merged
tannergooding merged 4 commits into
dotnet:release/11.0.2xxfrom
tannergooding:tannergooding-backport-56415-release-11.0.2xx
Nov 2, 2026
Merged

tannergooding merged 4 commits into
dotnet:release/11.0.2xxfrom
tannergooding:tannergooding-backport-56415-release-11.0.2xx

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Note

This backport description was drafted with GitHub Copilot.

Backport of #56415 to release/11.0.2xx

Fixes #56413.

Customer Impact

  • Customer reported
  • Found internally

CA5390 and CA5403 spent substantial analyzer time processing thousands of literal byte-array call sites even when no relevant cryptographic sink was reachable. Issue #56413 documents a 2,048-call reproduction where the analyzers accounted for 42.179 and 10.426 seconds of a 53.97-second build. The source PR's targeted reproduction measured about 128 seconds before and 2.3–2.5 seconds after. This backport skips sink-free methods and runs taint analysis once per method, while retaining value-content analysis when source recognition or control-flow decisions require it.

Regression

  • Yes
  • No

This is an analyzer performance optimization intended to preserve diagnostic behavior. Reachability checks account for implicit calls, initializers, branches, recursive helpers, and other cases that cannot be covered by a simple source-operation walk; ambiguous cases retain the full analysis. Regression tests cover these paths.

Testing

The NetAnalyzers solution build succeeded with 0 warnings and 0 errors. Focused tests on release/11.0.2xx passed: 348 passed, 1 skipped, 0 failed across the affected analyzer test classes.

Risk

Production changes are limited to security-analyzer dataflow and property-set analysis; no public API or diagnostic ID changes. The implementation keeps conservative fallbacks where reachability or value mapping cannot be established safely.

tannergooding and others added 3 commits October 10, 2026 06:08
Skip whole-method flow when no relevant sink is reachable and omit value-content flow when it cannot affect mapped operations. Preserve diagnostic behavior for implicit calls, initializers, conditional branches, and helper methods.

Co-authored-by: Copilot App <[email protected]>
(cherry picked from commit a5a0b02)
Co-authored-by: Copilot App <[email protected]>
(cherry picked from commit 7d020c1)
Co-authored-by: Copilot App <[email protected]>
(cherry picked from commit 57a73a7)
Copilot AI balanced review requested due to automatic review settings October 10, 2026 13:16
@tannergooding
tannergooding requested a review from a team as a code owner October 10, 2026 13:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟡 Changes recommended

Both value-content prepasses omit exception-filter control flow, potentially introducing false-positive diagnostics.

2 open findings
What changed in this PR

Backports security-analyzer performance optimizations that avoid redundant taint and value-content analyses while preserving diagnostic behavior.

Changes:

  • Adds sink-reachability and value-content prepasses.
  • Adds constant-value and constructor fast paths.
  • Expands C#/VB correctness and performance regression tests.
File Description
UseSharedAccessProtocolHttpsOnlyTests.cs Tests direct protocol constants and analysis counts.
TaintedDataAnalyzerTestBase.cs Adds reusable flow-counting scenarios.
ReviewCodeForXssVulnerabilitiesTests.cs Covers reachability and initializers.
ReviewCodeForSqlInjectionVulnerabilitiesTests.cs Covers sink-free and helper paths.
DoNotUseWeakKDFInsufficientIterationCountTests.cs Covers implicit calls, branches, and VB.
DoNotUseInsecureDeserializerJsonNetWithoutBinderTests.cs Tests value-content avoidance and helpers.
DoNotInstallRootCertTests.cs Adds constructor and VB coverage.
DoNotHardCodeEncryptionKeyTests.cs Tests reachability, single analysis, and branches.
DoNotHardCodeCertificateTests.cs Covers constructors and helper sinks.
DoNotDisableSchUseStrongCryptoTests.cs Tests direct switch filtering.
CountingCSharpSecurityAnalyzerTest.cs Adds analyzer instrumentation harness.
TaintedDataAnalysis.TaintedDataOperationVisitor.cs Recognizes literal arrays without value-content flow.
TaintedDataAnalysis.cs Makes value-content analysis conditional.
PropertySetAnalysis.PropertySetDataFlowOperationVisitor.cs Supports direct constructor mapping.
PropertySetAnalysis.cs Adds value-content necessity prepass.
ConstructorMapper.cs Adds value-independent constructor mapping.
UseSharedAccessProtocolHttpsOnly.cs Handles constant protocols directly.
SourceTriggeredTaintedDataAnalyzerBase.cs Adds sink reachability and single-pass analysis.
DoNotUseWeakKDFInsufficientIterationCount.cs Maps default-iteration constructors directly.
DoNotUseInsecureDeserializerJsonNetWithoutBinder.cs Adds analysis instrumentation.
DoNotSetSwitch.cs Avoids flow analysis for known benign constants.
DoNotInstallRootCert.cs Maps parameterless stores directly.

🧠 Review effort: Balanced

Keep exception-path analysis from propagating data through blocks that prerequisite analyses determine are infeasible.

Co-authored-by: Copilot App <[email protected]>

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

This looks good to me, and I am supportive of the backport to 11.0 servicing.

/cc @artl93

@jeffhandley
jeffhandley requested a review from artl93 October 27, 2026 21:55
@jeffhandley

Copy link
Copy Markdown
Member

@artl93 - Sending to you for review and backport consideration for post-GA 11.0 servicing. Per previous agreement on analyzers and SDK updates, these do not need to flow through Tactics, we just need local team approval, so it's your call on this and others like it. /cc @tannergooding

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

Approved, but see my comment in #56580 , the more we can see the full context of the plan, the more we can understand the overall risk. This is all goodness.

@tannergooding
tannergooding merged commit feb8ddb into dotnet:release/11.0.2xx Nov 2, 2026
23 of 25 checks passed
@tannergooding
tannergooding deleted the tannergooding-backport-56415-release-11.0.2xx branch November 2, 2026 18:17

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — bad86ff6 Deployed Nov 2, 2026 by tannergooding via pre_activation #11619
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants