Vulnerability: Potential Remote Code Execution in TYPO3 with mediace extension > ### Meta
> * CVSS: `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C` (9.1)
> * CWE-325, CWE-20, CWE-200, CWE-502

### Problem
It has been discovered that an internal verification mechanism can be used to generate arbitrary checksums. This allows to inject arbitrary data having a valid cryptographic message authentication code (HMAC-SHA1) and can lead to various attack chains as described below.

* [TYPO3-CORE-SA-2020-007](https://typo3.org/security/advisory/typo3-core-sa-2020-007), [CVE-2020-15099](https://nvd.nist.gov/vuln/detail/CVE-2020-15099): Potential Privilege Escalation
  + the database server used for a TYPO3 installation must be accessible for an attacker (either via internet or shared hosting network)
  + `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C` (7.5, high)
* [TYPO3-CORE-SA-2016-013](https://typo3.org/security/advisory/typo3-core-sa-2016-013), [CVE-2016-5091](https://nvd.nist.gov/vuln/detail/CVE-2016-5091): Insecure Deserialization & Remote Code Execution
  + an attacker must have access to at least one Extbase plugin or module action in a TYPO3 installation
  + `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C` (9.1, critical)

The overall severity of this vulnerability is critical (9.1) based on mentioned attack chains and the fact it does not require any privileges.

### Solution
In case the extension is not used and required at all, it is suggested to uninstall and remove it from the system completely. Otherwise, an updated version 7.6.5 is available from the TYPO3 extension manager, Packagist and the TYPO3 extension repository:

* https://extensions.typo3.org/extension/download/mediace/7.6.5/zip/
* https://packagist.org/packages/friendsoftypo3/mediace#7.6.5

As a precautionary measure it is advised to change `encryptionKey` and database credentials in `typo3conf/LocalConfiguration.php`.

### Credits
Thanks to TYPO3 security team member Oliver Hader who reported and fixed the issue.

### References
* [TYPO3-EXT-SA-2020-014](https://typo3.org/security/advisory/typo3-ext-sa-2020-014)
Vulnerability ID: GHSA-4h44-w6fm-548g
CWE: CWE-20
Severity score: 9.8
Project: https://github.com/FriendsOfTYPO3/mediace
Published: 2020-07-29
File: Resources/PHP/ValidateHashEID.php
Commit message: [SECURITY] Restrict file validation hash generation

Security-References: CVE-2020-15086
Commit author: Oliver Hader

Vulnerable version (before fix):
  call_user_func(function() {     $value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('value');     $addition = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('addition');     $scope = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('scope');      $content = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($value, $addition);      if ($scope === 'flashvars') {         header('Content-type: application/x-www-form-urlencoded');

Fixed version (after fix):
  call_user_func(function() {     $value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('value');     $scope = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('scope');      if (!is_string($value) || empty($value)) {         \TYPO3\CMS\Core\Utility\HttpUtility::setResponseCodeAndExit(             \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_400         );     }      $content = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($value, 'flashvars');      if ($scope === 'flashvars') {         header('Content-type: application/x-www-form-urlencoded');

Patch:
patch: @@ -14,10 +14,15 @@
 
 call_user_func(function() {
     $value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('value');
-    $addition = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('addition');
     $scope = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('scope');
 
-    $content = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($value, $addition);
+    if (!is_string($value) || empty($value)) {
+        \TYPO3\CMS\Core\Utility\HttpUtility::setResponseCodeAndExit(
+            \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_400
+        );
+    }
+
+    $content = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($value, 'flashvars');
 
     if ($scope === 'flashvars') {
         header('Content-type: application/x-www-form-urlencoded');
path: Resources/PHP/ValidateHashEID.php