diff -Nur perl-CGI-FormMagick-0.93/lib/CGI/FormMagick/Events.pm perl-CGI-FormMagick-0.93_bz10626/lib/CGI/FormMagick/Events.pm --- perl-CGI-FormMagick-0.93/lib/CGI/FormMagick/Events.pm 2005-10-31 18:24:02.000000000 +0100 +++ perl-CGI-FormMagick-0.93_bz10626/lib/CGI/FormMagick/Events.pm 2018-10-10 08:17:20.871139677 +0200 @@ -79,6 +79,13 @@ } else { $self->debug_msg("Validation successful."); + # Don't run any post event unless it's a POST request + return unless (($self->{cgi}->request_method || '') eq 'POST'); + if ($self->{csrf} and ($self->{cgi}->param('csrf_token') || '') ne $self->{cgi}->param('csrf_token_compare')){ + warn "CSRF protection blocked request\n"; + return $self->error($self->localise('CSRF_VALIDATION_FAILURE')); + } + # find out what the form post_event action is. my $post_form_routine = $self->{xml}->{'post-event'}; @@ -130,6 +137,14 @@ sub page_post_event { my ($self) = @_; $self->debug_msg("This is the page post-event."); + + # Don't run any post event unless it's a POST request + return unless (($self->{cgi}->request_method || '') eq 'POST'); + if ($self->{csrf} and ($self->{cgi}->param('csrf_token') || '') ne $self->{cgi}->param('csrf_token_compare')){ + warn "CSRF protection blocked request\n"; + return $self->error($self->localise('CSRF_VALIDATION_FAILURE')); + } + if (my $post_page_routine = $self->page->{'post-event'}) { $self->debug_msg("The post-routine is $post_page_routine"); $self->do_external_routine($post_page_routine); diff -Nur perl-CGI-FormMagick-0.93/lib/CGI/FormMagick/HTML.pm perl-CGI-FormMagick-0.93_bz10626/lib/CGI/FormMagick/HTML.pm --- perl-CGI-FormMagick-0.93/lib/CGI/FormMagick/HTML.pm 2018-10-09 16:57:49.511171415 +0200 +++ perl-CGI-FormMagick-0.93_bz10626/lib/CGI/FormMagick/HTML.pm 2018-10-09 17:01:20.380167138 +0200 @@ -182,6 +182,9 @@ print qq( \n); print qq( \n); print " ",$fm->{cgi}->state_field(), "\n"; # hidden field with state ID + if ($fm->{cgi}->param('csrf_token_compare')){ + print " {cgi}->param('csrf_token_compare') . "\">\n"; + } print "