Closed (duplicate)
Project:
CAPTCHA
Version:
6.x-2.2
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2007 at 01:30 UTC
Updated:
12 Aug 2010 at 16:09 UTC
Jump to comment: Most recent file
Comments
Comment #1
mstef commentedThis could very easily be tied to my last bug
Is there anything else out there that accomplishes the same task that captcha does?
Comment #2
mstef commentedI believe I atleast found out where the problem is - just don't know the how to fix it..
function captcha_form_alter($formid, &$form) {
.......
if ($flag && isset($trigger)) {
$form['#submit'] = array('captcha_submit' => array()) + $form['#submit'];
if (!_captcha_validate($_POST['edit']['captcha_response'])) {
//use call_func because module_invoke does not allow call by reference.
if (module_hook($captcha_type, 'captchachallenge')) {
call_user_func_array($captcha_type.'_captchachallenge', array(&$form, &$_SESSION['captcha']));
}
}
}
That is the code that prints out the captcha on the forms you want them on. The IF statement IS being called even though the captcha IS NOT showing up. I haven't really looked yet, but whatever functions it is using to attach the form is where the problem is...
I think.
..Anyone out there wanna help?
Comment #3
mstef commentedmaking some more progress..
if you change that loop to:
if ($flag && isset($trigger)) {
$form['#submit'] = array('captcha_submit' => array()) + $form['#submit'];
//use call_func because module_invoke does not allow call by reference.
if (module_hook($captcha_type, 'captchachallenge')) {
call_user_func_array($captcha_type.'_captchachallenge', array(&$form, &$_SESSION['captcha']));
}
}
which just removes the middle IF statement - it achieves two goods things, but still one problem. 1) it shows the captcha after the login is submiited (w/ incorrect pw or username) 2) If the captcha entry was correct the first time, no more errors will be thrown.
but now the problem is this..the captcha changes after the login is submitted BUT only the first answer works...the answer remains in the text box - but it will look too weird if you keep it this way.
so we need ONE of two solutions:
1) once the captcha is verified for a certain form, it goes away until submission is done (dont like this one, this opens up spam now)
2) the captcha changes like it does, but needs a new answer (this is much better)
i will keep trying..anyone else feel free to jump in..the funny thing is I don't even know php
Comment #4
mstef commentedthe problem might be in :
function captcha_submit() {
if($_SESSION['captcha_correct']) {
unset($_SESSION['captcha_correct']);
unset($_SESSION['captcha']);
}
}
after submitting, if it is correct, we need the captcha to start from scratch, even if the password was incorrect and the form is still there. we need a brand new captcha then. if it is correct and the password is correct, then theres no form , and no problem.
this code calls to unset it if it is sucessful, but i think the problem is that since it is the same form (when the pw is wrong) that it doesnt show a new captcha...need some help
Comment #5
mstef commentedi think this might be important too..
the captcha submit function ONLY gets called if the login is completely successful...
function captcha_submit() {
if($_SESSION['captcha_correct']) {
unset($_SESSION['captcha_correct']);
unset($_SESSION['captcha']);
}
}
shouldn't it be called and reset regardless of the outcome of the login?
Comment #6
mstef commentedI can't figure this out..
Other people MUST be having this problem..and how about the node submission problem. With captcha enabled you CANNOT submit anything on my site..
No one can fix this?
Comment #7
mstef commentedAnother BUG: There is a way to bypass the captcha when logging in. I was able to log in after a few failed attempts and some other things while getting the captcha incorrect. And no one has noticed this?
Comment #8
mstef commentedIts easier than i thought...
Go to the login page (not block)
Enter a valid username / pw
ignore the captcha field
After the error flags SIMPLY press the 'log in' tab and BINGO
Comment #9
davemybes commentedI can confirm this behaviour. It also occurs in the 4.7.x-dev and 5.x-dev versions, on login blocks as well as the login pages.
Mike, I hope you don't mind, but I changed the topic description to show the type of problem. I have also changed the version to 5.x in the hope that it gets more visibility that way.
I'm afraid I don't have bags of time at the moment, but I'll try and give the code a look over during the week, even though my PHP is not that great.
Comment #10
mstef commentedI thought the rapid amount of posts would raise some attention. Thank you for supporting. I believe my other issue regarding node and comment submission is an extremely critical bug as well. That should be addressed as well.
Comment #11
njivy commentedActually, I think the problem is in
user_login_validate(). It assumes no other validation functions operate on that form, so it does not check for pre-existing errors.Here's what happens:
1. User enters an incorrect captcha response, a correct username, and a correct password.
2. Form is submitted.
3. Captcha (or textimage) sets a form error.
4. User.module logs the user in anyway.
5. The user sees the login form with an error regarding the captcha, but they are already logged in.
Comment #12
njivy commentedHere's a proposed patch for user.module.
wundo, if you think this patch is worthy, I'll let you take it from here. I know this is the wrong place to submit it.
Comment #13
mstef commentedawesome let me try it out. great to see someone finally taking an interest in the case. I will let you know how it works out. Did you look into the bug with previewing nodes and comments?
Comment #14
mstef commentedAm i doing something wrong? patch -p0 < user_login_captcha.patch ?
Comment #15
davemybes commentedMike, this one is probably easier if you just edit the user.module directly and add in the extra bit of code
!form_get_errors() &&.Comment #16
davemybes commentedI can confirm that this works for the login captcha in 4.7 and 5.x. Thanks for that. I'm not sure how the powers-that-be will feel about a core patch like that, but at least for those of us desperate for some kind of protection, its a nice quick fix.
Comment #17
heine commentedLogin as a side-effect of form validation is an abomination.
Please file a core issue.
Comment #18
mstef commentedAre you sure that doesn't effect anything else?
Comment #19
mstef commentedIs it possible to just block people who fail a login attempt say X amount of times in X amount of time, like most good forums do. Or maybe a time gap each login?
Just thinking..
Do you guys see the bug in this module that pertains to submitting nodes and comments if you press 'preview' ?
Comment #20
njivy commentedmikestefff, we only do one bug per bug report. If you see another problem, please submit another issue. This helps us keep track of everything.
Comment #21
mstef commentedi did a while ago. no one has addressed it.
Comment #22
rkn-dupe commentedGetting the same issue, on new user reg:
Enter code and user name correctly, enter address which is already in use. Asks for a new address but no code to be entered this time.
Comment #23
rkn-dupe commentedNo progress on this?
Comment #24
yched commentedEr, the way i understand it, the described 'bug' is the intended behaviour of the module.
The point is to prove you're human.
If you entered the correct captcha *once*, (and even if the other fields in the form failed validation for any reason) then you are verified as 'human', this is stored in you session and the module does not ask you to prove it once again.
Comment #25
mstef commentedThats irrelevant. Yes it does prove that you are human. But if you read the any of the posts you will see the actual problems.
Comment #26
amal850720 commentedI'm using Pressflow 6.16.77 with Captcha 6.x-2.2 and discovered the same problem. I searched Drupal and found this thread but the last activity was in 2007. Is there any update to this issue?
@yched: A malicious code could easily enter a wrong CAPTCHA code to access the login form without CAPTCHA.
@mikesteff: I have to agree.
Comment #27
soxofaan commentedI think this is a duplicate of #810534: Fix CAPTCHA session reuse
A fix is in the making,
and in the meantime there is also a workaround (see #810534: Fix CAPTCHA session reuse)
Comment #28
amal850720 commentedFollowing workaround #27.