Skip to content

Commit

Permalink
Security patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed May 7, 2024
1 parent cfbdfa2 commit cd9afd8
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 5 deletions.
9 changes: 9 additions & 0 deletions classes/Pods.php
Original file line number Diff line number Diff line change
Expand Up @@ -4049,6 +4049,15 @@ public function form( $params = null, $label = null, $thank_you = null ) {
$fields_only = $params['fields_only'];
$output_type = $params['output_type'];

// Sanitize thank_you for security.
if ( ! empty( $thank_you ) ) {
// Additional sanitization.
$thank_you = sanitize_text_field( $thank_you );

// Fallback to '' so that the logic below can kick in if the thank you URL was not safe.
$thank_you = pods_enforce_safe_url( $thank_you, '' );
}

if ( empty( $output_type ) ) {
$output_type = 'div';
}
Expand Down
21 changes: 21 additions & 0 deletions includes/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2952,3 +2952,24 @@ function pods_kses_exclude_p( $content ) {
]
);
}

/**
* Enforce a URL as safe and fallback to another URL if it is not safe.
*
* @since 3.0.10.3
*
* @param string $url The URL to enforce as safe.
* @param string|null $fallback_url The fallback URL to use if the URL is not valid.
*
* @return string The safe URL or the fallback URL if that was not valid.
*/
function pods_enforce_safe_url( string $url, ?string $fallback_url = null ) {
$url = wp_sanitize_redirect( $url );

if ( null === $fallback_url ) {
$fallback_url = pods_current_url();
}

return wp_validate_redirect( $url, $fallback_url );
}

4 changes: 2 additions & 2 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Pods - Custom Content Types and Fields
* Plugin URI: https://pods.io/
* Description: Pods is a framework for creating, managing, and deploying customized content types and fields
* Version: 3.0.10.1
* Version: 3.0.10.3
* Author: Pods Framework Team
* Author URI: https://pods.io/about/
* Text Domain: pods
Expand Down Expand Up @@ -43,7 +43,7 @@
add_action( 'init', 'pods_deactivate_pods_ui' );
} else {
// Current version.
define( 'PODS_VERSION', '3.0.10.1' );
define( 'PODS_VERSION', '3.0.10.3' );

// Current database version, this is the last version the database changed.
define( 'PODS_DB_VERSION', '2.3.5' );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pods",
"version": "3.0.10.1",
"version": "3.0.10.3",
"description": "Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.",
"author": "Pods Foundation, Inc",
"homepage": "https://pods.io/",
Expand Down
14 changes: 13 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields,
Requires at least: 6.0
Tested up to: 6.4
Requires PHP: 7.2
Stable tag: 3.0.10.1
Stable tag: 3.0.10.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -181,6 +181,18 @@ Pods really wouldn't be where it is without all the contributions from our [dono

== Changelog ==

= 3.0.10.3 - May 8th, 2024 =

*Security Release*

* Security hardening: Enforce safe URLs for Pods form submission confirmation page URLs. Props to the wesley (wcraft) / Wordfence for responsibly reporting this. (@sc0ttkclark)

= 3.0.10.2 - February 21st, 2024 =

*Security Release*

Resolved issue with release deployment, see previous version for more details about the release.

= 3.0.10.1 - February 21st, 2024 =

*Security Release*
Expand Down
5 changes: 5 additions & 0 deletions src/Pods/Blocks/API.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/front/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
action=""
method="post"
class="pods-submittable pods-form pods-form-front pods-form-pod-<?php echo esc_attr( $pod_name ); ?> pods-submittable-ajax"
data-location="<?php echo esc_attr( $thank_you ); ?>"
data-location="<?php echo esc_attr( pods_enforce_safe_url( $thank_you ) ); ?>"
id="pods-form-<?php echo esc_attr( $pod_name . '-' . $counter ); ?>"
data-pods-pod-name="<?php echo esc_attr( $pod_name ); ?>"
data-pods-item-id="<?php echo esc_attr( $id ); ?>"
Expand Down

0 comments on commit cd9afd8

Please sign in to comment.