Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Document antiforgery HTTP method limitations and HttpMethodOverride interaction - #66772

#66772
Merged
cincuranet merged 3 commits into
dotnet:maindotnet/aspnetcore:mainfrom
GrantTotinov:issue-66687-docsGrantTotinov/aspnetcore:issue-66687-docsCopy head branch name to clipboard
Jun 4, 2026
Merged

Document antiforgery HTTP method limitations and HttpMethodOverride interaction#66772
cincuranet merged 3 commits into
dotnet:maindotnet/aspnetcore:mainfrom
GrantTotinov:issue-66687-docsGrantTotinov/aspnetcore:issue-66687-docsCopy head branch name to clipboard

Conversation

@GrantTotinov

@GrantTotinov GrantTotinov commented May 21, 2026

Copy link
Copy Markdown
Contributor

Document antiforgery HTTP method limitations and HttpMethodOverride interaction

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Description

Documents that AntiforgeryMiddleware and UseAntiforgery() only validate HTTP POST, PUT, and PATCH requests. Adds guidance for developers who need validation for other HTTP methods (for example, DELETE) to resolve IAntiforgery from DI and call ValidateRequestAsync or IsRequestValidAsync explicitly.

Also documents the interaction with HttpMethodOverrideMiddleware when configured with FormFieldName, where a POST request can be overridden to DELETE and bypass antiforgery validation.

Fixes #66687

Copilot AI review requested due to automatic review settings May 21, 2026 03:09
@github-actions github-actions Bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label May 21, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 21, 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 updates public API documentation to clarify antiforgery validation’s HTTP method scope and the security implications when combined with HttpMethodOverrideMiddleware (form-field mode), addressing scenarios where an overridden method like DELETE can bypass antiforgery middleware validation.

Changes:

  • Document that antiforgery middleware (UseAntiforgery / AntiforgeryMiddleware) only validates tokens for POST, PUT, and PATCH.
  • Add guidance for validating other HTTP methods by explicitly calling IAntiforgery.ValidateRequestAsync / IsRequestValidAsync.
  • Document the interaction between form-field HTTP method override and antiforgery validation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Middleware/HttpOverrides/src/HttpMethodOverrideExtensions.cs Adds remarks warning about form-field method override rewriting the request method before later middleware, and notes antiforgery method limitations.
src/Antiforgery/src/RequireAntiforgeryTokenAttribute.cs Adds remarks clarifying that UseAntiforgery validation is limited to POST/PUT/`PATCH and how to validate other methods manually.
src/Antiforgery/src/AntiforgeryApplicationBuilderExtensions.cs Adds remarks describing antiforgery method limitations, manual validation options, and the method-override interaction.

Comment thread src/Middleware/HttpOverrides/src/HttpMethodOverrideExtensions.cs Outdated
Comment thread src/Antiforgery/src/AntiforgeryApplicationBuilderExtensions.cs Outdated
@cincuranet

Copy link
Copy Markdown
Contributor

@DeagleGross Based on your #66687 (comment) do you want to add something here?

@cincuranet cincuranet self-assigned this Jun 1, 2026
@DeagleGross

Copy link
Copy Markdown
Member

I am fine with the changes here, I think we should change public docs and describe it there as well before closing the related issue: https://learn.microsoft.com/en-us/aspnet/core/security/anti-request-forgery?view=aspnetcore-10.0#antiforgery-with-minimal-apis

@cincuranet

Copy link
Copy Markdown
Contributor

@GrantTotinov Will you also open PR for https://github.com/dotnet/aspnetcore.docs or should I do it?

@GrantTotinov

Copy link
Copy Markdown
Contributor Author

@cincuranet Of course, I will open a PR as soon as possible.

@cincuranet

Copy link
Copy Markdown
Contributor

I'm going to merge this and keep an eye on the docs PR. Thanks @GrantTotinov.

@cincuranet

Copy link
Copy Markdown
Contributor

/ba-g Failures are unrelated.

@cincuranet
cincuranet merged commit bbb57bb into dotnet:main Jun 4, 2026
19 of 25 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview6 milestone Jun 4, 2026
@GrantTotinov

Copy link
Copy Markdown
Contributor Author

Awesome, thank you! Let me know if anything else is needed. @cincuranet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document antiforgery skip in AntiforgeryMiddleware for DELETE via HttpMethodOverride

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.