当connectionData被更改/无效时,如何处理SignalR协商500服务器错误?

时间:2015-12-30 16:43:50

标签: asp.net json signalr

我们正在使用AppScan来测试我们的应用程序对任何类型的恶意攻击的漏洞。由于我们在应用程序中使用SignarR,因此AppScan的目标是:

https://ourdomain.com/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22homepagehub%22%7D%5D&_=1450307725286

并修改connectionData值(例如将其设置为%27)。这导致服务器抛出以下500错误:

  

异常来源Newtonsoft.Json消息错误转换值“{”name“:”homepagehub“}>”'> “键入'Microsoft.AspNet.SignalR.Hubs.HubDispatcher + ClientHubInfo'。路径'[0]',第1行,位置121.Stack跟踪Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader,Object value,CultureInfo culture,JsonContract contract,Type targetType)   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader,Type objectType,JsonContract contract,JsonProperty member,JsonContainerContract containerContract,JsonProperty containerMember,Object existingValue)   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list,JsonReader reader,JsonArrayContract contract,JsonProperty containerProperty,String id)   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader,Type objectType,JsonContract contract,JsonProperty member,Object existingValue,String id)   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader,Type objectType,JsonContract contract,JsonProperty member,JsonContainerContract containerContract,JsonProperty containerMember,Object existingValue)   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader,Type objectType,Boolean checkAdditionalContent)   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader,Type objectType)   在Microsoft.AspNet.SignalR.Json.JsonSerializerExtensions.Parse [T](JsonSerializer序列化程序,String json)   在Microsoft.AspNet.SignalR.Hubs.HubDispatcher.AuthorizeRequest(IRequest请求)   在Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2环境)   在Microsoft.Owin.Mapping.MapMiddleware.d__0.MoveNext()    - 从抛出异常的先前位置开始的堆栈跟踪结束 -   在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   在Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)   在System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   在System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)   基本例外   来源Newtonsoft.Json   消息无法转换或从System.String转换为Microsoft.AspNet.SignalR.Hubs.HubDispatcher + ClientHubInfo。   在Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(对象值,类型initialType,类型targetType)的堆栈跟踪   at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue,CultureInfo culture,Type targetType)   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader,Object value,CultureInfo culture,JsonContract contract,Type targetType)   查询字符串值   -clientProtocol 1.5   -connectionData [“   {\“name \”:\“homepagehub \”}> \“'>”]   -_ 1450307725286

现在我明白发生了什么,但我的问题是处理这个错误的最佳方法是什么?如何以及在哪里可以尝试,捕获并处理这些错误?在我看来,signalR应该以一些优雅的方式处理无效的json请求数据,但也许我错了吗?有没有人有任何建议如何解决这个问题?

0 个答案:

没有答案