Skip to content

Commit e59e22b

Browse files
committed
Fixed an RCE vulnerability
1 parent ecf1891 commit e59e22b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Fixed a bug where asset edit page URLs contained spaces if the asset filename contained spaces. ([#15236](https://github.com/craftcms/cms/issues/15236))
66
- Fixed a bug where custom fields were getting included in rendered field layout forms, even if their `getInputHtml()` method returned an empty string.
7+
- Fixed an RCE vulnerability.
78

89
## 4.13.7 - 2024-12-17
910

src/controllers/UpdaterController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Composer\Semver\VersionParser;
1313
use Craft;
1414
use craft\errors\InvalidPluginException;
15+
use craft\helpers\FileHelper;
1516
use RequirementsChecker;
1617
use Throwable;
1718
use yii\web\BadRequestHttpException;
@@ -99,8 +100,13 @@ public function actionBackup(): Response
99100
*/
100101
public function actionRestoreDb(): Response
101102
{
103+
$backupPath = $this->data['dbBackupPath'];
104+
if (!file_exists($backupPath) || !FileHelper::isWithin($backupPath, Craft::$app->getPath()->getDbBackupPath())) {
105+
throw new BadRequestHttpException("Invalid backup path: $backupPath");
106+
}
107+
102108
try {
103-
Craft::$app->getDb()->restore($this->data['dbBackupPath']);
109+
Craft::$app->getDb()->restore($backupPath);
104110
} catch (Throwable $e) {
105111
Craft::error('Error restoring up the database: ' . $e->getMessage(), __METHOD__);
106112
return $this->send([

0 commit comments

Comments
 (0)