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/cp_notifications/activate.php (2 issues)

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
/**
4
 * Setup MySQL databases:
5
 * please note: when enabling the digest functionality, if the site activity is high, there may be chance of exceeding character limit that can be saved in the database
6
 * upon enabling module, we will create a new table with column data type that allows for more character storage.
7
 * 
8
 * create the indices for specific columns in the table that we just created
9
 */
10
11
run_sql_script(__DIR__ . '/install/mysql.sql');
12
13
14
/**
15
 * If there was an old version of cp_notifications installed in the past, check
16
 * and make sure that the information is migrated to and using the right tables then
17
 * start doing a clean up of the old data that is saved in the old data table structure
18
 */
19
$db_prefix = elgg_get_config('dbprefix');
20
$query = "SELECT * FROM {$db_prefix}objects_entity WHERE title LIKE 'Newsletter|%'";
21
$newsletter_objects = get_data($query);
22
23
if (count($newsletter_objects) > 0) {
24
25
    // iterate through each newsletter object
26
    foreach ($newsletter_objects as $newsletter_object) {
27
        
28
        $newsletter_title = explode('|', $newsletter_object->title);
29
30
        // if user does not exist because it was deleted, remove digest then skip
31
        if (!(get_user_by_email($newsletter_title[1]) instanceof ElggUser)) 
32
        {
33
            $object = get_entity($newsletter_object->guid);
34
            $object->delete();
35
            continue; 
36
        }
37
38
        // long term fix for the chracter limit, segregate all the entries into records, retrieve via the user guid
39
        $newsletter_descriptions = json_decode($newsletter_object->description, true);
40
        foreach ($newsletter_descriptions as $newsletter_header => $newsletter_contents) {
41
    
42
43
            foreach ($newsletter_contents as $content_type => $contents) {
44
45
                foreach ($contents as $content_id => $content) {
46
47
                    // group notifications are different than the rest (the content is saved as an array)
48
                    if ($newsletter_header === 'group') {
49
                        $group_contents = $content;
50
                        
51
                        foreach ($group_contents as $group_content_id => $group_content) {
52
                            /**
53
                             * entity_guid:	$group_content_id
54
                             * user id:     $newsletter_title[1]
55
                             * entry_tyoe:  $content_id
56
                             * group_name:  $content_type
57
                             * action_type:	$newsletter_header
58
                             * notification_entry: $group_content
59
                             */ 
60
61
                            $content_type = base64_encode($content_type);
62
                            $user_guid = (is_numeric($user_guid)) ? $user_guid : get_user_by_email($newsletter_title[1])->getGUID();
0 ignored issues
show
The method getGUID cannot be called on get_user_by_email($newsletter_title[1]) (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
63
                            $query = "INSERT INTO notification_digest ( entity_guid, user_guid, entry_type, group_name, action_type, notification_entry ) VALUES ( {$group_content_id}, {$newsletter_title[1]}, '{$newsletter_header}', '{$content_type}', '{$content_id}', '{$group_content}' )";
64
                            $body .= '<br/>'.$query.'<br/>';
65
                            $insert_row = insert_data($query);
66
                        }
67
68
                    } else {
69
70
                        /**
71
                         * entity_guid:	$content_id
72
                         * user id:     $newsletter_title[1]
73
                         * entry_tyoe:  $content_type
74
                         * group_name:  NULL
75
                         * action_type:	$newsletter_header 
76
                         * notification_entry: $content
77
                         */ 
78
79
80
                        $content_id = preg_replace("/[^0-9,.]/", "", $content_id);
81
                        $user_guid = (is_numeric($user_guid)) ? $user_guid : get_user_by_email($newsletter_title[1])->getGUID();
0 ignored issues
show
The method getGUID cannot be called on get_user_by_email($newsletter_title[1]) (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
82
83
                        $query = "INSERT INTO notification_digest ( entity_guid, user_guid, entry_type, group_name, action_type, notification_entry ) VALUES ( {$content_id}, {$newsletter_title[1]}, '{$newsletter_header}', NULL, '{$content_type}', '{$content_id}', '{$content}' )";
84
                        $insert_row = insert_data($query);
85
                    }
86
                }
87
            }
88
        }
89
90
        // remove the cpn_newsletter metadata... we don't need a reference between object entity and the digest metadata
91
        $user = get_user($newsletter_title[1]);
92
        $user->deleteMetadata('cpn_newsletter');
93
94
        // delete the Newsletter object
95
        $object = get_entity($newsletter_object->guid);
96
        $object->delete();
97
    }
98
}
99