From 8e9dbf3c35b0a6478b00901f31ff739c9dcf0696 Mon Sep 17 00:00:00 2001 From: aaroncampbell Date: Tue, 19 Sep 2017 13:41:52 +0000 Subject: [PATCH] oEmbed: Add extra hardening around allowed HTML for improved sandboxing. git-svn-id: https://develop.svn.wordpress.org/trunk@41448 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/embed.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index 2985964ecc..7e5bb374b9 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -753,24 +753,30 @@ function wp_filter_oembed_result( $result, $data, $url ) { } $html = $content[1] . $content[2]; + preg_match( '/ src=([\'"])(.*?)\1/', $html, $results ); + + if ( ! empty( $results ) ) { + $secret = wp_generate_password( 10, false ); + + $url = esc_url( "{$results[2]}#?secret=$secret" ); + $q = $results[1]; + + $html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html ); + $html = str_replace( '