Issues (1798)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

public.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @author Björn Schießle <[email protected]>
4
 * @author Christopher Schäpers <[email protected]>
5
 * @author Jörn Friedrich Dreyer <[email protected]>
6
 * @author Lukas Reschke <[email protected]>
7
 * @author Philipp Schaffrath <[email protected]>
8
 * @author Robin Appelman <[email protected]>
9
 * @author Thomas Müller <[email protected]>
10
 * @author Victor Dubiniuk <[email protected]>
11
 * @author Vincent Petry <[email protected]>
12
 *
13
 * @copyright Copyright (c) 2018, ownCloud GmbH
14
 * @license AGPL-3.0
15
 *
16
 * This code is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License, version 3,
18
 * as published by the Free Software Foundation.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
 * GNU Affero General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU Affero General Public License, version 3,
26
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
27
 *
28
 */
29
try {
30
	require_once __DIR__ . '/lib/base.php';
31
	if (\OCP\Util::needUpgrade()) {
32
		// since the behavior of apps or remotes are unpredictable during
33
		// an upgrade, return a 503 directly
34
		OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
35
		OC_Template::printErrorPage('Service unavailable');
36
		exit;
37
	}
38
39
	$request = \OC::$server->getRequest();
40
	OC::checkMaintenanceMode($request);
41
	OC::checkSingleUserMode(true);
42
	$pathInfo = $request->getPathInfo();
43
44
	if (!$pathInfo && $request->getParam('service', '') === '') {
0 ignored issues
show
Bug Best Practice introduced by
The expression $pathInfo of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
45
		\header('HTTP/1.0 404 Not Found');
46
		$dispatcher = \OC::$server->getEventDispatcher();
47
		$dispatcher->dispatch(\OCP\Http\HttpEvents::EVENT_404, new OCP\Http\HttpEvents(
48
			\OCP\Http\HttpEvents::EVENT_404,
49
			OC::$server->getRequest()
50
		));
51
		exit;
52
	} elseif ($request->getParam('service', '')) {
53
		$service = $request->getParam('service', '');
54
	} else {
55
		$pathInfo = \trim($pathInfo, '/');
56
		list($service) = \explode('/', $pathInfo);
57
	}
58
	$file = \OC::$server->getConfig()->getAppValue('core', 'public_' . \strip_tags($service));
59 View Code Duplication
	if ($file === null) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
		\header('HTTP/1.0 404 Not Found');
61
		$dispatcher = \OC::$server->getEventDispatcher();
62
		$dispatcher->dispatch(\OCP\Http\HttpEvents::EVENT_404, new OCP\Http\HttpEvents(
63
			\OCP\Http\HttpEvents::EVENT_404,
64
			OC::$server->getRequest()
65
		));
66
		exit;
67
	}
68
69
	$parts = \explode('/', $file, 2);
70
	$app = $parts[0];
71
72
	// Load all required applications
73
	\OC::$REQUESTEDAPP = $app;
74
	OC_App::loadApps(['authentication']);
75
	OC_App::loadApps(['filesystem', 'logging']);
76
77
	if (!\OC::$server->getAppManager()->isInstalled($app)) {
78
		throw new Exception('App not installed: ' . $app);
79
	}
80
	OC_App::loadApp($app);
81
	OC_User::setIncognitoMode(true);
82
83
	$baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';
84
85
	require_once OC_App::getAppPath($app) . '/' . $parts[1];
86
} catch (Exception $ex) {
87
	if ($ex instanceof \OC\ServiceUnavailableException) {
88
		OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
89
	} else {
90
		OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
91
	}
92
	//show the user a detailed error page
93
	\OC::$server->getLogger()->logException($ex, ['app' => 'public']);
94
	OC_Template::printExceptionErrorPage($ex);
95
} catch (Error $ex) {
96
	//show the user a detailed error page
97
	OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
98
	\OC::$server->getLogger()->logException($ex, ['app' => 'public']);
99
	OC_Template::printExceptionErrorPage($ex);
100
}
101