From 49abdc66f3a87bca89980a1b1a529bdef285462c Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 15 Aug 2006 01:07:51 +0000 Subject: [PATCH] Validate backup and fragment files. Don't allow traversal. git-svn-id: https://develop.svn.wordpress.org/trunk@4095 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-content/plugins/wp-db-backup.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wp-content/plugins/wp-db-backup.php b/wp-content/plugins/wp-db-backup.php index 9ba6406720..ec5da7774b 100644 --- a/wp-content/plugins/wp-db-backup.php +++ b/wp-content/plugins/wp-db-backup.php @@ -71,6 +71,7 @@ class wpdbBackup { $via = isset($_GET['via']) ? $_GET['via'] : 'http'; $this->backup_file = $_GET['backup']; + $this->validate_file($this->backup_file); switch($via) { case 'smtp': @@ -97,6 +98,7 @@ class wpdbBackup { } if (isset($_GET['fragment'] )) { list($table, $segment, $filename) = explode(':', $_GET['fragment']); + $this->validate_file($filename); $this->backup_fragment($table, $segment, $filename); } @@ -880,6 +882,18 @@ class wpdbBackup { return; } // wp_cron_db_backup + + function validate_file($file) { + if (false !== strpos($file, '..')) + die(__("Cheatin' uh ?")); + + if (false !== strpos($file, './')) + die(__("Cheatin' uh ?")); + + if (':' == substr($file, 1, 1)) + die(__("Cheatin' uh ?")); + } + } function wpdbBackup_init() {