Skip to content

Commit 5e5ccb3

Browse files
committed
Fix – Provide CSRF hardening for Mailchimp List changes.
1 parent 2a3a535 commit 5e5ccb3

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

mailchimp.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: MailChimp
44
Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
55
Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
6-
Version: 1.5.8
6+
Version: 1.5.9
77
Author: MailChimp
88
Author URI: https://mailchimp.com/
99
*/
@@ -25,7 +25,7 @@
2525
*/
2626

2727
// Version constant for easy CSS refreshes
28-
define('MCSF_VER', '1.5.8');
28+
define('MCSF_VER', '1.5.9');
2929

3030
// What's our permission (capability) threshold
3131
define('MCSF_CAP_THRESHOLD', 'manage_options');
@@ -185,6 +185,14 @@ function mailchimpSF_request_handler() {
185185
if (isset($_POST['mcsf_action'])) {
186186
switch ($_POST['mcsf_action']) {
187187
case 'login':
188+
if (
189+
! current_user_can( MCSF_CAP_THRESHOLD ) ||
190+
! isset( $_POST['_mcsf_nonce_action'] ) ||
191+
! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_mcsf_nonce_action'] ) ), 'mc_login' )
192+
) {
193+
wp_die('Security check failed.');
194+
}
195+
188196
$key = trim($_POST['mailchimpSF_api_key']);
189197

190198
try {
@@ -572,8 +580,17 @@ function mailchimpSF_save_general_form_settings() {
572580
* Sees if the user changed the list, and updates options accordingly
573581
**/
574582
function mailchimpSF_change_list_if_necessary() {
575-
// Simple permission check before going through all this
576-
if (!current_user_can(MCSF_CAP_THRESHOLD)) { return; }
583+
if ( ! isset( $_POST['mc_list_id'] ) ) {
584+
return;
585+
}
586+
587+
if (
588+
! current_user_can( MCSF_CAP_THRESHOLD ) ||
589+
! isset( $_POST['update_mc_list_id_nonce'] ) ||
590+
! wp_verify_nonce( sanitize_key( $_POST['update_mc_list_id_nonce'] ), 'update_mc_list_id_action' )
591+
) {
592+
wp_die( 'Security check failed.' );
593+
}
577594

578595
$api = mailchimpSF_get_api();
579596
if (!$api) { return; }

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: MailChimp
33
Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
44
Requires at least: 2.8
55
Tested up to: 4.5
6-
Stable tag: 1.5.8
6+
Stable tag: 1.5.9
77

88
== Description ==
99

@@ -131,6 +131,9 @@ Fixes major bug with "Settings" link on Plugins screen.
131131
Added support for multiple interest groups, field formatting based on type and date picker.
132132

133133
== Changelog ==
134+
= 1.5.9 =
135+
* Fix – Provide CSRF hardening for Mailchimp List changes.
136+
134137
= 1.5.8 =
135138
* Fix PHP warning for merge tags.
136139
* Fix double slashes on resoures being loaded

views/setup_page.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<input type="password" name="mailchimpSF_api_key" placeholder="API Key">
4747
</td>
4848
<td>
49+
<?php wp_nonce_field('mc_login', '_mcsf_nonce_action'); ?>
4950
<input type="submit" value="Connnect">
5051
</td>
5152
</tr>
@@ -140,6 +141,7 @@
140141
</td>
141142
<td>
142143
<input type="hidden" name="mcsf_action" value="update_mc_list_id" />
144+
<?php wp_nonce_field( 'update_mc_list_id_action', 'update_mc_list_id_nonce' ); ?>
143145
<input type="submit" name="Submit" value="<?php esc_attr_e('Update List', 'mailchimp_i18n'); ?>" class="button" />
144146
</td>
145147
</tr>

0 commit comments

Comments
 (0)