| @@ -213,8 +213,9 @@ | ||
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | 215 | * This function is used to fetch the token value from query string or cookies based on availability. |
| 216 | 216 | * |
| 217 | + * @since 4.16.7 Return an empty string for non-string token values. | |
| 217 | 218 | * @since 2.4.1 |
| 218 | 219 | * @access public |
| 219 | 220 | * |
| 220 | 221 | * @return string |
| @@ -227,9 +228,9 @@ | ||
| 227 | 228 | if ( empty( $token ) ) { |
| 228 | 229 | $token = isset( $_COOKIE['give_nl'] ) ? give_clean( $_COOKIE['give_nl'] ) : ''; |
| 229 | 230 | } |
| 230 | 231 | |
| 231 | - return $token; | |
| 232 | + return is_string( $token ) ? $token : ''; | |
| 232 | 233 | } |
| 233 | 234 | |
| 234 | 235 | /** |
| 235 | 236 | * Has the user authenticated? |
| @@ -269,8 +270,9 @@ | ||
| 269 | 270 | |
| 270 | 271 | /** |
| 271 | 272 | * Is this a valid token? |
| 272 | 273 | * |
| 274 | + * @since 4.16.7 Only accept non-empty string tokens. | |
| 273 | 275 | * @since 1.0 |
| 274 | 276 | * @access public |
| 275 | 277 | * |
| 276 | 278 | * @param $token string The token. |
| @@ -280,8 +282,13 @@ | ||
| 280 | 282 | public function is_valid_token( $token ) { |
| 281 | 283 | |
| 282 | 284 | global $wpdb; |
| 283 | 285 | |
| 286 | + // A crafted give_nl[]= parameter arrives as an array; reject non-string and empty tokens. | |
| 287 | + if ( ! is_string( $token ) || '' === $token ) { | |
| 288 | + return false; | |
| 289 | + } | |
| 290 | + | |
| 284 | 291 | // Make sure token isn't expired. |
| 285 | 292 | $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
| 286 | 293 | |
| 287 | 294 | $email = $wpdb->get_var( |
| @@ -343,8 +350,9 @@ | ||
| 343 | 350 | |
| 344 | 351 | /** |
| 345 | 352 | * Is this a valid verify key? |
| 346 | 353 | * |
| 354 | + * @since 4.16.7 Only accept non-empty string tokens. | |
| 347 | 355 | * @since 1.0 |
| 348 | 356 | * @access public |
| 349 | 357 | * |
| 350 | 358 | * @param $token string The token. |
| @@ -353,8 +361,13 @@ | ||
| 353 | 361 | */ |
| 354 | 362 | public function is_valid_verify_key( $token ) { |
| 355 | 363 | /* @var WPDB $wpdb */ |
| 356 | 364 | global $wpdb; |
| 365 | + | |
| 366 | + // A crafted give_nl[]= parameter arrives as an array; reject non-string and empty tokens. | |
| 367 | + if ( ! is_string( $token ) || '' === $token ) { | |
| 368 | + return false; | |
| 369 | + } | |
| 357 | 370 | |
| 358 | 371 | // See if the verify_key exists. |
| 359 | 372 | $row = $wpdb->get_row( |
| 360 | 373 | $wpdb->prepare( "SELECT id, email FROM {$wpdb->donors} WHERE verify_key = %s LIMIT 1", $token ) |