Skip to content

Commit

Permalink
Set max depth for JSON serializer to mitigate known DOS vulnerability (
Browse files Browse the repository at this point in the history
…#902)

The other option is to update Newtonsoft.Json, which now also sets the
maximum depth by default, but this mitigates without having to update.
  • Loading branch information
andyleejordan committed Dec 2, 2022
1 parent 974709d commit 7fd2219
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/JsonRpc/Serialization/SerializerBase.cs
Expand Up @@ -19,7 +19,7 @@ protected virtual JsonSerializer CreateSerializer()

protected virtual JsonSerializerSettings CreateSerializerSettings()
{
var settings = JsonConvert.DefaultSettings != null ? JsonConvert.DefaultSettings() : new JsonSerializerSettings();
var settings = JsonConvert.DefaultSettings != null ? JsonConvert.DefaultSettings() : new JsonSerializerSettings { MaxDepth = 128 };
AddOrReplaceConverters(settings.Converters);
return _settings = settings;
}
Expand Down

0 comments on commit 7fd2219

Please sign in to comment.