Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/bold-page-builder/bold-builder.php
+++ b/bold-page-builder/bold-builder.php
@@ -3,7 +3,7 @@
/**
* Plugin Name: Bold Page Builder
* Description: WordPress page builder.
- * Version: 5.9.11
+ * Version: 5.9.12
* Author: BoldThemes
* Author URI: https://www.bold-themes.com
* License: GPL v2 or later
@@ -14,7 +14,7 @@
defined( 'ABSPATH' ) || exit;
// VERSION --------------------------------------------------------- \
-define( 'BT_BB_VERSION', '5.9.11' );
+define( 'BT_BB_VERSION', '5.9.12' );
// VERSION --------------------------------------------------------- \
define( 'BT_BB_FEATURE_ADD_ELEMENTS', true );
@@ -1728,9 +1728,13 @@
$pattern = get_shortcode_regex();
global $bt_bb_array;
-
- $callback = new BT_BB_Callback( $bt_bb_array );
-
+
+ // Text nodes built here are handed to the editors as HTML. Content saved
+ // by an author without unfiltered_html is re-filtered (see the callback).
+ $author_trusted = function_exists( 'bt_bb_author_can_unfiltered_html' ) && bt_bb_author_can_unfiltered_html();
+
+ $callback = new BT_BB_Callback( $bt_bb_array, $author_trusted );
+
$preg_cb = preg_replace_callback( "/$pattern/s", array( $callback, 'bt_bb_do_shortcode_tag' ), $content );
}
}
@@ -1739,8 +1743,11 @@
private $bt_bb_array;
- function __construct( &$bt_bb_array ) {
+ private $author_trusted;
+
+ function __construct( &$bt_bb_array, $author_trusted = FALSE ) {
$this->bt_bb_array = &$bt_bb_array;
+ $this->author_trusted = (bool) $author_trusted;
}
function bt_bb_do_shortcode_tag( $m ) {
@@ -1768,10 +1775,27 @@
if ( isset( $bt_bb_map[ $m[2] ]['accept']['_content'] ) && $bt_bb_map[ $m[2] ]['accept']['_content'] ) {
$r = $m[5];
+ // A contiguous slice of what was saved: every tag in it is one kses
+ // already saw. Re-filter for untrusted authors as defense in depth.
+ if ( ! $this->author_trusted ) {
+ $r = wp_kses_post( $r );
+ }
} else {
- $callback = new BT_BB_Callback( $this->bt_bb_array[ count( $this->bt_bb_array ) - 1 ]['children'] );
+ $callback = new BT_BB_Callback( $this->bt_bb_array[ count( $this->bt_bb_array ) - 1 ]['children'], $this->author_trusted );
$r = preg_replace_callback( "/$pattern/s", array( $callback, 'bt_bb_do_shortcode_tag' ), $m[5] );
$r = trim( $r );
+ // What is left here is the text *between* the shortcode matches, with
+ // the matches cut out. The shortcode regex does not understand HTML, so
+ // a match can start inside an attribute value and end in text, and
+ // joining the two sides produces markup kses never saw: e.g.
+ // <img title="[bt_bb_headline"> x ]" onerror=...> loses everything
+ // from the bracket to the bracket and comes out as a live onerror.
+ // The builder never writes text into a container that does not accept
+ // it, so this is only ever leftover text: always filter it, whoever
+ // the author is.
+ if ( $r != '' ) {
+ $r = trim( wp_kses_post( $r ) );
+ }
}
if ( $r != '' ) {
--- a/bold-page-builder/content_elements/bt_bb_google_maps/bt_bb_google_maps.php
+++ b/bold-page-builder/content_elements/bt_bb_google_maps/bt_bb_google_maps.php
@@ -14,7 +14,11 @@
'map_type' => 'interactive',
'center_map' => ''
) ), $atts, $this->shortcode ) );
-
+
+ // Google API keys are [A-Za-z0-9_-]. Anything else could only be used to
+ // add parameters to the Maps script URL or the static map image URL.
+ $api_key = preg_replace( '/[^A-Za-z0-9_-]/', '', (string) $api_key );
+
$class_master = 'bt_bb_map';
$class = array( $this->shortcode, $class_master );
--- a/bold-page-builder/content_elements/bt_bb_google_maps_location/bt_bb_google_maps_location.php
+++ b/bold-page-builder/content_elements/bt_bb_google_maps_location/bt_bb_google_maps_location.php
@@ -10,8 +10,12 @@
'longitude' => '',
'icon' => ''
) ), $atts, $this->shortcode ) );
-
- $class_master = 'bt_bb_map_location';
+
+ // Coordinates are read back by the map script, so only numbers go out.
+ $latitude = bt_bb_sanitize_map_coordinate( $latitude, '' );
+ $longitude = bt_bb_sanitize_map_coordinate( $longitude, '' );
+
+ $class_master = 'bt_bb_map_location';
$class = array( $this->shortcode, $class_master );
--- a/bold-page-builder/content_elements/bt_bb_leaflet_map/bt_bb_leaflet_map.php
+++ b/bold-page-builder/content_elements/bt_bb_leaflet_map/bt_bb_leaflet_map.php
@@ -16,6 +16,10 @@
'zoom_control' => ''
) ), $atts, $this->shortcode ) );
+ // Tile URLs and attribution text are base64-encoded into the page, where
+ // kses never saw them; the attribution ends up in Leaflet's innerHTML.
+ $custom_style = bt_bb_sanitize_leaflet_custom_style( $custom_style );
+
$zoom = $zoom == '' ? '9' : $zoom;
$max_zoom = $max_zoom == '' ? '15' : $max_zoom;
--- a/bold-page-builder/content_elements/bt_bb_leaflet_map_location/bt_bb_leaflet_map_location.php
+++ b/bold-page-builder/content_elements/bt_bb_leaflet_map_location/bt_bb_leaflet_map_location.php
@@ -15,13 +15,10 @@
$class = array( $this->shortcode, $class_master );
- if ( $latitude == '' ) {
- $latitude = 0;
- }
-
- if ( $longitude == '' ) {
- $longitude = 0;
- }
+ // Coordinates are read back by the map script, so only numbers go out
+ // (empty or non-numeric falls back to 0, as an empty value always did).
+ $latitude = bt_bb_sanitize_map_coordinate( $latitude, 0 );
+ $longitude = bt_bb_sanitize_map_coordinate( $longitude, 0 );
if ( $el_class != '' ) {
$class[] = $el_class;
--- a/bold-page-builder/content_elements_misc/misc.php
+++ b/bold-page-builder/content_elements_misc/misc.php
@@ -387,6 +387,85 @@
}
}
+if ( ! function_exists( 'bt_bb_sanitize_map_coordinate' ) ) {
+ /**
+ * Returns a map latitude/longitude as a plain number string, or $fallback.
+ *
+ * Map scripts read coordinates back out of data-* attributes, where
+ * jQuery.data() hands them back entity-decoded; esc_attr() on output does
+ * not make a non-numeric value safe once a script builds markup or URLs
+ * from it. The trimmed original string is returned (not a float cast) so
+ * the decimal separator never depends on the PHP locale.
+ *
+ * @param mixed $value Raw attribute value.
+ * @param mixed $fallback Returned for empty or non-numeric input.
+ * @return mixed
+ */
+ function bt_bb_sanitize_map_coordinate( $value, $fallback = '' ) {
+ if ( ! is_scalar( $value ) ) {
+ return $fallback;
+ }
+ $value = trim( (string) $value );
+ if ( $value === '' || ! is_numeric( $value ) || ! is_finite( (float) $value ) ) {
+ return $fallback;
+ }
+ return $value;
+ }
+}
+
+if ( ! function_exists( 'bt_bb_sanitize_leaflet_custom_style' ) ) {
+ /**
+ * Sanitizes the Leaflet map "Additional map layers" value.
+ *
+ * The field is stored base64-encoded, so post-content kses never sees the
+ * decoded text. Each line is "tile URL,attribution". Lines whose URL is not
+ * an absolute http(s) or protocol-relative URL are dropped, and every
+ * attribution field is passed through wp_kses() with a small inline
+ * allowlist, because Leaflet writes attributions with innerHTML.
+ *
+ * @param string $custom_style Base64-encoded layer list.
+ * @return string Base64-encoded sanitized layer list, or '' if nothing is left.
+ */
+ function bt_bb_sanitize_leaflet_custom_style( $custom_style ) {
+ $custom_style = trim( (string) $custom_style );
+ if ( $custom_style === '' ) {
+ return '';
+ }
+
+ $decoded = base64_decode( $custom_style, true );
+ if ( $decoded === false || $decoded === '' ) {
+ return '';
+ }
+
+ $allowed_html = array(
+ 'a' => array( 'href' => true, 'title' => true, 'target' => true, 'rel' => true ),
+ 'b' => array(),
+ 'strong' => array(),
+ 'i' => array(),
+ 'em' => array(),
+ 'small' => array(),
+ 'span' => array(),
+ 'br' => array(),
+ );
+
+ $lines = array();
+ foreach ( explode( "n", $decoded ) as $line ) {
+ $fields = explode( ',', $line );
+ $fields[0] = trim( $fields[0] );
+ if ( ! preg_match( '#^(https?:)?//#i', $fields[0] ) ) {
+ continue;
+ }
+ $count = count( $fields );
+ for ( $i = 1; $i < $count; $i++ ) {
+ $fields[ $i ] = wp_kses( $fields[ $i ], $allowed_html );
+ }
+ $lines[] = implode( ',', $fields );
+ }
+
+ return empty( $lines ) ? '' : base64_encode( implode( "n", $lines ) );
+ }
+}
+
if ( ! function_exists( 'bt_bb_get_url' ) ) {
function bt_bb_get_url( $link, $post_type = 'page' ) {
if ( substr( $link, 0, 4 ) == 'www.' ) {