Bugzilla – Attachment 61673 Details for
Bug 18019
Add CSRF protection to authorities-home.pl (op==delete)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18019: Add CSRF protection to authorities-home.pl (op==delete)
Bug-18019-Add-CSRF-protection-to-authorities-homep.patch (text/plain), 2.83 KB, created by
Marcel de Rooy
on 2017-03-29 14:11:11 UTC
(
hide
)
Description:
Bug 18019: Add CSRF protection to authorities-home.pl (op==delete)
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-03-29 14:11:11 UTC
Size:
2.83 KB
patch
obsolete
>From 7b899a5710cd14ecaaf01eed6f9ed8f45965b06b Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 7 Feb 2017 09:09:33 +0100 >Subject: [PATCH] Bug 18019: Add CSRF protection to authorities-home.pl > (op==delete) >Content-Type: text/plain; charset=utf-8 > >Without this patch, it is possible to delete authority records with URL >manipulation. >Like: /cgi-bin/koha/authorities/authorities-home.pl?op=delete&authid=[XXX] > >Test plan: >[1] Go to Authorities. Search for some authorities (without links). >[2] Delete an authority. Should work. >[3] Apply patch. >[4] Construct an URL like above to delete another authority. Should fail. > Under Plack this results in an internal server error, the log tells > you: Wrong CSRF token. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Amended the test plan. >--- > authorities/authorities-home.pl | 13 +++++++++++++ > .../prog/en/modules/authorities/searchresultlist.tt | 3 ++- > 2 files changed, 15 insertions(+), 1 deletion(-) > >diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl >index 6e0a8fe..9b3a55e 100755 >--- a/authorities/authorities-home.pl >+++ b/authorities/authorities-home.pl >@@ -36,6 +36,7 @@ use C4::Search::History; > use Koha::Authority::Types; > use Koha::SearchEngine::Search; > use Koha::SearchEngine::QueryBuilder; >+use Koha::Token; > > my $query = new CGI; > my $dbh = C4::Context->dbh; >@@ -58,6 +59,12 @@ if ( $op eq "delete" ) { > debug => 1, > } > ); >+ >+ die "Wrong CSRF token" unless Koha::Token->new->check_csrf({ >+ session_id => scalar $query->cookie('CGISESSID'), >+ token => scalar $query->param('csrf_token'), >+ }); >+ > &DelAuthority( $authid, 1 ); > > if ( $query->param('operator') ) { >@@ -111,6 +118,12 @@ if ( $op eq "do_search" ) { > } > ); > >+ $template->param( >+ csrf_token => Koha::Token->new->generate_csrf({ >+ session_id => scalar $query->cookie('CGISESSID'), >+ }), >+ ); >+ > # search history > if (C4::Context->preference('EnableSearchHistory')) { > if ( $startfrom == 1) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >index 563c44e..76e4589 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >@@ -19,7 +19,8 @@ function confirm_deletion(id) { > + "&orderby=[% orderby %]" > + "&value=[% value |url %]" > + "&startfrom=[% startfrom %]" >- + "&resultsperpage=[% resultsperpage %]"; >+ + "&resultsperpage=[% resultsperpage %]" >+ + "&csrf_token=[% csrf_token %]"; > } > } > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18019
:
59969
|
59971
|
60417
|
61672
|
61673
|
61732
|
61740
|
61741