impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
339 stars 191 forks source link

fix: nonce verification error when logging in/out between donations #3820

Closed mathetos closed 5 years ago

mathetos commented 5 years ago

Bug Report

User Story

As a donor, I want to be able to donate multiple times. Currently, under just the right/wrong circumstances, I'll get a "nonce verification error" when I attempt to donate a second time.

Current Behavior

If a cookie gets cleared between two donations, then the second donation attempt always results in a "nonce verification error" and the user is reflected as logged-out regardless of whether they are logged in correctly or not.

Expected Behavior

A new session should be created between each donation attempt regardless of the donors logged-in or logged-out state.

Bug Type

Steps to Reproduce

  1. Login to a site and attempt to do a Test Gateway donation. it should be successful
  2. Then clear your cookies. You'll be logged out immediately.
  3. Attempt to donate again on the same form as previously and you'll get a "nonce verifcation error"

Possible Solution

THIS IS JUST MY BEST GUESS BASED ON THE BEHAVIOR: Ensure that when a donor attempts to donate a second time during the same session, that the old session is cleared correctly, and a new session is created.

Related

Acceptance Criteria

Environment

### WordPress Environment ### Home URL: https://php7.mattcromwell.com Site URL: https://php7.mattcromwell.com WP Version: 4.9.8 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: ✔ Language: en_US Permalink Structure: /%postname%/ Show on Front: posts Table Prefix Length: wp_ Table Prefix Length: 3 Table Prefix Status: Acceptable Admin AJAX: Accessible Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, refunded, failed, revoked, cancelled, abandoned, processing, preapproval ### Server Environment ### Hosting Provider: DBH: localhost, SRV: php7.mattcromwell.com TLS Connection: Connection uses TLS 1.2 TLS Connection: Probably Okay Server Info: Apache/2.4.29 (Unix) mod_hive/6.25 OpenSSL/1.0.1e-fips mod_fastcgi/2.4.6 PHP Version: 5.6.38 PHP Post Max Size: 32 MB PHP Time Limit: 45 PHP Max Input Vars: 1000 PHP Max Upload Size: 24 MB cURL Version: 7.59.0, OpenSSL/1.0.2k SUHOSIN Installed: – MySQL Version: 5.6.36 Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ gzip: ✔ GD Graphics Library: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Give Configuration ### Give Version: 2.3.0 Give Cache: Enabled Database Updates: All DB Updates Completed. Give Cache: Enabled Give Cache: ✔New Donation✔Donation Receipt✔New Offline Donation✔Offline Donation Instructions✔New User Registration✔User Registration Information✔Donor Note✔Email access Upgraded From: 2.2.0 Test Mode: Enabled Currency Code: USD Currency Position: Before Decimal Separator: . Thousands Separator: , Success Page: https://php7.mattcromwell.com/donation-confirmation-2/ Failure Page: https://php7.mattcromwell.com/donation-failed/ Donation History Page: https://php7.mattcromwell.com/donation-history-2/ Give Forms Slug: /donations/ Enabled Payment Gateways: Test Donation, Offline Donation Default Payment Gateway: Test Donation PayPal IPN Verification: Enabled PayPal IPN Notifications: N/A Donor Email Access: Enabled ### Active Give Add-ons ### Give - Database HealthCheck: ❌ Unlicensed – by WordImpress – 0.0.3 ### Other Active Plugins ### Better Search Replace: by Delicious Brains – 1.3.2 Debug Bar: by wordpressdotorg – 0.9 Email Cop: by Ashfame – 0.1.1 SG Optimizer: by SiteGround – 4.0.7 Transients Manager: by Pippin Williamson – 1.7.5 User Switching: by John Blackbourn & contributors – 1.4.0 ### Inactive Plugins ### Akismet Anti-Spam: by Automattic – 4.0.1 Beaver Builder Plugin (Pro Version): by The Beaver Builder Team – 1.7.3 Caldera Forms: by Caldera Labs – 1.5.7 Facebook Reviews Pro: by WordImpress – 1.1.1 Give - Form Field Manager: by WordImpress – 1.1 Give - Hook Helper: by Ravinder Kumar – 1.0 Give - PDF Receipts: by WordImpress – 1.0 Give - Per Form Emails: by WordImpress – 1.0.1 Give - Razorpay: by WordImpress – 1.1.0 Give - Recurring Donations: by WordImpress – 1.7.0 Give - Stripe Gateway: by WordImpress – 2.0.6 Give - Tributes: by WordImpress – 1.2 Give - Zapier: by WordImpress – 1.0 My Custom Functions: by Space X-Chimp – 4.22 WP Editor: by Benjamin Rojas – 1.2.6.3 WP Featherlight: by WP Site Care – 1.1.0 WP HTML Mail: by Hannes Etzelstorfer – 2.7 WP HTML Mail - Give: by Hannes Etzelstorfer – 1.0 WP Rollback: by WordImpress – 1.5 ### Theme ### Name: Storefront Version: 2.3.2 Author URL: https://woocommerce.com/ Child Theme: No – If you're modifying Give on a parent theme you didn't build personally, then we recommend using a child theme. See: How to Create a Child Theme
mehul0810 commented 5 years ago

@mathetos @DevinWalker @kevinwhoffman I've investigated on this issue and created a video how I am able to reproduce the issue. I'm thinking that this scenario with which I've reproduced the issue is not an ideal user behavior as clicking on the back button and trying to donate without refreshing the page is not good. Please check the video for more information.

Video Link: https://www.useloom.com/share/73dc75248ccb42b398b2341f67f90097

Let me know your thoughts on this or you have any different scenario to reproduce this issue.

mathetos commented 5 years ago

@mehul0810 When I tested, I refreshed the page once I was on the donation page again. I think this user-flow is HIGHLY unlikely, but I think the fact that this happens suggests to me that something about our nonce check and error messaging is not quite accurate because I believe the nonce is actually still correct, but it's something about how Give is working with the cookies that is incorrect.

mathetos commented 5 years ago

We have a customer reporting this error today, I'm asking them for exact replication steps: https://secure.helpscout.net/conversation/698817721/28396/

kevinwhoffman commented 5 years ago

@mehul0810 assigning to you but please wait until we get reproducible steps from @mathetos before looking into this.

mathetos commented 5 years ago

I got a duplicator file from the first user and was NOT able to replicate it locally at all. But then we got a second report from a user today (I added both HelpScout links in the OP). They pointed to their live page where you can see the problem just by switching to PayPal Standard. See here: https://www.learntherisk.org/donate/

If you can't see it anymore there, I've got a GIF: give-nonce-error

I asked them to try using "Transients Manager" to remove their transients and test again. Additionally, @kevinwhoffman noticed a JS error on that form related to Fee Recovery, so I asked them to deactivate that IF the transients clearing didn't solve it.

I'll report back when I hear back from them, but for now something is definitely off but it's very difficult to replicate.

kevinwhoffman commented 5 years ago

Here is the console error that appears after attempting to switch gateways in the site above. This doesn't necessarily mean Fee Recovery is the cause; it might just be the first script to encounter an error after the nonce failure.

image

kevinwhoffman commented 5 years ago

@jaydeeprami Please move this to the top of your list since @mehul0810 is out the rest of this week. We do not have specific steps to replicate, but we have definitely seen an increase in nonce validation errors recently.

Also note the nonce validation error described in the original post might be different from the nonce error that appears on gateway change in https://github.com/impress-org/give/issues/3820#issuecomment-436070255. Try your best to uncover the cause and report back before you leave for the week. Thanks.

mathetos commented 5 years ago

Two users confirmed that clearing Transients had no effect. One provided this stack trace from New Relic:

image

jaydeeprami commented 5 years ago

@kevinwhoffman,

I have try many cases to reproduce this issue but unable to do it. Below are cases which I have tested but not able to reproduce the issue from my end.

1) Process donation with new donor and then click on browser back button without refresh page and still can't reproduce issue 2) Process with create donation with new donor and then clear cookie and click on browser back button without refresh page and still can't reproduce issue 3) Logged out user case: -> Create donation and then Click on browser back button and try donation again without refresh page -> Create donation and then Click on browser back button and switch gateway then try donation again without refresh page

4) I have checked above all cases with options like Logged IN, Logged Out, With Login option enable and With Register + Login Option enable but could not reproduce the issue. 5) Also, I have tested with Fee recovery, Recurring Donation and FFM Addon but not able to reproduce issue. 6) I have also try to reproduce issue as per Matt suggest but can't reproduce.

Also, I have looked into live site ( https://www.learntherisk.org/donate/ ) and found one thing which cause this issue in that site.

On Gateway load, we are passing nonce in gateway load in ajax action but I have found that nonce option is not passed in Gateway load ajax request. Please see my attached screenshot from that site.

I am not sure why it's not passed as I have checked it in Core file and we are passing.

We have already resolved that issue https://github.com/impress-org/give/issues/2580

It might be possible that site using old version of Give.

mathetos commented 5 years ago

Thanks @jaydeeprami for your research into this issue. Each of the customer sites that reported this had a variety of problems with caching or running the wrong version of Give. Here's a few examples:

While they all had a common reason each was different in HOW it was happening and thus made it hard to find the commonality.

Closing for now, good work team!

kevinwhoffman commented 5 years ago

Reopening due to another possibly related report: https://wordpress.org/support/topic/paypal-standard-sometimes-works/

@ravinderk I'm assigning to you. Please use Give core version 2.3.0 and investigate this nonce issue. It seems to happen most frequently during payment gateway switches. Be sure to test all browsers.

mathetos commented 5 years ago

This user got it resolved by resetting his VPN... so it always seems to get resolved in one way or another still, but I still believe there is a root issue that is causing this. wordpress.org/support/topic/paypal-standard-sometimes-works

ravinderk commented 5 years ago

@kevinwhoffman @mathetos I am able to reproduce this issue. Donor will get failed nonce issue if donation form page cache generated when the donor was in session.