{"record":{"id":"39b3c5d35ed9845a","repo":"TechnitiumSoftware/DnsServer","slug":"qpm-limit-ipv6-prefix-valid-range-is-between-0-and","errorCode":null,"errorMessage":"QPM limit IPv6 prefix valid range is between 0 and 128.","messagePattern":"QPM limit IPv6 prefix valid range is between 0 and 128\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/DnsServer.cs","lineNumber":7449,"sourceCode":"        public IReadOnlyDictionary<int, (int, int)> QpmPrefixLimitsIPv6\n        {\n            get { return _qpmPrefixLimitsIPv6; }\n            set\n            {\n                if (value is null)\n                {\n                    _qpmPrefixLimitsIPv6 = new Dictionary<int, (int, int)>();\n                }\n                else if (value.Count > byte.MaxValue)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv6), \"QPM Prefix Limits for IPv6 cannot have more than 255 entries.\");\n                }\n                else\n                {\n                    foreach (KeyValuePair<int, (int, int)> qpmPrefixLimit in value)\n                    {\n                        if ((qpmPrefixLimit.Key < 0) || (qpmPrefixLimit.Key > 128))\n                            throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv6), \"QPM limit IPv6 prefix valid range is between 0 and 128.\");\n\n                        if ((qpmPrefixLimit.Value.Item1 < 0) || (qpmPrefixLimit.Value.Item2 < 0))\n                            throw new ArgumentOutOfRangeException(nameof(QpmPrefixLimitsIPv6), \"QPM limit value cannot be less than 0.\");\n                    }\n\n                    _qpmPrefixLimitsIPv6 = value;\n                }\n\n                ResetQpsLimitTimer();\n            }\n        }\n\n        public int QpmLimitSampleMinutes\n        {\n            get { return _qpmLimitSampleMinutes; }\n            set\n            {\n                if ((value < 1) || (value > 60))","sourceCodeStart":7431,"sourceCodeEnd":7467,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/DnsServer.cs#L7431-L7467","documentation":"Thrown by the QpmPrefixLimitsIPv6 property setter when any dictionary key (IPv6 prefix length) is outside 0-128. IPv6 addresses are 128 bits, so prefix lengths beyond that are invalid. Each entry is validated in a loop.","triggerScenarios":"Assigning QpmPrefixLimitsIPv6 a dictionary containing a key < 0 or > 128.","commonSituations":"Passing IPv4-style limits to the IPv6 property by mistake; off-by-one or typo in config; a negative value from a computation.","solutions":["Ensure all keys are integers in the range 0-128 inclusive.","Filter out-of-range keys before assignment."],"exampleFix":"// before\nserver.QpmPrefixLimitsIPv6 =\n    new Dictionary<int,(int,int)> { { 200, (100, 200) } }; // throws\n\n// after\nserver.QpmPrefixLimitsIPv6 =\n    new Dictionary<int,(int,int)> { { 64, (100, 200) } };","handlingStrategy":"validation","validationCode":"foreach (var key in qpmV6.Keys)\n    if (key < 0 || key > 128)\n        throw new InvalidOperationException($\"Invalid IPv6 prefix key: {key}\");\nserver.QpmPrefixLimitsIPv6 = qpmV6;","typeGuard":"static bool IsValidV6PrefixKey(int key) => key >= 0 && key <= 128;","tryCatchPattern":"try { server.QpmPrefixLimitsIPv6 = qpmV6; }\ncatch (ArgumentOutOfRangeException) { qpmV6 = qpmV6.Where(kv => kv.Key >= 0 && kv.Key <= 128).ToDictionary(k=>k.Key,v=>v.Value); server.QpmPrefixLimitsIPv6 = qpmV6; }","preventionTips":["Validate keys are in 0-128 before building.","Do not pass IPv4 prefix lists to the IPv6 property."],"tags":["dns","qpm","rate-limiting","ipv6","validation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}