Issues (1751)

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.

lib/includes/loader.webdav.auth.php (15 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
	function ldSetCredentials($login, $ARUserDir="/system/users/") {
0 ignored issues
show
ldSetCredentials uses the super-global variable $_COOKIE which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
ldSetCredentials uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
The function ldSetCredentials() has been defined more than once; this definition is ignored, only the first definition in lib/includes/loader.cmd.php (L127-128) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
4
		global $ARCurrent, $AR, $LD_NO_SESSION_SUPPORT;
5
6
		if ($LD_NO_SESSION_SUPPORT) {
7
			debug("ldSetCredentials($login): no session support");
8
			return;
9
		}
10
11
		if (!$ARUserDir || $ARUserDir == "") {
12
			$ARUserDir = "/system/users/";
13
		}
14
15
		// Make sure the login is lower case. Because of the
16
		// numerous checks on "admin".
17
		$login = strtolower( $login );
18
19
		debug("ldSetCredentials($login)","object");
20
21
		if (!$ARCurrent->session) {
22
			ldStartSession();
23
		} else {
24
			/* use the same sessionid if the user didn't login before */
25
			ldStartSession($ARCurrent->session->id);
26
		}
27
		$ARCurrent->session->put("ARLogin", $login);
28
		$ARCurrent->session->put("ARUserDir", $ARUserDir, true);
29
30
		/* create the session key */
31
		$session_key = bin2hex(random_bytes(16));
32
33
		$ARCurrent->session->put("ARSessionKey", $session_key, true);
34
		$ARCurrent->session->put("ARSessionTimedout", 0, 1);
35
36
		/* now save our session */
37
		$ARCurrent->session->save();
38
39
		$cookies = (array)$_COOKIE["ARSessionCookie"];
40
41
		foreach($cookies as $sessionid => $cookie){
42
			if(!$AR->hideSessionIDfromURL){
43
				if (!$ARCurrent->session->sessionstore->exists("/$sessionid/")) {
44
					$data = ldDecodeCookie($cookie);
45
					if(is_array($data)) {
46
						// don't just kill it, it may be from another ariadne installation
47
						if ($data['timestamp']<(time()-86400)) {
48
							// but do kill it if it's older than one day
49
							unset($cookie[$sessionid]);
50
							setcookie("ARSessionCookie[".$sessionid."]",null);
51
						}
52
					}
53
				}
54
			} else {
55
				// only 1 cookie allowed, unset all cookies
56
				if( $sessionid != $ARCurrent->session->id) {
57
					setcookie("ARSessionCookie[".$sessionid."]",null);
58
				}
59
			}
60
		}
61
62
		$data = array();
63
64
		$data['login']=$login;
65
		$data['timestamp']=time();
66
		$data['check']=ldGenerateSessionKeyCheck();
67
68
		$cookie=ldEncodeCookie($data);
69
		$cookiename = "ARSessionCookie[".$ARCurrent->session->id."]";
70
71
		debug("setting cookie ()($cookie)");
72
		header('P3P: CP="NOI CUR OUR"');
73
		$https = ($_SERVER['HTTPS']=='on');
74
		setcookie($cookiename,$cookie, 0, '/', false, $https, true);
75
	}
76
77 View Code Duplication
	function ldGenerateSessionKeyCheck() {
0 ignored issues
show
This function seems to be duplicated in 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...
The function ldGenerateSessionKeyCheck() has been defined more than once; this definition is ignored, only the first definition in lib/includes/loader.web.auth.php (L205-211) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
78
	global $ARCurrent;
79
		$session_key = $ARCurrent->session->get('ARSessionKey', true);
80
		$ARUserDir   = $ARCurrent->session->get('ARUserDir', true);
81
		$login       = $ARCurrent->session->get('ARLogin');
82
		return "{".md5($login.$ARUserDir.$session_key)."}";
83
	}
84
85
	function ldGetCredentials() {
0 ignored issues
show
The function ldGetCredentials() has been defined more than once; this definition is ignored, only the first definition in lib/includes/loader.cmd.php (L124-125) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
ldGetCredentials uses the super-global variable $_COOKIE which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
86
		debug("ldGetCredentials()","object");
87
		$ARSessionCookie = $_COOKIE["ARSessionCookie"];
88
		return $ARSessionCookie;
89
	}
90
91 View Code Duplication
	function ldCheckCredentials($login) {
0 ignored issues
show
The function ldCheckCredentials() has been defined more than once; this definition is ignored, only the first definition in lib/includes/loader.cmd.php (L130-131) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
This function seems to be duplicated in 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...
ldCheckCredentials uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
ldCheckCredentials uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
92
	global $ARCurrent, $AR;
93
		debug("ldCheckCredentials()","object");
94
		$result=false;
95
		$cookie=ldGetCredentials();
96
		$data = ldDecodeCookie($cookie[$ARCurrent->session->id]);
97
		if ($login === $data['login']
98
			&& ($saved=$data['check'])) {
99
			$check=ldGenerateSessionKeyCheck();
100
			if ($check === $saved && !$ARCurrent->session->get('ARSessionTimedout', 1)) {
101
				$result=true;
102
			} else {
103
				debug("login check failed","all");
104
			}
105
		} else {
106
			$ARSessionKeyCheck = $_GET['ARSessionKeyCheck'];
107
			if (!$ARSessionKeyCheck) {
108
				$ARSessionKeyCheck = $_POST['ARSessionKeyCheck'];
109
			}
110
			if ($ARSessionKeyCheck) {
111
				debug("ldCheckCredentials: trying ARSessionKeyCheck ($ARSessionKeyCheck)");
112
				if ($ARSessionKeyCheck == ldGenerateSessionKeyCheck()) {
113
					$result = true;
114
				}
115
			} else {
116
				debug("wrong login or corrupted cookie","all");
117
			}
118
		}
119
		return $result;
120
	}
121
122 View Code Duplication
	function ldDecodeCookie($cookie) {
0 ignored issues
show
This function seems to be duplicated in 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...
The function ldDecodeCookie() has been defined more than once; this definition is ignored, only the first definition in lib/includes/loader.web.auth.php (L250-262) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
123
		global $AR;
124
		$data = json_decode($cookie,true);
125
		if(is_null($data)){
126
			if(isset($AR->sessionCryptoKey)) {
127
				$key = base64_decode($AR->sessionCryptoKey);
128
				$crypto = new ar_crypt($key,MCRYPT_RIJNDAEL_256,1);
129
				$data = json_decode($crypto->decrypt($cookie),true);
130
			}
131
		}
132
133
		return $data;
134
	}
135
136 View Code Duplication
	function ldEncodeCookie($cookie) {
0 ignored issues
show
This function seems to be duplicated in 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...
The function ldEncodeCookie() has been defined more than once; this definition is ignored, only the first definition in lib/includes/loader.web.auth.php (L264-276) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
137
		global $AR;
138
		$data = json_encode($cookie);
139
		if(isset($AR->sessionCryptoKey)) {
140
			$key = base64_decode($AR->sessionCryptoKey);
141
			$crypto = new ar_crypt($key,MCRYPT_RIJNDAEL_256,1);
142
			$encdata = $crypto->crypt($data);
143
			if($encdata !== false) {
144
				$data = $encdata;
145
			}
146
		}
147
		return $data;
148
	}
149