It is possible to bruteforce passwords in Drupal. It is easier if you can do that without any evidence of the brute-force attack showing up in watchdog.
The attached patch updates the blogapi.module to add a call to watchdog when a login fails. This uses the same string from the user.module user_login_final_validate() in Drupal 6 so there is no string change (afaik).
There is no blogapi.module in core for Drupal 7 so I can't "apply to head and get a backport." I did however create an issue in #770590: make it harder to brute-force a password via blogapi_new and #770592: make it harder to brute-force a password via blogapi contrib which are the most logical replacements for blogapi.module for Drupal 7.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | login_flood.patch | 8.62 KB | grendzy |
| #12 | user_auth_770598.patch | 846 bytes | grendzy |
| #6 | 770598.patch | 1000 bytes | grendzy |
| #1 | 770589_blogapi_brute_force_harder-D6.patch | 599 bytes | greggles |
Comments
Comment #1
gregglesComment #2
damien tournoud commentedMakes a lot of sense.
Comment #3
grendzy commentedThe watchdog entry is awesome. I'd also like to suggest a new $op for hook_user(). Currently, there's no way for contrib modules to react to failures in user_authenticate(). This is a problem because while people have a hard time agreeing on the right response to brute-force attempts (tarpit? captcha? ban the IP? Ban the user? etc), lots of people want to do something about it.
A patch was posted in an old issue, see
http://drupal.org/node/117056#comment-1179721
Thoughts?
Comment #4
greggles@grendzy - That's a great idea for D8 core. I don't see it as an option for D6.x core (which is what this issue targets).
Comment #5
grendzy commentedOK, fair enough, but shouldn't the watchdog message originate from user_authenticate()? blogapi isn't the only module that auths users without using the user_login form (services module, etc).
Comment #6
grendzy commentedAlso realized we don't really need another hook_user($op) anyway, once this gets in a contrib module that wanted to react to "login failed" could capture the message with hook_watchdog and use that as a trigger. It'd be a tad indirect but the possibility exists.
Comment #7
gregglesGreat improvement. Back to rtbc like it was in comment #2.
Comment #8
drummComment #9
jbrauer commentedComment #10
gábor hojtsyCommitted this to Drupal 6. Looking at D7, while blogapi is not there, the latest patch has nothing to do with blogapi per say, better logging with blogapi is just a side-effect. I believe moving the logging to the more general place could be useful in D7 as well.
Comment #11
gregglesMakes sense to me.
Comment #12
grendzy commentedComment #13
c960657 commentedHow about also sharing the flood control in user_login_authenticate_validate()?
Comment #14
pwolanin commentedGood question - should all authentication mechanisms have the same flood control - or do we leave it up to each method?
Comment #15
grendzy commentedI'm inclined to agree with #13. Will work on a revised patch.
Comment #16
grendzy commentedHere's a new patch that decouples the flood protection from the form API.
Because the flood check needs to return multiple values, it's not possible to roll all this into user_authenticate(). So there's a new function to test the flood limits. In a way this is beneficial as contrib authors aren't forced into adopting the flood control if they don't want it.
A contrib module can simply call:
And get watchdog logging an flood protection without having to re-invent it all.
There are no tests in this patch however the login and flood system seems to have pretty thorough coverage in
user.test.There are no functional changes, just re-organizing code.Comment #17
grendzy commentedI'd like to revive this... anyone up for a review? If the consensus is that #16 is too late this close to beta, #12 still applies and is a straight port of what was committed to D6.
Patches still apply with small offset.
Comment #18
pwolanin commentedre: #16, I think it needs work because the flood_clear_event should be outside the user_authenticate if the call to user_flood_control() is outside it.
Comment #19
damienmckennaShould this be a Major ticket because it affects security?
Comment #20
grendzy commentedI don't mind if you change the priority - though a re-roll incorporating pwolanin's feedback would probably do more to move this forward.
Comment #21
mr.baileysMoving to 8.x-dev first.
Comment #22
greggles@mr.baileys - why? D8 this is in contrib?
Comment #23
crystaldawn commentedI recently had issues with several sites (all completely different clients) coming under heavy bruteforce login attacks, and this was the resulting solution ;)
https://www.drupal.org/project/cbp
"What is Crowd Bruteforce Protection?
Well, it's exactly what it says, it uses the Crowd Sourcing mentality for protecting your website, wikipedia explains it best: http://en.wikipedia.org/wiki/Crowdsourcing Currently it protects against Bruteforce logins and bans any IP that tries to login to your website X times"
It does much more than that short blurb above of course, but if your interested in reading more, you can read the project page, it does use a crowdsourcing idea for banning beyond just your own website. It makes as much use as possible from drupal's built in flood control and ip blocking and does not implement its own so that it could work with other modules that also utilize these drupal features if there even are any. It might not be the right solution for others, but for me it was perfect. If people start to use it, it'll have other side effects that could only help I think.
Comment #24
mgifford@greggles - This is a Core issue, so D8 would be right. Maybe I'm totally missing something though.
I'm also unassigning @grendzy as it's been 4 years.
Comment #25
greggles@mgifford blogapi was removed from Drupal 8 core and there is not Drupal 8 version of the contributed blogapi module. So, it only makes sense to fix this in 7.x/6.x.
Comment #26
mgiffordRight.... Thanks @greggles.