CVE-2019-11565 (published 2019-04-27T14:29Z)

Server Side Request Forgery (SSRF) exists in the Print My Blog plugin before 1.6.7 for WordPress via the site parameter.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-918
cwe_name: Server-Side Request Forgery (SSRF)
description: The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
extended_description: By providing URLs to unexpected hosts or ports, attackers can make it appear that the server is sending the request, possibly bypassing access controls such as firewalls that prevent the attackers from accessing the URLs directly. The server can be used as a proxy to conduct port scanning of hosts in internal networks, use other URLs such as that can access documents on the system (using file://), or use other protocols such as gopher:// or tftp://, which may provide greater control over the contents of requests.
         

Fix information:
repo_url: https://github.com/mnelson4/printmyblog
commit_details: repo_url: https://github.com/mnelson4/printmyblog
author: Mike Nelson
author_date: 2019-04-26 20:40:30-07:00
msg: do a little more sanitizing of the site param when REST PRoxy enabled
repository: repo_url: https://github.com/mnelson4/printmyblog
repo_name: mnelson4/printmyblog
description: WordPress Plugin that simplifies printing your entire blog
repo_language: PHP
owner: mnelson4
file_changes: filename: RestApiDetector.php
change_type: ModificationType.MODIFY
diff: @@ -30,11 +30,7 @@ class RestApiDetector
      */
     public function __construct($site)
     {
-        // If the REST API Proxy Plugin isn't active, always use the current site.
-        if(! PMB_REST_PROXY_EXISTS){
-            $site = '';
-        }
-        $this->setSite($site);
+        $this->setSite($this->sanitizeSite($site));
         $this->getSiteInfo();
     }
 
@@ -55,14 +51,7 @@ class RestApiDetector
             $this->setLocal(true);
             return;
         }
-        // If they forgot to add http(s), add it for them.
-        if(strpos($this->getSite(), 'http://') === false && strpos($this->getSite(), 'https://') === false) {
-            $this->setSite( 'http://' . $this->getSite());
-        }
-        // if there is one, check if it exists in wordpress.com, eg "retirementreflections.com"
-        $site = trailingslashit(sanitize_text_field($this->getSite()));
-
-
+        $site = $this->getSite();
         // Let's see if it's self-hosted...
         $data = $this->getSelfHostedSiteInfo($site);
 //        if($data === false){
@@ -77,6 +66,32 @@ class RestApiDetector
         return $data;
     }
 
+    /**
+     * Avoid SSRF by sanitizing the site received.
+     * @since $VID:$
+     * @param $site
+     * @return mixed|string
+     */
+    protected function sanitizeSite($site)
+    {
+        // If the REST API Proxy Plugin isn't active, always use the current site.
+        if(! PMB_REST_PROXY_EXISTS){
+            return '';
+        }
+        // If they forgot to add http(s), add it for them.
+        if(strpos($site, 'http://') === false && strpos($site, 'https://') === false) {
+            $site = 'http://' . $site;
+        }
+        // if there is one, check if it exists in wordpress.com, eg "retirementreflections.com"
+
+        $file_info = pathinfo($site);
+        if( isset($file_info['extension'])){
+            $site = str_replace($file_info['filename'] . "." . $file_info['extension'], "", $site);
+        }
+        $site = trailingslashit(sanitize_text_field($site));
+        return $site;
+    }
+
     /**
      * Tries to get the site's name, description, and URL, assuming it's self-hosted.
      * Returns a true on success, false if the site works but wasn't a self-hosted WordPress site, or

programming_language: PHP