Skip to content

Commit cf433c7

Browse files
committed
Validate backup and fragment files. Don't allow traversal.
git-svn-id: https://develop.svn.wordpress.org/branches/2.0@4226 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9b78b38 commit cf433c7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

wp-content/plugins/wp-db-backup.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ function init() {
6969
$via = isset($_GET['via']) ? $_GET['via'] : 'http';
7070

7171
$this->backup_file = $_GET['backup'];
72-
72+
$this->validate_file($this->backup_file);
73+
7374
switch($via) {
7475
case 'smtp':
7576
case 'email':
@@ -95,6 +96,7 @@ function init() {
9596
}
9697
if (isset($_GET['fragment'] )) {
9798
list($table, $segment, $filename) = explode(':', $_GET['fragment']);
99+
$this->validate_file($filename);
98100
$this->backup_fragment($table, $segment, $filename);
99101
}
100102

@@ -881,6 +883,18 @@ function wp_cron_daily() {
881883

882884
return;
883885
} // wp_cron_db_backup
886+
887+
function validate_file($file) {
888+
if (false !== strpos($file, '..'))
889+
die(__("Cheatin' uh ?"));
890+
891+
if (false !== strpos($file, './'))
892+
die(__("Cheatin' uh ?"));
893+
894+
if (':' == substr($file, 1, 1))
895+
die(__("Cheatin' uh ?"));
896+
}
897+
884898
}
885899

886900
function wpdbBackup_init() {

0 commit comments

Comments
 (0)