Skip to content

Commit ce056fd

Browse files
committed
Deploying version 1.6.7
1 parent f8b810c commit ce056fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+515
-486
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
**Contributors:** wpengine, deliciousbrains, ianmjones, eriktorsner, kevinwhoffman, mattshaw, bradt, SylvainDeaure \
44
**Tags:** amazon ses,smtp,email delivery,gmail smtp,newsletter \
55
**Requires at least:** 5.3 \
6-
**Tested up to:** 6.3 \
6+
**Tested up to:** 6.4 \
77
**Requires PHP:** 7.2 \
8-
**Stable tag:** 1.6.6
8+
**Stable tag:** 1.6.7
99

1010
Fix your email delivery problems by sending your WordPress emails through Amazon SES's powerful email sending infrastructure.
1111

@@ -191,6 +191,11 @@ Please double check the credentials match up with the credentials you received w
191191

192192
## Changelog
193193

194+
### 1.6.7 - 2024-02-08
195+
196+
* Security: Unserializing an object related to plugin settings now passes `'allowed_classes' => false` to avoid instantiating the complete object and potentially running malicious code
197+
* Security: Processing of the email queue now restricts the type of data allowed to ensure stored queue items meet requirements
198+
194199
### 1.6.6 - 2023-08-24
195200

196201
* New: WordPress 6.3 compatible

classes/Activity-List-Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function column_subject( $email ) {
163163
* @param array $email The array of info about the email.
164164
*/
165165
public function column_recipient( $email ) {
166-
$email['recipient'] = maybe_unserialize( $email['recipient'] );
166+
$email['recipient'] = Utils::maybe_unserialize( $email['recipient'] );
167167

168168
if ( is_array( $email['recipient'] ) ) {
169169
return implode( ', ', $email['recipient'] );

classes/Email-Log.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
namespace DeliciousBrains\WP_Offload_SES;
1010

11-
use DeliciousBrains\WP_Offload_SES\WP_Offload_SES;
12-
1311
/**
1412
* Class Email_Log
1513
*
@@ -127,7 +125,7 @@ public function get_email( int $id ) {
127125
return false;
128126
}
129127

130-
$row = array_map( 'maybe_unserialize', $row );
128+
$row = array_map( '\DeliciousBrains\WP_Offload_SES\Utils::maybe_unserialize', $row );
131129

132130
if ( ! empty( $row['email_headers'] ) ) {
133131
$row['email_headers'] = Utils::sanitize_email_headers( $row['email_headers'] );

classes/Queue/Connection.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,13 @@
1414
*/
1515
class Connection extends DatabaseConnection {
1616

17-
/**
18-
* Table to store jobs.
19-
*
20-
* @var string
21-
*/
22-
protected $jobs_table;
23-
24-
/**
25-
* Table to store failures.
26-
*
27-
* @var string
28-
*/
29-
protected $failures_table;
30-
3117
/**
3218
* Construct the Connection class.
3319
*
3420
* @param \wpdb $wpdb WordPress database class.
3521
*/
36-
public function __construct( $wpdb ) {
37-
parent::__construct( $wpdb );
22+
public function __construct( $wpdb, array $allowed_job_classes = array() ) {
23+
parent::__construct( $wpdb, $allowed_job_classes );
3824

3925
$this->jobs_table = $this->database->base_prefix . 'oses_jobs';
4026
$this->failures_table = $this->database->base_prefix . 'oses_failures';
@@ -65,7 +51,7 @@ public function get_job( $id ) {
6551
*
6652
* @return bool
6753
*/
68-
public function release( $job ) {
54+
public function release( Job $job ) {
6955
/** @var WP_Offload_SES $wp_offload_ses */
7056
global $wp_offload_ses;
7157

@@ -106,12 +92,12 @@ public function failure( $job, Exception $exception ): bool {
10692
/**
10793
* Push a job onto the queue.
10894
*
109-
* @param object $job The email job.
110-
* @param int $delay The delay for the job.
95+
* @param Job $job The email job.
96+
* @param int $delay The delay for the job.
11197
*
11298
* @return bool|int
11399
*/
114-
public function push( \DeliciousBrains\WP_Offload_SES\WP_Queue\Job $job, $delay = 0 ) {
100+
public function push( Job $job, $delay = 0 ) {
115101
$args = array(
116102
'job' => serialize( $job ),
117103
'available_at' => $this->datetime( $delay ),

classes/Queue/Email-Cron.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class Email_Cron extends Cron {
1414
/**
1515
* Cron constructor.
1616
*
17-
* @param string $id
18-
* @param Worker $worker
19-
* @param int $interval
17+
* @param string $id
18+
* @param Email_Worker $worker
19+
* @param int $interval
2020
*/
2121
public function __construct( $id, $worker, $interval ) {
2222
parent::__construct( $id, $worker, $interval );

classes/Queue/Email-Queue.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@
1212
*/
1313
class Email_Queue extends Queue {
1414

15-
/**
16-
* The database connection.
17-
*
18-
* @var Connection
19-
*/
20-
protected $connection;
21-
22-
/**
23-
* The cron class.
24-
*
25-
* @var Email_Cron
26-
*/
27-
protected $cron;
28-
2915
/**
3016
* The delay before running a cron.
3117
*
@@ -67,7 +53,7 @@ class Email_Queue extends Queue {
6753
public function __construct() {
6854
global $wpdb;
6955

70-
$this->connection = new Connection( $wpdb );
56+
$this->connection = new Connection( $wpdb, array( Email_Job::class ) );
7157
parent::__construct( $this->connection );
7258

7359
$this->add_cron();
@@ -149,10 +135,10 @@ public function add_cron() {
149135
*
150136
* @param int $attempts The number of times to attempt the job.
151137
*
152-
* @return Worker
138+
* @return Email_Worker
153139
*/
154140
public function worker( $attempts ) {
155-
return new Worker( $this->connection, $attempts );
141+
return new Email_Worker( $this->connection, $attempts );
156142
}
157143

158144
/**
@@ -177,7 +163,7 @@ public function install_tables() {
177163
reserved_at datetime DEFAULT NULL,
178164
available_at datetime NOT NULL,
179165
created_at datetime NOT NULL,
180-
PRIMARY KEY (id)
166+
PRIMARY KEY (id)
181167
) $charset_collate;";
182168
dbDelta( $sql );
183169

@@ -186,7 +172,7 @@ public function install_tables() {
186172
job longtext NOT NULL,
187173
error text DEFAULT NULL,
188174
failed_at datetime NOT NULL,
189-
PRIMARY KEY (id)
175+
PRIMARY KEY (id)
190176
) $charset_collate;";
191177
dbDelta( $sql );
192178
}
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
use DeliciousBrains\WP_Offload_SES\Command_Pool;
66
use DeliciousBrains\WP_Offload_SES\Error;
77
use DeliciousBrains\WP_Offload_SES\WP_Queue\Exceptions\WorkerAttemptsExceededException;
8+
use DeliciousBrains\WP_Offload_SES\WP_Queue\Worker;
89
use Exception;
910

1011
/**
1112
* Class Worker
1213
*
1314
* @since 1.0.0
1415
*/
15-
class Worker {
16+
class Email_Worker extends Worker {
1617

1718
/**
1819
* The AWS Command Pool wrapper.
@@ -21,30 +22,15 @@ class Worker {
2122
*/
2223
protected $command_pool;
2324

24-
/**
25-
* The database connection.
26-
*
27-
* @var Connection
28-
*/
29-
private $connection;
30-
31-
/**
32-
* The number of times to attempt a job.
33-
*
34-
* @var int
35-
*/
36-
private $attempts;
37-
3825
/**
3926
* Worker constructor.
4027
*
4128
* @param Connection $connection The database connection.
4229
* @param int $attempts The number of times to attempt a job.
4330
*/
4431
public function __construct( Connection $connection, int $attempts = 3 ) {
32+
parent::__construct( $connection, $attempts );
4533
$this->command_pool = new Command_Pool( $connection, $attempts );
46-
$this->connection = $connection;
47-
$this->attempts = $attempts;
4834
}
4935

5036
/**

classes/Queue/Queue-Status.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace DeliciousBrains\WP_Offload_SES\Queue;
44

55
use DeliciousBrains\WP_Offload_SES\Email;
6+
use DeliciousBrains\WP_Offload_SES\Queue\Jobs\Email_Job;
67
use DeliciousBrains\WP_Offload_SES\Utils;
78
use DeliciousBrains\WP_Offload_SES\Error;
89
use DeliciousBrains\WP_Offload_SES\WP_Offload_SES;
@@ -32,7 +33,7 @@ class Queue_Status {
3233
public function __construct( WP_Offload_SES $wp_offload_ses ) {
3334
global $wpdb;
3435

35-
$this->connection = new Connection( $wpdb );
36+
$this->connection = new Connection( $wpdb, array( Email_Job::class ) );
3637
$this->wp_offload_ses = $wp_offload_ses;
3738

3839
// Run the cron health check after everything has loaded.

classes/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function get_defined_settings( bool $force = false ): array {
116116
$unserialized = array();
117117

118118
if ( defined( $this->settings_constant ) ) {
119-
$unserialized = maybe_unserialize( constant( $this->settings_constant ) );
119+
$unserialized = Utils::maybe_unserialize( constant( $this->settings_constant ) );
120120
$unserialized = is_array( $unserialized ) ? $unserialized : array();
121121
}
122122

classes/Utils.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,19 @@ public static function sanitize_email_headers( $headers ): array {
322322

323323
return $new_headers;
324324
}
325+
326+
/**
327+
* Maybe unserialize data, but not if an object.
328+
*
329+
* @param mixed $data
330+
*
331+
* @return mixed
332+
*/
333+
public static function maybe_unserialize( $data ) {
334+
if ( is_serialized( $data ) ) {
335+
return @unserialize( $data, array( 'allowed_classes' => false ) ); // @phpcs:ignore
336+
}
337+
338+
return $data;
339+
}
325340
}

0 commit comments

Comments
 (0)