Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 5 tasks
mathetos opened this issue Oct 31, 2018 · 13 comments
Closed
1 of 5 tasks

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

mathetos opened this issue Oct 31, 2018 · 13 comments
Assignees

Comments

@mathetos
Copy link
Member

mathetos commented Oct 31, 2018

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

  • This bug describes functionality that once worked as expected in version X.X.X.
  • This bug describes functionality that never worked as expected.
  • I am not sure whether this functionality ever worked as expected.

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

  • Whether a donor is loggedout or logged in, they can donate multiple times without a nonce verification error
  • However this is fixed, it does not negatively impact the logged-out donors ability to see their donation history throughout the duration of the lifetime of their session cookie.

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
Copy link
Contributor

@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
Copy link
Member Author

mathetos commented Nov 1, 2018

@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
Copy link
Member Author

mathetos commented Nov 1, 2018

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

@kevinwhoffman
Copy link
Contributor

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

@mathetos
Copy link
Member Author

mathetos commented Nov 5, 2018

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
Copy link
Contributor

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
Copy link
Contributor

kevinwhoffman commented Nov 5, 2018

@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 #3820 (comment). Try your best to uncover the cause and report back before you leave for the week. Thanks.

@mathetos
Copy link
Member Author

mathetos commented Nov 6, 2018

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

image

@jaydeeprami
Copy link
Contributor

@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 #2580

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

@mathetos mathetos removed the urgent label Nov 8, 2018
@mathetos
Copy link
Member Author

mathetos commented Nov 8, 2018

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:

  • Running Give 2.2.5 (the version where this nonce issue existed)
  • Using a Cache plugin that didn't clear the JS files when a plugin was updated (Hummingbird)
  • Had a custom script that stripped out the version params on our assets, thus preventing us from cache busting the old JS file.

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!

@mathetos mathetos closed this as completed Nov 8, 2018
@kevinwhoffman
Copy link
Contributor

kevinwhoffman commented Nov 14, 2018

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
Copy link
Member Author

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
Copy link
Collaborator

@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.

DevinWalker pushed a commit that referenced this issue Nov 27, 2018
fix: nonce verification error when logging in/out between donations #3820
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants