Issues (2473)

Branch: master

Security Analysis    no vulnerabilities found

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.

engine/lib/upgrade.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
 * Elgg upgrade library.
4
 * Contains code for handling versioning and upgrades.
5
 *
6
 * @package    Elgg.Core
7
 * @subpackage Upgrade
8
 */
9
10
/**
11
 * Saves the processed upgrades to a dataset.
12
 *
13
 * @param array $processed_upgrades An array of processed upgrade filenames
14
 *                                  (not the path, just the file)
15
 * @return bool
16
 * @access private
17
 *
18
 * @todo this is still required because of the hack in the 2011010101 upgrade
19
 */
20
function elgg_set_processed_upgrades(array $processed_upgrades) {
21
	$processed_upgrades = array_unique($processed_upgrades);
22
	return datalist_set('processed_upgrades', serialize($processed_upgrades));
23
}
24
25
/**
26
 * Returns the version of the upgrade filename.
27
 *
28
 * @param string $filename The upgrade filename. No full path.
29
 * @return int|false
30
 * @since 1.8.0
31
 * @access private
32
 * @todo used by elgg_get_upgrade_files
33
 */
34 View Code Duplication
function elgg_get_upgrade_file_version($filename) {
35
	preg_match('/^([0-9]{10})([\.a-z0-9-_]+)?\.(php)$/i', $filename, $matches);
36
37
	if (isset($matches[1])) {
38
		return (int) $matches[1];
39
	}
40
41
	return false;
42
}
43
44
/**
45
 * Returns a list of upgrade files relative to the $upgrade_path dir.
46
 *
47
 * @param string $upgrade_path The directory that has upgrade scripts
48
 * @return array|false
49
 * @access private
50
 *
51
 * @todo the wire and groups plugins and the installer are using this
52
 */
53
function elgg_get_upgrade_files($upgrade_path = null) {
54
	if (!$upgrade_path) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $upgrade_path of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null 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...
55
		$upgrade_path = elgg_get_root_path() . 'engine/lib/upgrades/';
56
	}
57
	$upgrade_path = sanitise_filepath($upgrade_path);
58
	$handle = opendir($upgrade_path);
59
60
	if (!$handle) {
61
		return false;
62
	}
63
64
	$upgrade_files = array();
65
66 View Code Duplication
	while ($upgrade_file = readdir($handle)) {
67
		// make sure this is a well formed upgrade.
68
		if (is_dir($upgrade_path . '$upgrade_file')) {
69
			continue;
70
		}
71
		$upgrade_version = elgg_get_upgrade_file_version($upgrade_file);
72
		if (!$upgrade_version) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $upgrade_version of type integer|false is loosely compared to false; this is ambiguous if the integer can be zero. You might want to explicitly use === null instead.

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

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
73
			continue;
74
		}
75
		$upgrade_files[] = $upgrade_file;
76
	}
77
78
	sort($upgrade_files);
79
80
	return $upgrade_files;
81
}
82
83
/**
84
 * Unlocks upgrade.
85
 *
86
 * @access private
87
 *
88
 * @todo the hack in the 2011010101 upgrade requires this
89
 */
90
function _elgg_upgrade_unlock() {
91
	global $CONFIG;
92
	delete_data("drop table {$CONFIG->dbprefix}upgrade_lock");
93
	elgg_log('Upgrade unlocked.', 'NOTICE');
94
}
95