Issues (1844)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

checkemail.php (2 issues)

1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    {@link https://xoops.org/ XOOPS Project}
15
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @author       Brian Wahoff <[email protected]>
17
 * @author       Eric Juden <[email protected]>
18
 * @author       XOOPS Development Team
19
 */
20
21
use XoopsModules\Xhelp;
22
23
require __DIR__ . '/servicemain.php';
24
25
//Include xhelp Related Includes
26
//require_once XHELP_INCLUDE_PATH . '/events.php';
27
//require_once XHELP_CLASS_PATH . '/mailboxPOP3.php';
28
//require_once XHELP_CLASS_PATH . '/EmailParser.php';
29
//require_once XHELP_CLASS_PATH . '/EmailStore.php';
30
//require_once XHELP_CLASS_PATH . '/validator.php';
31
32
$helper       = Xhelp\Helper::getInstance();
33
$eventService = Xhelp\EventService::getInstance();
34
35
//Initialize xhelp objects
36
$msgParser = new Xhelp\EmailParser();
37
$msgStore  = new Xhelp\EmailStore();
38
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */
39
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox');
40
/** @var \XoopsModules\Xhelp\MailEventHandler $mailEventHandler */
41
$mailEventHandler = $helper->getHandler('MailEvent');
42
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */
43
$ticketHandler = $helper->getHandler('Ticket');
44
//$notificationService =  Xhelp\NotificationService::getInstance();
45
46
//$eventService->advise('new_user_by_email', Xhelp\NotificationService::getInstance(), 'new_user_activation' . $xoopsConfigUser['activation_type']);
47
$eventService->advise('new_user_by_email', 'new_user_activation' . $xoopsConfigUser['activation_type']);
48
49
//Get All Department Mailboxes
50
$departmentMailBoxes = $departmentMailBoxHandler->getActiveMailboxes();
51
52
//Loop Through All Department Mailboxes
53
foreach ($departmentMailBoxes as $mbox) {
54
    $deptid = $mbox->getVar('departmentid');
55
    //Connect to the mailbox
56
    if ($mbox->connect()) {
57
        //Check for new messages
58
        if ($mbox->hasMessages()) {
59
            //Retrieve / Store each message
60
            while ($msg = $mbox->getMessage()) {
61
                $msg_logs = [];
62
                $skip_msg = false;
63
64
                //Check if there are any errors parsing msg
65
                $parsed = $msgParser->parseMessage($msg);
66
                if ($parsed) {
67
                    //Sanity Check: Disallow emails from other department mailboxes
68
                    if (isDepartmentEmail($parsed->getEmail())) {
69
                        $msg_logs[_XHELP_MAIL_CLASS3][] = sprintf(_XHELP_MESSAGE_EMAIL_DEPT_MBOX, $parsed->getEmail());
70
                    } else {
71
                        //Create new user account if necessary
72
                        if (!$xoopsUser = Xhelp\Utility::emailIsXoopsUser($parsed->getEmail())) {
73
                            if ($helper->getConfig('xhelp_allowAnonymous')) {
74
                                switch ($xoopsConfigUser['activation_type']) {
75
                                    case 1:
76
                                        $level = 1;
77
                                        break;
78
                                    case 0:
79
                                    case 2:
80
                                    default:
81
                                        $level = 0;
82
                                }
83
                                $xoopsUser = Xhelp\Utility::getXoopsAccountFromEmail($parsed->getEmail(), $parsed->getName(), $password, $level);
84
                                $eventService->trigger('new_user_by_email', [$password, $xoopsUser]);
85
                            } else {
86
                                $msg_logs[_XHELP_MAIL_CLASS3][] = sprintf(_XHELP_MESSAGE_NO_ANON, $parsed->getEmail());
87
                                $skip_msg                       = true;
88
                            }
89
                        }
90
91
                        if (false === $skip_msg) {
92
                            //Store Message In Server
93
                            $obj = $msgStore->storeMsg($parsed, $xoopsUser, $mbox, $errors);
0 ignored issues
show
It seems like $xoopsUser can also be of type boolean; however, parameter $user of XoopsModules\Xhelp\EmailStore::storeMsg() does only seem to accept XoopsUser, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

93
                            $obj = $msgStore->storeMsg($parsed, /** @scrutinizer ignore-type */ $xoopsUser, $mbox, $errors);
Loading history...
94
                            if ($obj) {
95
                                switch ($parsed->getMsgType()) {
96
                                    case _XHELP_MSGTYPE_TICKET:
97
                                        //Trigger New Ticket Events
98
                                        $eventService->trigger('new_ticket', $obj);
99
                                        break;
100
                                    case _XHELP_MSGTYPE_RESPONSE:
101
                                        //Trigger New Response Events
102
                                        $eventService->trigger('new_response', $obj);
103
                                        break;
104
                                }
105
                                //} else {        // If message not stored properly, log event
106
                                //    $storeEvent = $mailEventHandler->newEvent($mbox->getVar('id'), _XHELP_MAILEVENT_DESC2, _XHELP_MAILEVENT_CLASS2);
107
                            } else {
108
                                $msg_logs[_XHELP_MAILEVENT_CLASS2] = &$errors;
109
                            }
110
                        }
111
                    }
112
                } else {
113
                    $msg_logs[_XHELP_MAILEVENT_CLASS1][] = _XHELP_MAILEVENT_DESC1;
114
                }
115
                //Remove Message From Server
116
                $mbox->deleteMessage($msg);
117
118
                //Log Any Messages
119
                logMessages($mbox->getVar('id'), $msg_logs);
120
            }
121
        }
122
        //Disconnect from Server
123
        $mbox->disconnect();
124
    } else {                        // If mailbox not connected properly, log event
125
        $connEvent = $mailEventHandler->newEvent($mbox->getVar('id'), _XHELP_MAILEVENT_DESC0, (string)_XHELP_MAILEVENT_CLASS0);
126
    }
127
}
128
129
/**
130
 * @param int   $mbox
131
 * @param array $arr
132
 */
133
function logMessages(int $mbox, array $arr)
134
{
135
    global $mailEventHandler;
136
    foreach ($arr as $class => $msg) {
137
        if (is_array($msg)) {
138
            $msg = implode("\r\n", $msg);
139
        }
140
        $event = $mailEventHandler->newEvent($mbox, $msg, $class);
0 ignored issues
show
The assignment to $event is dead and can be removed.
Loading history...
141
    }
142
}
143
144
/**
145
 * @param string $email
146
 * @return bool
147
 */
148
function isDepartmentEmail(string $email): bool
149
{
150
    static $email_arr;
151
152
    if (null === $email_arr) {
153
        global $departmentMailBoxHandler;
154
        $departmentMailBoxes = $departmentMailBoxHandler->getObjects();
155
        $email_arr           = [];
156
        foreach ($departmentMailBoxes as $mbox) {
157
            $email_arr[] = $mbox->getVar('emailaddress');
158
        }
159
        unset($departmentMailBoxes);
160
    }
161
162
    $ret = in_array($email, $email_arr);
163
164
    return $ret;
165
}
166