A dotnet source code review is a line-by-line security check of a C#, ASP.NET or ASP.NET Core application, done by reading the code and its configuration rather than only attacking the running app. It finds problems that testing from outside often misses: a controller with no authorisation attribute, a raw SQL string built from user input, a hard-coded connection string or an old NuGet package with a known flaw.
This guide explains what a good .NET review actually checks, how it differs between classic ASP.NET (.NET Framework) and modern ASP.NET Core, what you should prepare before the review starts and what you should receive at the end.
Key takeaways
- A .NET review covers the C# code, the configuration files (web.config, appsettings.json), the NuGet packages and the build and deployment settings, not just the code.
- The highest-value checks are authorisation on every controller and endpoint, data access (SQL injection), deserialisation, secrets handling and cryptography.
- Classic ASP.NET Web Forms and MVC apps on .NET Framework carry different risks from ASP.NET Core apps, so the reviewer must know both.
- Automated tools such as SonarQube, Checkmarx and Semgrep help with coverage, but every finding should be manually verified before it reaches your developers.
- Ask for findings mapped to OWASP categories with the exact file and line, a clear fix and a retest after you fix them.
Why an ASP.NET security review needs its own approach
.NET is a large, mature platform. Many Indian banks, NBFCs, insurers, government vendors and enterprise software firms run line-of-business applications written in C# over the last fifteen years or more. One company may have a Web Forms portal on .NET Framework 4.x, an MVC admin panel and a new ASP.NET Core API, all talking to the same SQL Server database.
Each of these frameworks has its own security features, its own defaults and its own common mistakes. ASP.NET Core gives you good protection out of the box, such as anti-forgery support and output encoding in Razor views, but only if developers do not switch it off. Older applications depend heavily on web.config settings that are easy to get wrong. A reviewer who only knows one of them will miss issues in the other.
If you are new to the idea of code review in general, our source code review guide covers the basics. This post focuses on what is specific to .NET.
What a dotnet source code review checks
A thorough review is organised around risk areas rather than files. Below are the areas a good reviewer works through, with what they look for in each.
1. Authentication and authorisation
This is where the most serious findings usually sit. Broken Access Control is A01 in the OWASP Top 10 (2021), and in .NET it often comes from small omissions. The reviewer checks that every controller and action that should be protected carries the right [Authorize] attribute or policy, and that [AllowAnonymous] is only used where it is meant to be.
They also look at object-level checks. An API action that loads an order by ID must confirm that the order belongs to the logged-in user, not just that a user is logged in. In ASP.NET Core they review authorisation policies and handlers, minimal API endpoint mappings, and any custom middleware that makes access decisions. In classic ASP.NET they review the authorization sections of web.config, location rules, forms authentication settings and custom membership providers.
2. Data access and injection
Entity Framework and parameterised ADO.NET queries protect against SQL injection when used correctly. The risk comes from string concatenation: SqlCommand built with user input, FromSqlRaw or ExecuteSqlRaw with interpolated or concatenated values, and dynamic stored procedures that build SQL inside the database. The reviewer traces user input from the controller down to the query to confirm it stays a parameter all the way.
The same tracing applies to other injection types: LDAP queries against Active Directory, XPath, command execution through Process.Start, and file paths built from request data (path traversal).
3. Deserialisation and XML handling
Unsafe deserialisation has caused some of the most serious .NET vulnerabilities over the years. The reviewer searches for BinaryFormatter, NetDataContractSerializer, LosFormatter, SoapFormatter and Json.NET configured with TypeNameHandling set to anything other than None. Microsoft has removed the in-box BinaryFormatter implementation from .NET 9, but older applications and those on .NET Framework may still use it, and a compatibility package can bring it back.
For XML, they check that XmlDocument, XmlReader and XmlTextReader are configured so that external entities and DTD processing cannot be abused (XXE). Defaults are safer in newer .NET versions, but older .NET Framework code needs a careful look.
4. Output encoding, XSS and CSRF
Razor encodes output by default, so cross-site scripting usually appears where developers bypass it: Html.Raw, MvcHtmlString, HtmlString, or JavaScript built from server-side strings. In Web Forms, the reviewer looks at controls that render unencoded text, places where request validation was disabled with validateRequest set to false, and ViewState handling.
For cross-site request forgery, they check that state-changing actions use anti-forgery tokens ([ValidateAntiForgeryToken] or the global filter in ASP.NET Core), and that APIs which rely on cookies are not left open. CORS policies are reviewed too, because AllowAnyOrigin combined with credentials, or a wildcard origin on a sensitive API, is a common mistake.
5. Secrets and configuration
Configuration is half the attack surface in .NET. The reviewer reads web.config and appsettings.json files (including environment-specific ones such as appsettings.Development.json) and checks for:
- Connection strings, API keys, SMTP passwords or JWT signing keys stored in plain text or committed to Git. Tools such as Gitleaks help find secrets in the full commit history, not just the current code.
- Debug settings left on in production, such as compilation debug set to true, customErrors set to Off, or the developer exception page enabled outside development.
- A hard-coded machineKey shared across environments, which can make ViewState and forms authentication tickets easier to attack.
- Missing HTTPS enforcement, HSTS, secure and HttpOnly cookie flags and sensible session timeouts.
- Verbose logging that writes passwords, tokens or personal data into log files.
6. Cryptography and data protection
The reviewer looks for weak algorithms (MD5, SHA1 for passwords, DES, TripleDES, RC2), ECB mode, hard-coded keys and initialisation vectors, and random values generated with System.Random where a cryptographically secure generator is needed. Passwords should be hashed with a proper password hashing approach, such as the ASP.NET Core Identity password hasher, not a plain hash. They also check how the ASP.NET Core Data Protection keys are stored and shared across servers.
7. NuGet packages and vulnerable components
Vulnerable and Outdated Components is A06 in the OWASP Top 10 (2021). The reviewer lists every NuGet package, including transitive ones, and checks them against known vulnerabilities. Commands such as dotnet list package --vulnerable, NuGet Audit warnings during restore in recent .NET SDKs, OWASP Dependency-Check and Syft/Grype all help here. They also flag target frameworks that are out of Microsoft support, because those stop receiving security fixes.
8. File uploads, logging and business logic
Upload handlers are checked for file type validation, size limits, storage outside the web root and safe file names. Logging is checked so that security events such as failed logins and permission denials are actually recorded (A09 in the OWASP Top 10). Finally, the reviewer reads business logic for flaws no tool understands: discounts applied twice, approval steps that can be skipped, or a role check done only in the front end.
Building a .NET API as well as a web front end? A code review and an API penetration test complement each other well. See how we approach API and web service penetration testing alongside the code.
ASP.NET Framework vs ASP.NET Core: what changes in the review
| Area | Classic ASP.NET (.NET Framework) | ASP.NET Core (.NET 6 and later) |
|---|---|---|
| Configuration | web.config: authorization rules, customErrors, compilation debug, machineKey, httpCookies | appsettings.json, environment variables, user secrets, Program.cs middleware order |
| Access control | web.config location rules, [Authorize] on MVC controllers, page-level checks in Web Forms | [Authorize] attributes, policies and handlers, minimal API endpoint mappings |
| XSS protection | Request validation, Web Forms control encoding, Razor in MVC | Razor encoding by default; review Html.Raw and tag helpers |
| CSRF | ViewState MAC, anti-forgery tokens in MVC | Anti-forgery middleware and filters; cookie-based APIs |
| Deserialisation | BinaryFormatter, LosFormatter, ViewState, older Json.NET settings | Json.NET TypeNameHandling, custom converters; BinaryFormatter removed in .NET 9 |
| Support status | Check the Framework version is still supported | Check the .NET version is still in support and patched |
C# secure code review: how the work is done
A good C# secure code review mixes tools and people. Neither works well alone.
- Scoping. The reviewer agrees which solutions, projects and repositories are in scope, the .NET versions used and the most sensitive features, such as payments, KYC or admin functions.
- Automated scanning. SAST tools such as SonarQube, Checkmarx and Semgrep scan the code for known risky patterns. Roslyn-based analyzers that ship with the .NET SDK also flag some security issues. Secret and dependency scanners run in parallel.
- Manual review. The reviewer reads the high-risk code by hand: authentication, authorisation, data access, file handling and anything that touches money or personal data. This is where business logic flaws and missing checks are found.
- Verification. Each tool finding is checked to remove false positives. Only real, confirmed issues go into the report.
- Reporting and retest. Findings are written up with the file, line, impact and a fix that fits .NET, then rechecked once your team has fixed them.
If you are comparing tools yourself, our posts on the best SAST tools and SAST vs DAST explain where each fits. The secure code review checklist gives a language-neutral starting point you can adapt for .NET.
Web.config security and other quick wins
Some issues are cheap to fix and appear again and again. Beyond the configuration points above, start with these before a review:
- Move secrets out of web.config and appsettings.json into a secret store or protected environment variables, and rotate any key that was ever committed to Git.
- Run dotnet list package --vulnerable on every project and upgrade what it flags.
- Search the solution for BinaryFormatter, TypeNameHandling, Html.Raw, FromSqlRaw and AllowAnonymous, and confirm each use is intended.
What to prepare before the review starts
A review goes faster and finds more when the reviewer has context. Have these ready:
- Read access to the repository, or a zipped copy of the full solution including configuration files with secrets masked.
- The .NET and framework versions, and a short note on how the app is built and deployed (IIS, Azure App Service, containers).
- A list of user roles and what each role is allowed to do.
- The most sensitive flows you want examined closely.
- Any earlier VAPT or code review reports, so known issues can be rechecked.
What you should receive at the end
Each finding should give the severity (usually CVSS-based), the OWASP category, the exact file and line, a short explanation of why it is a risk, and a fix written for .NET. Our post on VAPT report format covers what a good report looks like in more detail.
After your team fixes the issues, a retest should confirm each one as closed, partly fixed or still open. That closure evidence is what clients, auditors and enterprise customers usually ask for.
Frequently asked questions
How long does a .NET source code review take?
It depends on the size of the solution and how much of it is in scope. At Xtreme InfoSec, most source code review projects take 3-5 working days, and an express review can be completed within 2 working days when you need it quickly.
Is a SAST scan enough for a .NET application?
No. SAST tools are good at spotting known patterns such as string-built SQL or weak hashing, but they produce false positives and cannot judge business logic or missing authorisation. A manual review of the high-risk code is what finds those issues.
Do you need the full source code, or only part of it?
The full solution including configuration files gives the best result, because many .NET issues sit in web.config, appsettings.json, Program.cs or shared libraries. If only part of the code can be shared, the scope and limits should be written clearly in the report.
Should we do a code review or a penetration test?
They find different things. A code review sees everything in the code, including unused or hidden endpoints. A penetration test shows what an attacker can actually exploit on the running system. For critical applications, many teams do both.
Can you review old .NET Framework or Web Forms applications?
Yes. Older applications often need the review most, because they rely on web.config settings and serialisation features that newer versions have changed or removed. The report will also flag framework versions that are out of support.
Get your .NET application reviewed
Xtreme InfoSec reviews C#, ASP.NET and ASP.NET Core code by hand, backed by SonarQube, Checkmarx, Fortify and open-source tools. You get manually verified, OWASP-mapped findings with step-by-step fixes and a free retest. Source code review starts from a minimum of ₹15,000, with a fixed quote after scoping, or use our VAPT cost estimator for a quick idea.