Skip to content

Commit 7fd2219

Browse files
Set max depth for JSON serializer to mitigate known DOS vulnerability (#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.
1 parent 974709d commit 7fd2219

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)