Skip to content

C# CSRF query: add support for ASP.NET Core - #20983

Merged
smowton merged 2 commits into
github:mainfrom
smowton:smowton/feature/csharp-csrf-aspnetcore
Dec 8, 2025
Merged

C# CSRF query: add support for ASP.NET Core#20983
smowton merged 2 commits into
github:mainfrom
smowton:smowton/feature/csharp-csrf-aspnetcore

Conversation

@smowton

Copy link
Copy Markdown
Contributor

No description provided.

@smowton
smowton requested a review from a team as a code ownerDecember 8, 2025 11:51
CopilotAI review requested due to automatic review settings December 8, 2025 11:51

CopilotAI 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 extends the C# CSRF security query to detect missing anti-forgery token validation in ASP.NET Core applications, in addition to the existing ASP.NET MVC support.

Key changes:

  • Added ASP.NET Core framework support to the CSRF detection query
  • Refactored validation logic to handle both ASP.NET MVC and ASP.NET Core patterns
  • Added comprehensive test cases for ASP.NET Core scenarios

Reviewed changes

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

Show a summary per file
FileDescription
MissingAntiForgeryTokenValidation.qlExtended query logic to detect CSRF vulnerabilities in both ASP.NET MVC and ASP.NET Core controllers
MissingAntiForgeryTokenValidation.csAdded test cases demonstrating vulnerable and safe ASP.NET Core controller patterns
MissingAntiForgeryTokenValidation.expectedExpected query results for the new ASP.NET Core test cases
MissingAntiForgeryTokenValidation.qlrefQuery reference file for test execution
optionsExtractor configuration for ASP.NET Core test compilation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@smowton
smowton merged commit ef991e5 into github:mainDec 8, 2025
23 checks passed
@Plasma

Copy link
Copy Markdown

False positives are generated by this query when the validation attribute is not on the action but instead applied globally via https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.autovalidateantiforgerytokenattribute?view=aspnetcore-10.0

Sign up for freeto 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.

5 participants

@smowton@Plasma@hvitved@github-advanced-security