Skip to content

Document antiforgery HTTP method limitations and HttpMethodOverride interaction#66772

Open
GrantTotinov wants to merge 1 commit into
dotnet:mainfrom
GrantTotinov:issue-66687-docs
Open

Document antiforgery HTTP method limitations and HttpMethodOverride interaction#66772
GrantTotinov wants to merge 1 commit into
dotnet:mainfrom
GrantTotinov:issue-66687-docs

Conversation

@GrantTotinov
Copy link
Copy Markdown

@GrantTotinov GrantTotinov commented May 21, 2026

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
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Thanks for your PR, @GrantTotinov. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
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

2 participants