Document antiforgery HTTP method limitations and HttpMethodOverride interaction#66772
Open
GrantTotinov wants to merge 1 commit into
Open
Document antiforgery HTTP method limitations and HttpMethodOverride interaction#66772GrantTotinov wants to merge 1 commit into
GrantTotinov wants to merge 1 commit into
Conversation
Contributor
|
Thanks for your PR, @GrantTotinov. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
There was a problem hiding this comment.
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 forPOST,PUT, andPATCH. - 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. |
d1f4827 to
6535052
Compare
Open
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Document antiforgery HTTP method limitations and HttpMethodOverride interaction
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