-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
DoneThis issue has been fixedThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-model-binding
Milestone
Description
Describe the bug
Collections of complex types may bind unconditionally until int.MaxValue
elements are reached. This relates to #4939 but involves built-in model binders.
Similarly, nested types may recursively bind until the stack is exhausted. This may relate to #6616.
To Reproduce
Steps to reproduce the behavior:
- Using the current version of ASP.NET Core i.e.
master
- Create a simple model such as
private class LocationInfo { [FromHeader] public string GpsCoordinates { get; set; } public int Zipcode { get; set; } }
- Add an action to a controller or a handler to a page with a
List<LocationInfo>
argument - Post a request containing a `` header to the action
- Experience extremely slow response (as the collection fills up
int.MaxValue
items
Expected behavior
Expect model binding to detect the problem and throw
an Exception
informing the developer.
Additional context
Beyond [FromHeader]
, the problem may occur with [FromServices]
or a custom greedy model binder. It's possible other models can cause infinite recursion or extremely large collections in model binding.
Metadata
Metadata
Assignees
Labels
DoneThis issue has been fixedThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-model-binding