c# - ASP.NET Model Binder Infinite Loop -
i'm having issue default asp.net url-form-encoded model binder enters infinite loop.
the issue can reproduced creating apicontroller:
public class testcontroller : apicontroller { public httpresponsemessage put([frombody] data data) { return new httpresponsemessage(httpstatuscode.nocontent); } } and following data models:
public class data { public string title { get; set; } public subdata subdata { get; set; } } public class subdata { public ilist<item> items { get; set; } } public class item { public ilist<subitem> subitems { get; set; } } public class subitem { public string name { get; set; } } then call controller via:
$.ajax({ url: '/api/test', type: 'put', data: { title: 'hello', subdata: { items: null } } }); i've created issue , full example here: https://aspnetwebstack.codeplex.com/workitem/2280
the problem
passing data.subdata.items property null causes model binder go infinite loop. continue consume memory until there isn't left. once memory gone, testcontroller called , data parameter null (no exception thrown). passing empty array or not passing property @ allow binder work properly.
debugging asp.net source indicates infinite loop located in collectionmodelbinder.bindcomplexcollectionfromindexes method. indexnames iterator while(true) , binding sub item works, didbind never set false, never breaks out of foreach. selects method because value client null.
simply sending empty array not sufficient since attacker use launch of dos attack.
questions
- where can report or further help? codeplex site looks dead , mvc 4.
- is there way override behavior of model binder avoid situation (i'm looking global solution)?
any appreciated.
Comments
Post a Comment