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.

mod/embed/start.php (1 issue)

Labels
Severity

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 media embed plugin
4
 *
5
 * @package ElggEmbed
6
 */
7
8
9
elgg_register_event_handler('init', 'system', 'embed_init');
10
11
/**
12
 * Init function
13
 */
14
function embed_init() {
15
	elgg_extend_view('css/elgg', 'embed/css');
16
	elgg_extend_view('css/admin', 'embed/css');
17
18
	if (elgg_is_logged_in()) {
19
		elgg_register_plugin_hook_handler('register', 'menu:longtext', 'embed_longtext_menu');
20
	}
21
	elgg_register_plugin_hook_handler('register', 'menu:embed', 'embed_select_tab', 1000);
22
23
	// Page handler for the modal media embed
24
	elgg_register_page_handler('embed', 'embed_page_handler');
25
	
26
	$embed_js = elgg_get_simplecache_url('js', 'embed/embed');
27
	elgg_register_js('elgg.embed', $embed_js, 'footer');
28
}
29
30
/**
31
 * Add the embed menu item to the long text menu
32
 *
33
 * @param string $hook
34
 * @param string $type
35
 * @param array $items
36
 * @param array $vars
37
 * @return array
38
 */
39
function embed_longtext_menu($hook, $type, $items, $vars) {
40
41
	if (elgg_get_context() == 'embed') {
42
		return $items;
43
	}
44
45
	$url = 'embed';
46
47
	$page_owner = elgg_get_page_owner_entity();
48
	if (elgg_instanceof($page_owner, 'group') && $page_owner->isMember()) {
49
		$url = 'embed?container_guid=' . $page_owner->getGUID();
50
	}
51
52
	elgg_load_js('lightbox');
53
	elgg_load_css('lightbox');
54
	elgg_require_js('jquery.form');
55
	elgg_load_js('elgg.embed');
56
57
	$text = elgg_echo('embed:media');
58
59
	// if loaded through ajax (like on /activity), pull in JS libs manually
60
	// hack for #6422 because we haven't converted everything to amd yet
61
	if (elgg_in_context('ajax')) {
62
		$externals = elgg_get_config('externals_map');
63
		$embed = elgg_extract('elgg.embed', $externals['js']);
64
		$lightbox_js = elgg_extract('lightbox', $externals['js']);
65
		$lightbox_css = elgg_extract('lightbox', $externals['css']);
66
		
67
		$text .= <<<___JS
68
<script>
69
	require(['jquery.form']);
70
	if (typeof $.fancybox === 'undefined') {
71
		$.getScript('$lightbox_js->url');
72
		$('head').append('<link rel="stylesheet" href="$lightbox_css->url"></link>');
73
	}
74
	if (typeof elgg.embed === 'undefined') {
75
		$.getScript('$embed->url');
76
	}
77
</script>
78
___JS;
79
	}
80
81
	$items[] = ElggMenuItem::factory(array(
82
		'name' => 'embed',
83
		'href' => 'javascript:void()',
84
		'data-colorbox-opts' => json_encode([
85
			'href' => elgg_normalize_url($url),
86
		]),
87
		'text' => $text,
88
		'rel' => "embed-lightbox-{$vars['id']}",
89
		'link_class' => "elgg-longtext-control elgg-lightbox embed-control embed-control-{$vars['id']}",
90
		'priority' => 10,
91
	));
92
	
93
	return $items;
94
}
95
96
/**
97
 * Select the correct embed tab for display
98
 *
99
 * @param string $hook
100
 * @param string $type
101
 * @param array $items
102
 * @param array $vars
103
 */
104
function embed_select_tab($hook, $type, $items, $vars) {
105
106
	// can this ba called from page handler instead?
107
	$page = get_input('page');
108
	$tab_name = array_pop(explode('/', $page));
0 ignored issues
show
explode('/', $page) cannot be passed to array_pop() as the parameter $array expects a reference.
Loading history...
109
	foreach ($items as $item) {
110
		if ($item->getName() == $tab_name) {
111
			$item->setSelected();
112
			elgg_set_config('embed_tab', $item);
113
		}
114
	}
115
116
	if (!elgg_get_config('embed_tab') && count($items) > 0) {
117
		$items[0]->setSelected();
118
		elgg_set_config('embed_tab', $items[0]);
119
	}
120
}
121
122
/**
123
 * Serves the content for the embed lightbox
124
 *
125
 * @param array $page URL segments
126
 */
127
function embed_page_handler($page) {
128
129
	$container_guid = (int)get_input('container_guid');
130
	if ($container_guid) {
131
		$container = get_entity($container_guid);
132
133
		if (elgg_instanceof($container, 'group') && $container->isMember()) {
134
			// embedding inside a group so save file to group files
135
			elgg_set_page_owner_guid($container_guid);
136
		}
137
	}
138
139
	set_input('page', $page[1]); 
140
141
	echo elgg_view('embed/layout');
142
143
	// exit because this is in a modal display.
144
	exit;
145
}
146
147
/**
148
 * A special listing function for selectable content
149
 *
150
 * This calls a custom list view for entities. 
151
 *
152
 * @param array $entities Array of ElggEntity objects
153
 * @param array $vars     Display parameters
154
 * @return string
155
 */
156
function embed_list_items($entities, $vars = array()) {
157
158
	$defaults = array(
159
		'items' => $entities,
160
		'list_class' => 'elgg-list-entity',
161
	);
162
163
	$vars = array_merge($defaults, $vars);
164
165
	return elgg_view('embed/list', $vars);
166
}
167
168
/**
169
 * Set the options for the list of embedable content
170
 *
171
 * @param array $options
172
 * @return array
173
 */
174
function embed_get_list_options($options = array()) {
175
176
	$container_guids = array(elgg_get_logged_in_user_guid());
177
	if (elgg_get_page_owner_guid()) {
178
		$page_owner_guid = elgg_get_page_owner_guid();
179
		if ($page_owner_guid != elgg_get_logged_in_user_guid()) {
180
			$container_guids[] = $page_owner_guid;
181
		}
182
	}
183
184
	$defaults = array(
185
		'limit' => 6,
186
		'container_guids' => $container_guids,
187
		'item_class' => 'embed-item',
188
	);
189
190
	$options = array_merge($defaults, $options);
191
192
	return $options;
193
}
194