This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 $_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);
}
}
![]() 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
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
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. ![]() 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
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
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
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() 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);
}
}
![]() |
|||
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
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() 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. ![]() 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);
}
}
![]() 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);
}
}
![]() |
|||
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. ![]() 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
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
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. ![]() 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
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
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 |
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: