From b7d4cdc1b404848fea9f96598f5ff2ec1f20b747 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 19 Nov 2019 14:51:50 +0000 Subject: [PATCH] Bug 23634: Prevent non-superlibrarians from editing superlibarian emails This patchset prevents a non-superlibrarian user from editing a superlibrarians email address via memberentry. This is to prevent a privilege escalation vulnerability whereby a user could update a superlibrarians contact details to match their own and then request a password reset via the OPAC. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- .../prog/en/includes/member-alt-address-style.inc | 4 ++++ .../prog/en/modules/members/memberentrygen.tt | 14 +++++++++----- members/memberentry.pl | 10 +++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style.inc index 69fb6649b8..7b3f9bbd70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style.inc @@ -222,7 +222,11 @@ + [% IF ( NoUpdateEmail ) %] + + [% ELSE %] + [% END %] [% IF ( mandatoryB_email ) %]Required[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 25c32db057..a211207a82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -690,7 +690,11 @@ legend:hover { [% END %] Primary email: + [% IF ( NoUpdateEmail ) %] + + [% ELSE %] + [% END %] [% IF ( mandatoryemail ) %] Required [% END %] @@ -707,13 +711,13 @@ legend:hover { [% END %] Secondary email: + [% IF ( NoUpdateEmail ) %] + + [% ELSE %] - [% IF ( mandatoryemailpro ) %] - Required [% END %] - - [% END # /UNLESS noemailpro %] - + [% IF ( mandatoryemailpro ) %] + Required [% IF ( mandatoryfax ) %] diff --git a/members/memberentry.pl b/members/memberentry.pl index cfdc06032e..714222abdb 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -101,6 +101,7 @@ my $step = $input->param('step') || 0; my @errors; my $borrower_data; my $NoUpdateLogin; +my $NoUpdateEmail; my $userenv = C4::Context->userenv; my @messages; @@ -166,6 +167,11 @@ if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) { my $logged_in_user = Koha::Patrons->find( $loggedinuser ); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); + # check permission to modify email info. + if ( $patron->is_superlibrarian && !$logged_in_user->is_superlibrarian ) { + $NoUpdateEmail = 1; + } + $borrower_data = $patron->unblessed; $borrower_data->{category_type} = $patron->category->category_type; } @@ -206,7 +212,8 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) push(@errors,"ERROR_$_"); } } - # check permission to modify login info. + + # check permission to modify login info. if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) { $NoUpdateLogin = 1; } @@ -827,6 +834,7 @@ $template->param( modify => $modify, nok => $nok,#flag to know if an error NoUpdateLogin => $NoUpdateLogin, + NoUpdateEmail => $NoUpdateEmail, ); # Generate CSRF token -- 2.20.1