-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include rrl
-plugin (Response Rate Limiting)
#6904
base: master
Are you sure you want to change the base?
Conversation
This was one of the recommendations of the Trail of Bits audit: > Implement rate-limiting controls in CoreDNS. For instance, consider incorporating the `rrl` plugin, used for rate limiting, into the main set of CoreDNS plugins to help prevent DoS attacks Signed-off-by: Nicolai Søborg <git@xn--sb-lka.org>
@@ -56,4 +56,5 @@ import ( | |||
_ "github.com/coredns/coredns/plugin/tsig" | |||
_ "github.com/coredns/coredns/plugin/view" | |||
_ "github.com/coredns/coredns/plugin/whoami" | |||
_ "github.com/coredns/rrl/plugins/rrl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would want to copy the plugin into the repo for "built-in" plugins.
It's a good discussion here. For the current implementation,
For 1&2, it may be a small surprise when the user wanted to set a QPS for certain range of clients(or globally) but all requests are blocked once they triggered the rule. There are not many users using this plugin so far I guess. |
Totally agree with @jasonjoo2010 func TestDebit_internal(t *testing.T) {
rrl := defaultRRL()
rrl.window = 1 * second
rrl.responsesInterval = second / 10
rrl.initTable()
for i := 0; i < 100; i++ {
b, _, _ := rrl.debit(rrl.responsesInterval, "token")
if i < 50 {
time.Sleep(time.Second / 20)
} else {
time.Sleep(time.Second / 5)
}
fmt.Println("Balance for ", i+1, b)
}
} Resultslimit 10, window 0: limit 10, window 1 sec: limit 10, window 15 sec (default):
I would also like to see a standard token bucket algorithm so that the rate limiter does not allow more than N requests per second. |
Btw, I can share the simple internal fix for a literal QPS limiting purpose:
But as the plugin claims to follow the same behaviour of BIND9, I didn't raise this concern to official repo. The philosophy of BIND9 must be forbidding a client from sending further requests when it violates the rule, I guess. |
When we move this in tree, I think we should split the functionality of the rrl plugin into two separate plugins: response rate limiting, and request rate limiting. The rrl plugin was initially intended to be a response rate limiter (not request). Its goal was to prevent DNS reflection attacks specially. The implementation follows BIND's description of its synonymous feature designed for the same purpose. Later, request rate limiting was added to our implementation. In retrospect, request rate limiting should have been a separate plugin. These two functions have different goals, and should ideally track state/rates and limit requests/responses differently. When incorporating rrl into coredns as an internal plugin, it would be a good opportunity to remove the request rate limiting functionality, and break it out (or re-implement) into a separate plugin that can optimized for that purpose (in terms of performance and expected behavior). The observations above regarding "literal QPS limiting" vs BIND behavior underscores this: Expectations for request rate limiting are going to be different than response rate limiting geared for reflection attack prevention. Rather than these two functions being at odds in the same plugin, I think they would be better as two separate plugins. |
1. Why is this pull request needed and what does it do?
This is one of the recommendations in the Trail of Bits security audit:
2. Which issues (if any) are related?
Running a public coredns server, I see a lot of DNS amplification DDoS attacks.
I think it makes a lot of sense for
rrl
to be a build-in plugin (allowing for easier usage)3. Which documentation changes (if any) need to be made?
https://github.com/coredns/coredns.io/blob/master/content/explugins/rrl.md needs to be moved to the "non-ex" plugins folder. Maybe this repos README should include Response Rate Limiting as a feature?
4. Does this introduce a backward incompatible change or deprecation?
Nope