CVE-2021-32698 (published 2021-06-21T22:15Z)

eLabFTW is an open source electronic lab notebook for research labs. This vulnerability allows an attacker to make GET requests on behalf of the server. It is "blind" because the attacker cannot see the result of the request. Issue has been patched in eLabFTW 4.0.0.

Severity: MEDIUM
CVSS v2 base score: 4.0 (AV:N/AC:L/Au:S/C:P/I:N/A:N)
CVSS v3 base score: 4.9, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N)

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/elabftw/elabftw
commit_details: repo_url: https://github.com/elabftw/elabftw
author: Nicolas CARPi
author_date: 2021-06-11 21:29:33+02:00
msg: security: prevent blind ssrf in pdf generation

Issue: one could set the src attribute of an img tag to anything they
want and the pdf generation will happily GET it. This means that one can
do arbitrary HTTP GET requests from the server itself. This doesn't work
in the browser context because of the restrictive CSP policy, which is
not applied during the pdf generation.

This is a MINOR vulnerability as other security measures in the PHP
configuration prevents prospective escalation.

The vulnerability was reported by @mgrRaf and @xoffense. Thank to them
for responsible disclosure. A bounty has been awarded.
repository: repo_url: https://github.com/elabftw/elabftw
repo_name: elabftw/elabftw
description: :notebook: eLabFTW is the most popular open source electronic lab notebook for research labs.
repo_language: PHP
owner: elabftw
file_changes: filename: MakePdf.php
change_type: ModificationType.MODIFY
diff: @@ -137,7 +137,11 @@ class MakePdf extends AbstractMake
             'useCjk' => $this->Entity->Users->userData['cjk_fonts'],
         );
 
-        return $this->getTwig(Config::getConfig())->render('pdf.html', $renderArr);
+        $html = $this->getTwig(Config::getConfig())->render('pdf.html', $renderArr);
+
+        // now remove any img src pointing to outside world
+        // prevent blind ssrf (thwarted by CSP on webpage, but not in pdf)
+        return preg_replace('/img src=("|\')(ht|f|)tp/i', 'nope', $html);
     }
 
     /**
@@ -218,7 +222,7 @@ class MakePdf extends AbstractMake
         $contentDecode = html_entity_decode($content, ENT_HTML5, 'UTF-8');
         file_put_contents($filename, $contentDecode);
 
-        // apsolute path to tex2svg app
+        // absolute path to tex2svg app
         $appDir = dirname(__DIR__, 2) . '/src/node';
 
         // convert tex to svg with mathjax nodejs script

programming_language: PHP