Skip to content

Commit e9f34b5

Browse files
committed
Fix possible remote code execution attack
1 parent d0bd237 commit e9f34b5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

service/backupservice.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ public function doRestoreTable( $timestamp, $table )
297297
return false;
298298
}
299299

300+
if ( preg_match( '/[\.\/]/', $table ) )
301+
{
302+
throw new Exception( "Invalid table name: $table" );
303+
}
304+
300305
// get the table structure file name
301306
$structureFile = $this->configService->getBackupBaseDirectory() . "/$timestamp/$table/structure.xml";
302307

tests/integration/BackupIntegrationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public function testRestore() {
9191
$tableExists = $this->db->tableExists( self::TEST_TABLE_NO_PREFIX );
9292
$this->assertFalse( $tableExists );
9393

94+
// restore forged table
95+
$timestamp = $timestampList[0];
96+
$tableList = ["../../admin/files"];
97+
// this should throw an exception
98+
$this->backupService->doRestoreTables( $timestamp, $tableList );
99+
94100
// restore table
95101
$timestamp = $timestampList[0];
96102
$tableList = [self::TEST_TABLE];

0 commit comments

Comments
 (0)