This is not a common combination of pieces, but should be properly documented anyway. Maybe Roslyn analyzer could help here as well.
- Server developer added
HttpMethodOverrideMiddleware (which is not default).
- Configured with form field mode (FormFieldName set) - header mode triggers CORS preflight and is not cross-origin exploitable.
- Method override registered before antiforgery in the pipeline.
- Target endpoint uses antiforgery.
- The endpoint accepts DELETE (or another non-POST/PUT/PATCH method).
We can explicitly document that AntiforgeryMiddleware and extensions like app.UseAntiforgery() only support checking a subset of methods (POST, PUT and PATCH), and if user needs other HTTP methods validated, they can resolve IAntifogery and validate the request explicitly.
This is not a common combination of pieces, but should be properly documented anyway. Maybe Roslyn analyzer could help here as well.
HttpMethodOverrideMiddleware(which is not default).We can explicitly document that
AntiforgeryMiddlewareand extensions likeapp.UseAntiforgery()only support checking a subset of methods (POST, PUT and PATCH), and if user needs other HTTP methods validated, they can resolveIAntifogeryand validate the request explicitly.