Skip to content

Best SAST Tools for C# in 2026

Suphi Cankurt

Written by Suphi Cankurt

Key Takeaways
  • SonarQube Community Edition is the practical C# starting point, strong rule coverage, quality gates, works with Visual Studio and every CI system, free.
  • For deep taint analysis on .NET web apps, CodeQL, Checkmarx, and Fortify lead the field. CodeQL is free on public repos; the commercial two dominate regulated enterprise environments.
  • Snyk Code brings modern DeepCode-style analysis to C# with fast IDE feedback and cross-file taint. Semgrep adds custom YAML rules you can author yourself.
  • Security Code Scan and Microsoft DevSkim are useful zero-cost additions that run inside MSBuild or the IDE. They are baselines, not replacements.
  • A solid free stack for most .NET teams: SonarQube CE in CI, CodeQL on the main branch via GitHub Actions, Security Code Scan in MSBuild, DevSkim in Visual Studio. Add Snyk Code or SonarQube Developer Edition once you need cross-file taint in a pipeline.

C# and .NET run a huge share of enterprise code, internal business apps, ASP.NET web services, Azure workloads, Unity games. The language is statically typed and Roslyn-backed, which makes SAST both easier and harder than Python or JavaScript. This guide compares 8 SAST tools with real C# and .NET support: SonarQube, Checkmarx, Fortify, Snyk Code, Semgrep, CodeQL, Security Code Scan, and Microsoft DevSkim.

Looking for the full SAST landscape? This guide focuses on C# and .NET coverage. For all 50+ SAST tools including enterprise platforms, see the complete SAST tools list or the open source SAST tools guide.

Why C# SAST is different

C# looks superficially similar to Java, but the SAST problem is not the same. You are dealing with two runtimes that coexist in real codebases, the legacy .NET Framework 4.x world and modern .NET (Core, 5, 6, 7, 8, 9). Each has different sinks, different auth models, and different serialization traps.

The C# ecosystem leans heavily on frameworks: ASP.NET MVC, Razor Pages, Blazor, Entity Framework, ADO.NET, WCF, SignalR. A useful C# SAST tool needs to understand model binding, controller action attributes, Razor encoding rules, Entity Framework query composition, and the many serializers (BinaryFormatter, XmlSerializer, DataContractSerializer, Newtonsoft.Json, System.Text.Json).

The common C#-specific vulnerability patterns SAST tools target include insecure deserialization (BinaryFormatter and unsafe JSON.NET TypeNameHandling settings), SQL injection in raw ADO.NET and string-concatenated EF queries, XSS in Razor views that use @Html.Raw, path traversal in file upload and download endpoints, weak cryptography (MD5, SHA1, DES, ECB mode, hardcoded keys), missing or broken authorization attributes, and JWT validation flaws.

C# .NET also pairs naturally with SCA tools for NuGet dependency coverage, SAST handles your code, SCA handles the packages you pull in.


Top SAST tools for C#

1. SonarQube

SonarQube is the tool most .NET teams reach for first. Its C# analyzer is built on Roslyn, so it understands the language natively and integrates cleanly into Visual Studio, Rider, and every major CI system.

What SonarQube does well: Deep C# rule coverage, hundreds of rules across security, reliability, and maintainability. Quality gates block pull requests that introduce new issues. The Community Edition is free and covers a broad set of security rules including injection patterns, weak crypto, insecure deserialization, and unsafe cookie configuration.

Where SonarQube falls short: Cross-procedural taint analysis for C# is Developer Edition and above, which is a paid tier. Community Edition catches pattern-based security issues, but complex data flow across controllers, services, and repositories needs the commercial license.

Best fit: Any .NET team that wants one scanner for both security and code quality, with a strong Visual Studio and Azure DevOps integration story.

SonarCloud Issues view on a C# .NET project (SomeConsoleApplication/Program.cs) showing a Major Bug category with assignable status, filters for Type, Severity, Security Category, and Language — the Roslyn-based C# analysis described in the prose

2. Checkmarx

Checkmarx has been a mainstay in enterprise .NET shops for over a decade. Its C# SAST engine is strong on taint analysis and covers both .NET Framework and modern .NET.

What Checkmarx does well: Deep inter-procedural data flow analysis across very large C# codebases, including legacy .NET Framework monoliths where other tools struggle. Good coverage of ASP.NET MVC, Web API, and WCF patterns. Rich compliance reporting for PCI, HIPAA, ISO 27001, and industry-specific audits.

Where Checkmarx falls short: Scans are slow compared to Roslyn-based analyzers, full scans of big solutions can take hours. The developer experience has improved over the years but still lags the inline feedback of Snyk Code or SonarLint. Pricing is enterprise-oriented and not publicly listed.

Best fit: Regulated enterprises with large .NET estates, government contractors, and teams that need formal compliance reports.

Checkmarx SAST Results Viewer showing findings grouped by Language and Severity with a Java project block (116 results) listing Trust Boundary Violation in Session Variables, Stored XSS, SQL Injection, and Reflected XSS All Clients with source and sink node columns — the grouped results UI described in the prose
Note: Checkmarx and Fortify list “request a quote” pricing only — no public per-developer or per-scan number. Budget two to four months of sales cycle, a pilot on a representative repo, and a formal SOW before a purchase order lands. Plan around that timeline when comparing against a self-serve SaaS like Snyk Code.

3. Fortify Static Code Analyzer

Fortify Static Code Analyzer (now OpenText Fortify) is one of the longest-running commercial SAST platforms, with particularly strong legacy support. For organizations still running .NET Framework 4.x alongside modern .NET, Fortify tends to have coverage that newer tools skip.

What Fortify does well: Very broad C# rule coverage and a deep taint engine. Historically strong on old .NET patterns, WebForms, classic ASP.NET, WCF, which some modern scanners treat as second-class. Enterprise-grade Software Security Center (SSC) for tracking findings across large programs.

Where Fortify falls short: Scan time and resource usage are high. The UI and developer experience feel dated compared to newer SAST vendors. Like Checkmarx, pricing is not published and is oriented toward enterprise buyers.

Best fit: Large organizations with mixed .NET Framework and modern .NET portfolios, regulated industries, and teams with formal AppSec programs that already use Fortify elsewhere.

Fortify Audit Workbench displaying a Cross-Site Scripting Persistent finding in init_pdf_upload.java line 94 with the Analysis Evidence panel listing the taint trail through VDHPDFForm.java assignments and an Issue Summary showing the Data Flow classification

4. Snyk Code

Snyk Code brings DeepCode-derived analysis to C# with a developer-first workflow. Its C# engine performs cross-file taint analysis and runs fast enough for in-IDE feedback.

What Snyk Code does well: Fast scans with cross-file data flow tracking across C# projects, including ASP.NET Core controllers, services, and repositories. Solid IDE support in Visual Studio, Rider, and VS Code. Fix suggestions are concrete and contextual, which reduces the back-and-forth when triaging results.

Where Snyk Code falls short: The free tier is IDE-focused. Full CI/CD usage with taint analysis requires a paid plan. It is SaaS by default, source code is sent to Snyk’s infrastructure, which is a non-starter for air-gapped and classified environments.

Best fit: Development teams that want modern taint analysis for C# with first-class IDE ergonomics and fast feedback, without the heaviness of Fortify or Checkmarx.

Snyk Code Path Traversal finding (CWE-23) on ManualTestingController.cs showing a 12-step data flow in 1 file from an HTTP parameter workflowFullPath into System.IO.File.ReadAllText, with highlighted source and sink lines — concrete evidence of the cross-file C# taint analysis described in the prose

5. Semgrep

Semgrep treats C# as a first-class language in its pattern engine. The Semgrep Registry ships community rules for common .NET security issues, and teams can write custom YAML rules that match real AST patterns instead of regex.

What Semgrep does well: Custom rule authoring is the killer feature. If you have a proprietary .NET framework, internal APIs, or a recurring pattern you keep finding in reviews, you can codify it in minutes. The community registry covers OWASP-style C# rules, and Semgrep handles multi-language repositories in one scanner.

Where Semgrep falls short: Community Edition taint analysis for C# is more limited than Snyk Code or SonarQube Developer Edition. Deep cross-file data flow is a paid feature. On pure .NET-specific depth, SonarQube is still stronger out of the box.

Best fit: Teams that want to author their own .NET rules, or a shop with mixed languages (C# plus Go, Python, JavaScript) that wants a single scanner across the stack.

Semgrep policy editor with Supply Chain tab selected, creating a Block malicious dependencies policy scoped to all projects with the Block and leave a comment action, alongside a Critical severity main-branch-check Embedded Malicious Code finding on package-lock.json line 30

6. CodeQL

CodeQL is GitHub’s deep data flow engine. It models C# code as a queryable database and ships mature query packs for SQL injection, XSS, deserialization, SSRF, path traversal, and many more .NET-specific patterns.

What CodeQL does well: The deepest free C# taint analysis I know of. It understands ADO.NET, Entity Framework, ASP.NET MVC controllers, Razor templates, and serializers, and it traces tainted input across projects and files. On public GitHub repos it is free via GitHub Advanced Security; the github/codeql repo ships hundreds of production-grade C# queries.

Where CodeQL falls short: Scans are slow, expect 10 to 30 minutes on medium .NET solutions, longer on big ones. Private repos need GitHub Advanced Security, which is a per-seat commercial license. Writing custom QL queries has a steeper learning curve than Semgrep rules.

Best fit: .NET web apps and API services where deep injection analysis matters, especially teams already on GitHub and using Actions for CI.

CodeQL for VS Code basic query.ql (import csharp; from IfStmt ifstmt, BlockStmt block where ifstmt.getThen = block and block.isEmpty select ifstmt) running against a juice-shop PowerShell/C# database and returning 63 results in 22 seconds — the queryable-database approach described in the prose

Key Insight

For .NET, the depth that matters is framework-aware taint. Any scanner can flag SqlCommand with string concatenation. Only the scanners that know an ASP.NET MVC [FromBody] parameter is a tainted source, a Razor view with @Html.Raw is a sink, and a BinaryFormatter call crosses a trust boundary will find the bugs that matter in real ASP.NET code.


7. Security Code Scan

Security Code Scan is an open-source Roslyn analyzer for .NET. Because it runs inside MSBuild, it produces warnings directly in the build output with zero extra infrastructure.

What Security Code Scan does well: Covers a useful baseline of C# security patterns, SQL injection, XSS, CSRF misconfigurations, weak cryptography, insecure cookie settings, hardcoded passwords, and XXE. It integrates with every .NET CI pipeline because it is just another analyzer package.

Where Security Code Scan falls short: Development activity has slowed in recent years, so coverage of newer ASP.NET Core patterns is uneven. There is no cross-file taint analysis. It is a good first line, not a substitute for SonarQube, CodeQL, or a commercial scanner.

Best fit: Any .NET project that wants free, in-compiler security warnings. Pair it with SonarQube or CodeQL rather than relying on it alone.

Visual Studio Error List showing a Security Code Scan SCS0028 warning: 'Unsafe deserialization possible from 1st argument passed to serial.Deserialize', with the Build plus IntelliSense filter active and a right-click Suppress menu offering In Source or In Suppression File

8. Microsoft DevSkim

Microsoft DevSkim is a free IDE extension and CLI from Microsoft focused on surfacing risky patterns as you type. It is rule-driven and multi-language, with solid C# coverage for obvious footguns.

What DevSkim does well: Lightweight, instant feedback in Visual Studio, VS Code, and on the CLI. Catches weak crypto (MD5, SHA1, DES), hardcoded credentials, insecure randomness, dangerous APIs, and a long list of risky patterns. Rules are open source and easy to extend in JSON.

Where DevSkim falls short: It is a regex and pattern matcher, not a data flow engine. It will not trace tainted input across functions. Coverage is broad but shallow by design.

Best fit: Developer IDE workflow companion, pair DevSkim with a deeper scanner like SonarQube or CodeQL. It catches the easy things early, before they even hit a CI pipeline.

Microsoft DevSkim VS Code extension running devskim analyze in the integrated terminal on DevSkimCodeTest.java, returning SARIF-style JSON output with ruleId DS176298 and severity markers — the pattern-scanning model described in the prose

Comparison table

ToolTypeC# DepthTaint AnalysisLicenseBest For
SonarQubeSAST + qualityDeep RoslynPaid tiersOpen source / CommercialQuality + security combined
CheckmarxSAST (enterprise)Very deepCross-projectCommercialRegulated .NET enterprises
FortifySAST (enterprise)Very deepCross-projectCommercialMixed legacy + modern .NET
Snyk CodeSAST (commercial)Deep, modernCross-fileCommercial (free IDE)Developer-first taint
SemgrepSAST (multi-language)Strong patternsLimited (paid for full)Open source / CommercialCustom rules, polyglot
CodeQLSAST (deep analysis)Very deepCross-projectFree (public) / CommercialDeep injection analysis
Security Code ScanRoslyn analyzerBaselineNoneOpen sourceFree in-build warnings
Microsoft DevSkimPattern scannerShallow, broadNoneOpen sourceIDE-time quick wins

How to choose for your use case

Small team on a budget: Start with SonarQube Community Edition in CI, Security Code Scan in MSBuild, and DevSkim in Visual Studio. That is three zero-cost tools catching most common C# issues. Add CodeQL on the main branch if you are on GitHub.

Growing .NET product team: SonarQube CE plus CodeQL in GitHub Actions is a strong free baseline. When you outgrow it, Snyk Code or SonarQube Developer Edition adds cross-file taint analysis without the weight of an enterprise SAST vendor.

Regulated enterprise with large .NET estate: This is still Checkmarx and Fortify territory. They lead on deep analysis of legacy .NET Framework monoliths and on compliance reporting that auditors expect. Expect a pilot, long deployment, and a commercial contract. See the enterprise SAST tools guide for the broader landscape.

Azure-heavy shop on GitHub: SonarQube Community plus CodeQL in GitHub Actions covers the majority of what you need. Add Snyk Code for developer-loop taint or go straight to SonarQube Developer Edition if you want everything in one dashboard.

Polyglot monorepo (C# plus Go, Python, JavaScript): Semgrep is the natural anchor. Layer SonarQube for .NET-specific depth and CodeQL for the heavy taint queries on main.

Pro tip: For any .NET team that already lives on GitHub, the highest-value free combo is SonarQube Community in CI plus CodeQL via the github/codeql-action workflow on main. Security Code Scan in MSBuild and DevSkim in Visual Studio cover the IDE layer. Spend the pilot evaluation on Snyk Code vs SonarQube Developer Edition — two very different approaches to cross-file C# taint — instead of defaulting to Checkmarx or Fortify before you have concrete taint gaps in hand.

Open source vs commercial

Side-by-side comparison visual: left panel Free Open-Source Stack at $0/year (SonarQube Community, Security Code Scan, Microsoft DevSkim, CodeQL via Actions); right panel Enterprise Commercial requiring a license (Checkmarx CxSAST, Fortify SCA, Snyk Code, SonarQube Developer+) — summarizing the two paths discussed in this section

The free stack for C#, SonarQube CE, Security Code Scan, DevSkim, and CodeQL on public repos, covers pattern-based rules very well. The gap versus commercial tools is in cross-procedural taint analysis and in framework-specific depth for large, messy .NET Framework codebases.

Snyk Code and SonarQube Developer Edition both add inter-procedural taint that follows input from controllers through services to sinks. For ASP.NET MVC and Web API apps processing untrusted input, this matters: a tainted request parameter that passes through a binder and three helper methods before hitting a raw ADO.NET query will be missed by pattern matchers but caught by either of these.

Checkmarx and Fortify remain dominant in regulated enterprises. The reasons are usually non-technical, compliance reports auditors expect, long-standing procurement contracts, and ecosystems of SSO, RBAC, and ticket integrations. On pure detection depth for modern .NET web apps, CodeQL often matches or exceeds them in my experience. For legacy .NET Framework work, the commercial two still have an edge.

CodeQL bridges the gap if you do not need a commercial vendor relationship. Free on public repos, and for private repos it is part of GitHub Advanced Security.

For a more detailed look at free options, see the open source SAST tools guide. For buying considerations, see SAST vs SCA: which do you need first.

If your team works across multiple languages, the dedicated SAST picks for Java, Python, JavaScript and TypeScript, Go, and PHP each cover the tool-specific nuances that generic SAST lists miss.


FAQ

This guide is part of the resource hub.

Frequently Asked Questions

What is the best free SAST tool for C#?
SonarQube Community Edition is the strongest free option for C# and .NET. It ships hundreds of rules tailored to C#, covers both security and code quality, and integrates with Visual Studio, Rider, and every major CI system. For a pure open-source route, Security Code Scan and Microsoft’s Roslyn-based analyzers run inside the compiler and catch common injection and deserialization patterns without any extra infrastructure.
Is Security Code Scan still maintained?
Security Code Scan is an open-source Roslyn analyzer for .NET. Activity has slowed in recent years and it does not cover every modern ASP.NET Core pattern, so I treat it as a useful baseline rather than a replacement for SonarQube or a commercial scanner. It is still worth wiring into CI because it runs inside MSBuild with no separate server.
Does CodeQL work well for C#?
Yes. CodeQL ships a mature C# query pack covering SQL injection in ADO.NET and Entity Framework, deserialization via BinaryFormatter and XmlSerializer, path traversal, SSRF, and many MVC and Razor template flaws. It understands both .NET Framework and modern .NET (Core and later). For private repos you need GitHub Advanced Security; for public repos it is free.
Can I replace Checkmarx or Fortify with SonarQube?
It depends on the depth of taint analysis you need. SonarQube Developer Edition and above include cross-procedural taint analysis for C#, and for many teams that is enough. Checkmarx and Fortify still tend to lead on deep data flow across very large .NET Framework monoliths, compliance reporting (PCI, HIPAA, FedRAMP), and regulated-industry expectations. The honest answer: run a pilot on your real code before assuming any of them wins.
What vulnerabilities are most common in C# code?
The recurring C# patterns I see are insecure deserialization via BinaryFormatter or unsafe JSON.NET settings, SQL injection in raw ADO.NET and string-interpolated Entity Framework queries, XSS in Razor views that disable encoding, path traversal in file upload handlers, weak cryptography (MD5, SHA1, DES, ECB mode), missing authorization attributes on MVC controllers, and JWT validation flaws such as disabled signature checks.
Suphi Cankurt

Years in application security. Reviews and compares 209 AppSec tools across 11 categories to help teams pick the right solution. More about me →