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/modules/mod_webdav.php (1 issue)

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
	require_once("HTTP/WebDAV/Server.php");
3
4
	class Ariadne_WebDAV_Server extends HTTP_WebDAV_Server {
5
6
		public function __construct( &$store, $config ) {
7
			global $ariadne;
8
			debug("webdav: initting server");
9
			parent::__construct();
10
			$this->store = $store;
11
			$this->config = $config;
12
			$this->root = &$config['root'];
13
			debug("webdav: loading modules");
14
15
			$this->modules = array();
16
			include_once($ariadne."/modules/mod_webdav/files.php");
17
			$this->modules['files'] = new WebDAV_files($this);
18
19
			debug("webdav: init done");
20
		}
21
22 View Code Duplication
		function path_unescape($path) {
23
			$result = "";
24
			if ($path) {
25
				debug("webdav: escaped path: $path");
26
				$result = preg_replace_callback(
27
					'/(_[0-9a-fA-F][0-9a-fA-F]|__)/',
28
					function ( $matches ) {
29
						// Two types of escaped characters can be here, the
30
						// underscore or other characters. Check for the
31
						// underscore first.
32
33
						$char = $matches[0];
34
						if ($char[1] == "_") {
35
						// It is the underscore, return it as a character.
36
							return "_";
37
						}
38
39
						// Assume it is an escaped character here. Find the
40
						// numbers in hex, turn them back to decimal, get
41
						// the corresponding character and return it.
42
43
						return chr(hexdec(substr($char, 1, 2)));
44
					},
45
					$path
46
				);
47
			}
48
			debug("webdav: unescaped path: $result");
49
			return $result;
50
		}
51
52
		public static function path_unescape_callback($char) {
53
			// Two types of escaped characters can be here, the
54
			// underscore or other characters. Check for the
55
			// underscore first.
56
57
			if ($char[1] == "_") {
58
				// It is the underscore, return it as a character.
59
				return "_";
60
			}
61
62
			// Assume it is an escaped character here. Find the
63
			// numbers in hex, turn them back to decimal, get
64
			// the corresponding character and return it.
65
66
			return chr(hexdec(substr($char, 1, 2)));
67
		}
68
69
		public function check_auth($type, $user, $pass) {
0 ignored issues
show
check_auth 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...
70
		global $AR, $ARCurrent, $auth_config;
71
			debug("webdav:check_auth  $type:$user:$pass;");
72
			$auth_class = "mod_auth_".$auth_config['method'];
73
74
			debug("webdav:check_auth using $auth_class module");
75
76
			$mod_auth = new $auth_class($auth_config);
77
78
			$result = null;
79
80
			/* FIXME: make this configurable */
81
			if (preg_match('/^Microsoft Data Access Internet/i', $_SERVER['HTTP_USER_AGENT'])) {
82
				debug("webdav:check_auth using sessions");
83
				$this->http_auth_realm = "Ariadne WebDAV: ".$ARCurrent->session->id;
84
				if (!$ARCurrent->session || !$ARCurrent->session->id) {
85
					ldStartSession();
86
				}
87
				if ($ARCurrent->session->get('ARSessionTimedout', 1)) {
88
					/* find a better solution than to just kill the session */
89
					$ARCurrent->session->kill();
90
					ldStartSession();
91
				} elseif ($user) {
92
					$result = $mod_auth->checkLogin($user, $pass);
93
				}
94
			} else {
95
				debug("webdav:check_auth no session support");
96
				$this->http_auth_realm = "Ariadne WebDAV";
97
				// do HTTP Basic Auth only, so no session stuff
98
				global $LD_NO_SESSION_SUPPORT;
99
				$LD_NO_SESSION_SUPPORT = true;
100
				if ($user) {
101
					$result = $mod_auth->checkLogin($user, $pass);
102
				}
103
			}
104
			if ($result === true) {
105
				debug("webdav:check_auth success");
106
				debug("webdav:check_auth user loaded: ".$AR->user->data->login);
107
				return true;
108
			} else {
109
				debug("webdav:check_auth failed");
110
				return false;
111
			}
112
		}
113
114
		public function get_info($list) {
115
			$result = Array();
116
			$props = $list['props'];
117
			if (is_array($props)) {
118
				foreach ($props as $name => $val) {
119
					debug("webdav:get_info $name:$val");
120
					if ($name == 'displayname') {
121
						$val = static::path_unescape($val);
122
						debug("webdav:get_info unescaped $val");
123
					}
124
					$result['props'][] = $this->mkprop($name, htmlspecialchars($val));
125
				}
126
			}
127
			$result['path'] = htmlspecialchars(static::path_unescape(substr($list['path'], strlen($this->root)-1)));
128
			return $result;
129
		}
130
131
		public function propfind(&$options, &$files) {
132
			debug("webdav:propfind [end]");
133
			return $this->modules['files']->propfind($options, $files);
134
		}
135
136
		public function head($options) {
137
			debug("webdav:head");
138
			return $this->modules['files']->head($options);
139
		}
140
141
		public function delete($options) {
142
			debug("webdav:delete");
143
			return $this->modules['files']->delete($options);
144
		}
145
146
		public function lock( &$options ) {
147
			debug("method lock called");
148
		}
149
150
		public function checkLock($path) {
151
			debug("method check lock");
152
		}
153
154
		public function mkcol($options) {
155
			debug("webdav:mkcol");
156
			return $this->modules['files']->mkcol($options);
157
		}
158
159
		public function get(&$options) {
160
			debug("webdav:get");
161
			return $this->modules['files']->get($options);
162
		}
163
164
165
		public function move($options) {
166
			debug("webdav:move");
167
			return $this->modules['files']->move($options);
168
		}
169
170
		public function put(&$params) {
171
			debug("webdav:put");
172
			return $this->modules['files']->put($params);
173
		}
174
175
		public function proppatch(&$options) {
176
177
		}
178
179
	} // end class definition
180