-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Add brute force protection on all methods wrapped by PublicShareMiddleware #35057
Conversation
Sounds like you want to do brute force protection, not rate limiting.
But seems like I should extend the docs with this a bit going forward. |
Let's have a look together tomorrow |
@nickvergessen Thanks for the explanation. Better like this? It still only protects against incorrect token attempts but not against incorrect share password. I'll squash the commits later if needed. |
This now also protects against invalid password attempts. |
6a817c5
to
f08e207
Compare
Rebased and squashed. |
$controllerClassPath = explode('\\', get_class($controller)); | ||
$controllerShortClass = end($controllerClassPath); | ||
$bruteforceProtectionAction = $controllerShortClass . '::' . $methodName; | ||
$this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $bruteforceProtectionAction); |
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.
Can we read if the controller itself has the annotation and then reuse that action or better not do anything, so it's not double slowed?
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.
Technically we can, just like the BruteForceMiddleware
does.
But as you said, what if the ShareController
is handled by the BruteForceMiddleware
in the future? sleepDelayOrThrowOnMax
would be called twice.
Also it would probably bring some confusion. Why would the PublicShareMiddleware
care about annotations that are bruteforce-related?
I think it's fine the way we do it. All methods having the token/password check are bruteforce protected.
Only weird aspect of this is when reading the controllers...nothing mentions bruteforce protection in OCA\Files_Sharing\Controller\PublicShareController
and OCA\Files_Sharing\Controller\ShareController
.
Should we add explicit comments pointing to the PublicShareMiddleware
in those controllers? And/or in the AuthPublicShareController
and PublicShareController
?
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.
@nickvergessen I kinda answered your question 😁. IMO it's fine and clearer like it is now.
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.
Good 👍🏽
But the one question is still up
ℹ️ master is 26 |
f08e207
to
eb5cbe0
Compare
eb5cbe0
to
8f6db2e
Compare
…ware if an invalid token is provided or when share password is wrong Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
8f6db2e
to
4a3f3be
Compare
/backport to stable25 |
/backport to stable24 |
/backport to stable23 |
The backport to stable25 failed. Please do this backport manually. |
The backport to stable24 failed. Please do this backport manually. |
The backport to stable23 failed. Please do this backport manually. |
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This adds a rate limit on all methods wrapped by PublicShareMiddleware if an invalid token is provided.
As the token check does not happen in the controller methods but in the middleware, we can't use the
@AnonRateThrottle
annotation on those methods.Remaining questions: