[Bug 43896] New: Patrons can't log in with a cardnumber that matches another patron's userid
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Bug ID: 43896 Summary: Patrons can't log in with a cardnumber that matches another patron's userid Initiative type: --- Sponsorship --- status: Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Authentication Assignee: koha-bugs@lists.koha-community.org Reporter: kyle@bywatersolutions.com QA Contact: martin.renvoize@openfifth.co.uk CC: dpavlin@rot13.org Target Milestone: --- Since bug 40286, checkpw_internal only checks the password of the patron whose userid matches the login. If that string is also another patron's cardnumber, the cardnumber owner can no longer log in with their own password. Before 26.05 Koha fell back to the cardnumber match, so logins that worked for years break on upgrade. Each failed attempt also increments login_attempts on the userid owner. This affects everything that goes through C4::Auth::checkpw To recreate: 1) Create patron A with cardnumber TESTCARD and a password 2) Create patron B with userid TESTCARD and a different password 3) Log into the OPAC as TESTCARD with patron A's password 4) Note "You entered an incorrect username or password" 5) Note patron B's login_attempts went up -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |40286 See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=33905 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40286 [Bug 40286] Make C4::Auth::checkpw_internal use Koha::Patrons->find_by_identifier -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |kyle@bywatersolutions.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #1 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 208826 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208826&action=edit Bug 43896: Unit tests Patch from commit d0dccba -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #2 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 208827 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208827&action=edit Bug 43896: Patrons can't log in with a cardnumber that matches another patron's userid Bug 40286 made checkpw_internal use Koha::Patrons->find_by_identifier, which only returns the userid match when an identifier is one patron's userid and another patron's cardnumber. Before that, Koha tried the userid match and then the cardnumber match. Now the cardnumber owner can't log in with their own password, and each attempt counts as a failed login on the other patron. This patch restores the cardnumber fallback when the password doesn't match. Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/Auth.t 3) Note the test failures 4) Apply this patch 5) prove t/db_dependent/Auth.t 6) All tests pass! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208826|0 |1 is obsolete| | Attachment #208827|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 208831 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208831&action=edit Bug 43896: Unit tests Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 208832 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208832&action=edit Bug 43896: Patrons can't log in with a cardnumber that matches another patron's userid Bug 40286 made checkpw_internal use Koha::Patrons->find_by_identifier, which only returns the userid match when an identifier is one patron's userid and another patron's cardnumber. Before that, Koha tried the userid match and then the cardnumber match. Now the cardnumber owner can't log in with their own password, and each attempt counts as a failed login on the other patron. This patch restores the cardnumber fallback when the password doesn't match. Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/Auth.t 3) Note the test failures 4) Apply this patch 5) prove t/db_dependent/Auth.t 6) All tests pass! Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #5 from David Nind <david@davidnind.com> --- Testing notes (using KTD): 1. To reproduced the issue using: - Mary Burton (49): . Card number: TESTCARD . User name: 23529000651225 . Password: Policy10 - Lisa Charles (37): . Card number: 23529000197047 . User name: TESTCARD . Password: Policy09 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com --- Comment #6 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- There are a couple efforts to entirely avoid this situation to happen. Not sure what we want to do, really. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=43898 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208831|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208832|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #7 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 209714 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209714&action=edit Bug 43896: Unit tests Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #8 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 209715 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209715&action=edit Bug 43896: Patrons can't log in with a cardnumber that matches another patron's userid Bug 40286 made checkpw_internal use Koha::Patrons->find_by_identifier, which only returns the userid match when an identifier is one patron's userid and another patron's cardnumber. Before that, Koha tried the userid match and then the cardnumber match. Now the cardnumber owner can't log in with their own password, and each attempt counts as a failed login on the other patron. This patch restores the cardnumber fallback when the password doesn't match. Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/Auth.t 3) Note the test failures 4) Apply this patch 5) prove t/db_dependent/Auth.t 6) All tests pass! Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208831|1 |0 is obsolete| | Attachment #208832|1 |0 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #209714|0 |1 is obsolete| | Attachment #209715|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #9 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- (In reply to Tomás Cohen Arazi from comment #6)
There are a couple efforts to entirely avoid this situation to happen. Not sure what we want to do, really.
Bug 43898 stops new conflicts and bug 43899 reports existing ones, but neither helps libraries that already have conflicts and lost logins when they upgraded to 26.05. This patch restores the pre-26.05 behavior for them, so I think we need it whatever we decide on 33905. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208831|0 |1 is obsolete| | Attachment #208832|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210420 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210420&action=edit Bug 43896: Unit tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210421 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210421&action=edit Bug 43896: Patrons can't log in with a cardnumber that matches another patron's userid Bug 40286 made checkpw_internal use Koha::Patrons->find_by_identifier, which only returns the userid match when an identifier is one patron's userid and another patron's cardnumber. Before that, Koha tried the userid match and then the cardnumber match. Now the cardnumber owner can't log in with their own password, and each attempt counts as a failed login on the other patron. This patch restores the cardnumber fallback when the password doesn't match. Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/Auth.t 3) Note the test failures 4) Apply this patch 5) prove t/db_dependent/Auth.t 6) All tests pass! Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210422 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210422&action=edit Bug 43896: (QA follow-up) Hash the password once, count failures for every patron and check the right patron's password The fallback to the cardnumber owner checked the password of the first patron found before the check that logs them in, so every successful login hashed the password twice. Failed attempts were also only counted for the userid owner: once they were locked, the password of the cardnumber owner could be guessed without limit. Add Koha::Patrons->search_by_identifier, which returns the patrons an identifier can refer to as a set, in one query on the indexed userid and cardnumber columns: the userid owner first, then the cardnumber owner. The owners of a unique patron attribute are only returned when nothing else matches, as find_by_identifier always did. find_by_identifier now uses it, and so does checkpw_internal, which checks the password of each of them in turn: it is hashed once per patron the identifier refers to, and once, as before, in the usual case. checkpw now counts a failed attempt for every patron the identifier refers to, also when the first one is locked, so that guessing the password of the cardnumber owner is as limited as for anyone else. Two callers check the password of a patron they already know by passing their userid, which can also be the cardnumber of another patron, and so accepted the password of that other patron. They now check that the password found is the one of the patron they are checking: * SIP: ILS::Patron->check_password * REST: POST /api/v1/public/patrons/{patron_id}/password, whose old_password could be the password of another patron To test: 1. prove t/db_dependent/Auth.t t/db_dependent/Koha/Patrons.t \ t/db_dependent/SIP/Patron.t t/db_dependent/api/v1/patrons_password.t 2. Create patron A with userid TESTCARD and patron B with cardnumber TESTCARD, with FailedLoginAttempts set to 3 3. Log in on the OPAC as TESTCARD with each of their passwords => Both can log in 4. Enter a wrong password as TESTCARD three times => Both accounts are locked 5. As patron A, change your password on the OPAC using the password of patron B as the current password (or with the REST route) => Refused Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210420|0 |1 is obsolete| | Attachment #210421|0 |1 is obsolete| | Attachment #210422|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #13 from David Nind <david@davidnind.com> --- Created attachment 210533 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210533&action=edit Bug 43896: Unit tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #14 from David Nind <david@davidnind.com> --- Created attachment 210534 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210534&action=edit Bug 43896: Patrons can't log in with a cardnumber that matches another patron's userid Bug 40286 made checkpw_internal use Koha::Patrons->find_by_identifier, which only returns the userid match when an identifier is one patron's userid and another patron's cardnumber. Before that, Koha tried the userid match and then the cardnumber match. Now the cardnumber owner can't log in with their own password, and each attempt counts as a failed login on the other patron. This patch restores the cardnumber fallback when the password doesn't match. Test Plan: 1) Apply the unit test patch 2) prove t/db_dependent/Auth.t 3) Note the test failures 4) Apply this patch 5) prove t/db_dependent/Auth.t 6) All tests pass! Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #15 from David Nind <david@davidnind.com> --- Created attachment 210535 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210535&action=edit Bug 43896: (QA follow-up) Hash the password once, count failures for every patron and check the right patron's password The fallback to the cardnumber owner checked the password of the first patron found before the check that logs them in, so every successful login hashed the password twice. Failed attempts were also only counted for the userid owner: once they were locked, the password of the cardnumber owner could be guessed without limit. Add Koha::Patrons->search_by_identifier, which returns the patrons an identifier can refer to as a set, in one query on the indexed userid and cardnumber columns: the userid owner first, then the cardnumber owner. The owners of a unique patron attribute are only returned when nothing else matches, as find_by_identifier always did. find_by_identifier now uses it, and so does checkpw_internal, which checks the password of each of them in turn: it is hashed once per patron the identifier refers to, and once, as before, in the usual case. checkpw now counts a failed attempt for every patron the identifier refers to, also when the first one is locked, so that guessing the password of the cardnumber owner is as limited as for anyone else. Two callers check the password of a patron they already know by passing their userid, which can also be the cardnumber of another patron, and so accepted the password of that other patron. They now check that the password found is the one of the patron they are checking: * SIP: ILS::Patron->check_password * REST: POST /api/v1/public/patrons/{patron_id}/password, whose old_password could be the password of another patron To test: 1. prove t/db_dependent/Auth.t t/db_dependent/Koha/Patrons.t \ t/db_dependent/SIP/Patron.t t/db_dependent/api/v1/patrons_password.t 2. Create patron A with userid TESTCARD and patron B with cardnumber TESTCARD, with FailedLoginAttempts set to 3 3. Log in on the OPAC as TESTCARD with each of their passwords => Both can log in 4. Enter a wrong password as TESTCARD three times => Both accounts are locked 5. As patron A, change your password on the OPAC using the password of patron B as the current password (or with the REST route) => Refused Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #16 from David Nind <david@davidnind.com> --- Added my sign off again, including for the QA follow-up, in case this helps with the QA. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #17 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Thanks David, that's really helpful :) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210535|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #18 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 211459 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211459&action=edit Bug 43896: (QA follow-up) Hash the password once, count failures for every patron and check the right patron's password The fallback to the cardnumber owner checked the password of the first patron found before the check that logs them in, so every successful login hashed the password twice. Failed attempts were also only counted for the userid owner: once they were locked, the password of the cardnumber owner could be guessed without limit. Add Koha::Patrons->search_by_identifier, which returns the patrons an identifier can refer to as a set, in one query on the indexed userid and cardnumber columns: the userid owner first, then the cardnumber owner. The owners of a unique patron attribute are only returned when nothing else matches, as find_by_identifier always did. find_by_identifier now uses it, and so does checkpw_internal, which checks the password of each of them in turn: it is hashed once per patron the identifier refers to, and once, as before, in the usual case. checkpw now counts a failed attempt for every patron the identifier refers to, also when the first one is locked, so that guessing the password of the cardnumber owner is as limited as for anyone else. Two callers check the password of a patron they already know by passing their userid, which can also be the cardnumber of another patron, and so accepted the password of that other patron. They now check that the password found is the one of the patron they are checking: * SIP: ILS::Patron->check_password * REST: POST /api/v1/public/patrons/{patron_id}/password, whose old_password could be the password of another patron To test: 1. prove t/db_dependent/Auth.t t/db_dependent/Koha/Patrons.t \ t/db_dependent/SIP/Patron.t t/db_dependent/api/v1/patrons_password.t 2. Create patron A with userid TESTCARD and patron B with cardnumber TESTCARD, with FailedLoginAttempts set to 3 3. Log in on the OPAC as TESTCARD with each of their passwords => Both can log in 4. Enter a wrong password as TESTCARD three times => Both accounts are locked 5. As patron A, change your password on the OPAC using the password of patron B as the current password (or with the REST route) => Refused Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Failed QA CC| |dcook@prosentient.com.au --- Comment #19 from David Cook <dcook@prosentient.com.au> --- While the QA follow-up is a much better patch, it would be a regression which would re-introduce bug 14323 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 --- Comment #20 from David Cook <dcook@prosentient.com.au> --- Honestly, I think the best thing to do would be to find cases where a string exists in the userid and cardnumber of different users, move it to a note or some other field, and then add a staff interface note saying that the user needs a new userid/cardnumber. We can have a note come up in the OPAC saying "A problem has occurred with your account. Please contact the library to restore access." or something. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43896 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=14323 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org