Skip to content

Commit 16f7a9e

Browse files
committed
Set max depth for JSON serializer to mitigate known DOS vulnerability
The other option is to update Newtonsoft.Json, which now also sets the maximum depth by default, but this mitigates without having to update.
1 parent 974709d commit 16f7a9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/JsonRpc/Serialization/SerializerBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected virtual JsonSerializer CreateSerializer()
1919

2020
protected virtual JsonSerializerSettings CreateSerializerSettings()
2121
{
22-
var settings = JsonConvert.DefaultSettings != null ? JsonConvert.DefaultSettings() : new JsonSerializerSettings();
22+
var settings = JsonConvert.DefaultSettings != null ? JsonConvert.DefaultSettings() : new JsonSerializerSettings { MaxDepth = 128 };
2323
AddOrReplaceConverters(settings.Converters);
2424
return _settings = settings;
2525
}

0 commit comments

Comments
 (0)