Skip to content

Commit 4acaaeb

Browse files
BornToBeRootclaude
andcommitted
Fix: Limit RDAP response size
Responses (RDAP queries, referrals, bootstrap files) are limited to 10 MB, so a broken or malicious server cannot exhaust the memory. Larger responses fail as network error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4cd491a commit 4acaaeb

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎Source/NETworkManager.Models/RDAP/RDAPBootstrapService.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public RDAPBootstrapService()
9090
Timeout = TimeSpan.FromSeconds(30)
9191
};
9292

93+
_client.MaxResponseContentBufferSize = RDAPClient.MaxResponseSize;
9394
_client.DefaultRequestHeaders.UserAgent.ParseAdd("NETworkManager");
9495

9596
_stealthEndpoints = LoadStealthEndpoints();

‎Source/NETworkManager.Models/RDAP/RDAPClient.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public class RDAPClient : SingletonBase<RDAPClient>
3131
/// </summary>
3232
private const int MaxRedirects = 5;
3333

34+
/// <summary>
35+
/// Maximum size of a response (after decompression). Real RDAP responses are well below 1 MB. Larger responses
36+
/// are rejected, so a broken or malicious server (e.g. a referral target) cannot exhaust the memory.
37+
/// </summary>
38+
public const long MaxResponseSize = 10 * 1024 * 1024;
39+
3440
private static readonly JsonSerializerSettings SerializerSettings = new()
3541
{
3642
// Keep dates as strings. Newtonsoft would otherwise convert them to DateTime and lose the offset.
@@ -78,6 +84,7 @@ public RDAPClient()
7884

7985
foreach (var client in new[] { _client, _referralClient })
8086
{
87+
client.MaxResponseContentBufferSize = MaxResponseSize;
8188
client.DefaultRequestHeaders.UserAgent.ParseAdd("NETworkManager");
8289
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(RDAPMediaType));
8390
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

0 commit comments

Comments
 (0)