Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/funnelkit-stripe-woo-payment-gateway/admin/admin.php
+++ b/funnelkit-stripe-woo-payment-gateway/admin/admin.php
@@ -613,9 +613,15 @@
* @return string
*/
public function get_connect_url() {
+ $transient_key = 'fkwcs_connect_state_' . get_current_user_id();
+ $state_token = get_transient( $transient_key );
+ if ( empty( $state_token ) ) {
+ $state_token = wp_generate_password( 32, false );
+ set_transient( $transient_key, $state_token, 30 * MINUTE_IN_SECONDS );
+ }
$custom_args = [
- 'redirect' => admin_url( 'admin.php?page=wc-settings&tab=fkwcs_api_settings' ),
+ 'redirect' => admin_url( 'admin.php?page=wc-settings&tab=fkwcs_api_settings&fkwcs_state=' . $state_token ),
];
$get_unique_id = get_option( 'fkwcs_wp_stripe', '' );
@@ -1253,6 +1259,9 @@
if ( false === current_user_can( 'manage_woocommerce' ) ) {
return;
}
+ if ( ! $this->verify_connect_state() ) {
+ return;
+ }
$redirect_url = apply_filters( 'fkwcs_stripe_connect_redirect_url', admin_url( '/admin.php?page=wc-settings&tab=fkwcs_api_settings' ) );
$this->settings['fkwcs_con_status'] = 'failed';
@@ -1265,6 +1274,9 @@
if ( false === current_user_can( 'manage_woocommerce' ) ) {
return;
}
+ if ( ! $this->verify_connect_state() ) {
+ return;
+ }
$response = $_GET; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
$redirect_url = apply_filters( 'fkwcs_stripe_connect_redirect_url', admin_url( '/admin.php?page=wc-settings&tab=fkwcs_api_settings' ) );
@@ -1314,7 +1326,7 @@
$this->update_options( $this->settings );
if ( ! empty( $response['wp_hash'] ) ) {
- update_option( 'fkwcs_wp_hash', $response['wp_hash'], 'no' );
+ update_option( 'fkwcs_wp_hash', sanitize_text_field( wp_unslash( $response['wp_hash'] ) ), 'no' );
}
do_action( 'fkwcs_after_connect_with_stripe', $this->settings['fkwcs_con_status'] );
wp_safe_redirect( $redirect_url );
@@ -1325,6 +1337,26 @@
}
/**
+ * Verify the CSRF state token from the Stripe Connect OAuth callback.
+ *
+ * @return bool
+ */
+ private function verify_connect_state() {
+ $state_token = isset( $_GET['fkwcs_state'] ) ? sanitize_text_field( wp_unslash( $_GET['fkwcs_state'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( empty( $state_token ) ) {
+ return false;
+ }
+ $transient_key = 'fkwcs_connect_state_' . get_current_user_id();
+ $stored_token = get_transient( $transient_key );
+ if ( empty( $stored_token ) || ! hash_equals( $stored_token, $state_token ) ) {
+ return false;
+ }
+ delete_transient( $transient_key );
+
+ return true;
+ }
+
+ /**
* Check if stripe is connected
*
* @return bool
@@ -2693,7 +2725,7 @@
// Check if the user is an administrator, on the correct page, and the fkwcs_sync_stripe_tax parameter exists
- if ( is_admin() && current_user_can( 'manage_options' ) && isset( $_GET['page'], $_GET['tab'], $_GET['fkwcs_sync_stripe_tax'] ) && sanitize_text_field( $_GET['page'] ) === 'wc-settings' && sanitize_text_field( $_GET['tab'] ) === 'fkwcs_api_settings' && $_GET['fkwcs_sync_stripe_tax'] === 'true' ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ if ( is_admin() && current_user_can( 'manage_options' ) && isset( $_GET['page'], $_GET['tab'], $_GET['fkwcs_sync_stripe_tax'], $_GET['_wpnonce'] ) && sanitize_text_field( wp_unslash( $_GET['page'] ) ) === 'wc-settings' && sanitize_text_field( wp_unslash( $_GET['tab'] ) ) === 'fkwcs_api_settings' && sanitize_text_field( wp_unslash( $_GET['fkwcs_sync_stripe_tax'] ) ) === 'true' && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'fkwcs_sync_stripe_tax' ) ) {
$option_key = 'fkwcs_secret_key';
$secret_key = get_option( $option_key );
--- a/funnelkit-stripe-woo-payment-gateway/admin/app/dist/bwfsg-app.asset.php
+++ b/funnelkit-stripe-woo-payment-gateway/admin/app/dist/bwfsg-app.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-url'), 'version' => '7fec352e10f527c7c60eaa9a732f69c6');
No newline at end of file
+<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-date', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-is-shallow-equal', 'wp-polyfill', 'wp-url'), 'version' => '0596afc87bf5d59d92c9152c4f8ca0ba');
No newline at end of file
--- a/funnelkit-stripe-woo-payment-gateway/funnelkit-stripe-woo-payment-gateway.php
+++ b/funnelkit-stripe-woo-payment-gateway/funnelkit-stripe-woo-payment-gateway.php
@@ -3,13 +3,13 @@
* Plugin Name: FunnelKit Payment Gateway for Stripe WooCommerce
* Plugin URI: https://www.funnelkit.com/
* Description: Effortlessly accepts payments via Stripe on your WooCommerce Store.
- * Version: 1.14.0.3
+ * Version: 1.14.0.4
* Author: FunnelKit
* Author URI: https://funnelkit.com/
* License: GPLv2 or later
* Text Domain: funnelkit-stripe-woo-payment-gateway
* WC requires at least: 3.0
- * WC tested up to: 10.6.0
+ * WC tested up to: 10.8.0
*
* Requires at least: 5.4.0
* Tested up to: 6.9.3
@@ -62,7 +62,7 @@
define( 'FKWCS_DIR', __DIR__ );
define( 'FKWCS_NAME', 'Stripe Payment Gateway for WooCommerce' );
define( 'FKWCS_TEXTDOMAIN', 'funnelkit-stripe-woo-payment-gateway' );
- ( defined( 'FKWCS_IS_DEV' ) && true === FKWCS_IS_DEV ) ? define( 'FKWCS_VERSION', time() ) : define( 'FKWCS_VERSION', '1.14.0.3' );
+ ( defined( 'FKWCS_IS_DEV' ) && true === FKWCS_IS_DEV ) ? define( 'FKWCS_VERSION', time() ) : define( 'FKWCS_VERSION', '1.14.0.4' );
add_action( 'plugins_loaded', array( $this, 'load_wp_dependent_properties' ), 1 );
}