From d572baf83c5a6d61a7f97aa4d115eba76c5f106c Mon Sep 17 00:00:00 2001 From: Klap-in Date: Tue, 21 May 2013 21:40:37 +0200 Subject: Add check for token when resizing and caching external images --- inc/fetch.functions.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'inc/fetch.functions.php') diff --git a/inc/fetch.functions.php b/inc/fetch.functions.php index 5801e96fa..59a76a798 100644 --- a/inc/fetch.functions.php +++ b/inc/fetch.functions.php @@ -108,6 +108,10 @@ function checkFileStatus(&$media, &$file, $rev = '', $width=0, $height=0) { //download failed - redirect to original URL return array(302, $media); } + // check token for resized and cached images + if (($width || $height) && media_get_token($media, $width, $height) !== $INPUT->str('tok')) { + return array(412, 'Precondition Failed'); + } } else { $media = cleanID($media); if(empty($media)) { -- cgit v1.2.3 From cc036f74ff14c387f24d72f5a52f2f158208846e Mon Sep 17 00:00:00 2001 From: Klap-in Date: Thu, 1 Aug 2013 23:06:03 +0200 Subject: remove hash for external images, but use token url parameter instead --- inc/fetch.functions.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'inc/fetch.functions.php') diff --git a/inc/fetch.functions.php b/inc/fetch.functions.php index 3c700b35b..207ad9e5f 100644 --- a/inc/fetch.functions.php +++ b/inc/fetch.functions.php @@ -101,8 +101,8 @@ function checkFileStatus(&$media, &$file, $rev = '', $width=0, $height=0) { //media to local file if(media_isexternal($media)) { - //check hash - if(substr(PassHash::hmac('md5', $media, auth_cookiesalt()), 0, 6) !== $INPUT->str('hash')) { + //check token for external image and additional for resized and cached images + if(media_get_token($media, $width, $height) !== $INPUT->str('tok')) { return array(412, 'Precondition Failed'); } //handle external images @@ -111,10 +111,6 @@ function checkFileStatus(&$media, &$file, $rev = '', $width=0, $height=0) { //download failed - redirect to original URL return array(302, $media); } - // check token for resized and cached images - if (($width || $height) && media_get_token($media, $width, $height) !== $INPUT->str('tok')) { - return array(412, 'Precondition Failed'); - } } else { $media = cleanID($media); if(empty($media)) { -- cgit v1.2.3