Skip to content
Snippets Groups Projects
Commit 9dddcae9 authored by Bart Visscher's avatar Bart Visscher
Browse files

Remove invalid characters from app id to prevent loading of invalid resources

parent 12bdc6dd
Branches
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
$app = $_POST["app"]; $app = $_POST["app"];
$app = OC_App::cleanAppId($app);
$l = OC_L10N::get( $app ); $l = OC_L10N::get( $app );
......
...@@ -38,6 +38,15 @@ class OC_App{ ...@@ -38,6 +38,15 @@ class OC_App{
static private $checkedApps = array(); static private $checkedApps = array();
static private $altLogin = array(); static private $altLogin = array();
/**
* @brief clean the appid
* @param $app Appid that needs to be cleaned
* @return string
*/
public static function cleanAppId($app) {
return str_replace(array('\0', '/', '\\', '..'), '', $app);
}
/** /**
* @brief loads all apps * @brief loads all apps
* @param array $types * @param array $types
......
...@@ -468,7 +468,7 @@ class OC { ...@@ -468,7 +468,7 @@ class OC {
register_shutdown_function(array('OC_Helper', 'cleanTmp')); register_shutdown_function(array('OC_Helper', 'cleanTmp'));
//parse the given parameters //parse the given parameters
self::$REQUESTEDAPP = (isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? str_replace(array('\0', '/', '\\', '..'), '', strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files')); self::$REQUESTEDAPP = (isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app']) ? OC_App::cleanAppId(strip_tags($_GET['app'])) : OC_Config::getValue('defaultapp', 'files'));
if (substr_count(self::$REQUESTEDAPP, '?') != 0) { if (substr_count(self::$REQUESTEDAPP, '?') != 0) {
$app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?')); $app = substr(self::$REQUESTEDAPP, 0, strpos(self::$REQUESTEDAPP, '?'));
$param = substr($_GET['app'], strpos($_GET['app'], '?') + 1); $param = substr($_GET['app'], strpos($_GET['app'], '?') + 1);
......
...@@ -97,7 +97,7 @@ class OC_L10N{ ...@@ -97,7 +97,7 @@ class OC_L10N{
if ($this->app === true) { if ($this->app === true) {
return; return;
} }
$app = $this->app; $app = OC_App::cleanAppId($this->app);
$lang = $this->lang; $lang = $this->lang;
$this->app = true; $this->app = true;
// Find the right language // Find the right language
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
OC_JSON::checkAdminUser(); OC_JSON::checkAdminUser();
OCP\JSON::callCheck(); OCP\JSON::callCheck();
OC_App::disable($_POST['appid']); OC_App::disable(OC_App::cleanAppId($_POST['appid']));
OC_JSON::success(); OC_JSON::success();
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
OC_JSON::checkAdminUser(); OC_JSON::checkAdminUser();
OCP\JSON::callCheck(); OCP\JSON::callCheck();
$appid = OC_App::enable($_POST['appid']); $appid = OC_App::enable(OC_App::cleanAppId($_POST['appid']));
if($appid !== false) { if($appid !== false) {
OC_JSON::success(array('data' => array('appid' => $appid))); OC_JSON::success(array('data' => array('appid' => $appid)));
} else { } else {
......
...@@ -4,6 +4,7 @@ OC_Util::checkAdminUser(); ...@@ -4,6 +4,7 @@ OC_Util::checkAdminUser();
OCP\JSON::callCheck(); OCP\JSON::callCheck();
$app = $_GET['app']; $app = $_GET['app'];
$app = OC_App::cleanAppId($app);
//load the one app and see what it adds to the navigation //load the one app and see what it adds to the navigation
OC_App::loadApp($app); OC_App::loadApp($app);
......
...@@ -4,6 +4,7 @@ OC_JSON::checkAdminUser(); ...@@ -4,6 +4,7 @@ OC_JSON::checkAdminUser();
OCP\JSON::callCheck(); OCP\JSON::callCheck();
$appid = $_POST['appid']; $appid = $_POST['appid'];
$appid = OC_App::cleanAppId($appid);
$result = OC_Installer::updateApp($appid); $result = OC_Installer::updateApp($appid);
if($result !== false) { if($result !== false) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment