Issues (201)

Security Analysis    no request data  

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.

includes/Controller/Login.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
namespace Redaxscript\Controller;
3
4
use Redaxscript\Auth;
5
use Redaxscript\Filter;
6
use Redaxscript\Model;
7
use Redaxscript\Validator;
8
9
/**
10
 * children class to process the login request
11
 *
12
 * @since 3.0.0
13
 *
14
 * @package Redaxscript
15
 * @category Controller
16
 * @author Henry Ruhs
17
 * @author Balázs Szilágyi
18
 */
19
20
class Login extends ControllerAbstract
21
{
22
	/**
23
	 * process the class
24
	 *
25
	 * @since 3.0.0
26
	 *
27
	 * @return string
28
	 */
29
30 5
	public function process() : string
31
	{
32 5
		$postArray = $this->_normalizePost($this->_sanitizePost());
33 5
		$validateArray = $this->_validatePost($postArray);
34 5
		$user = $this->_getUser($postArray);
35
36
		/* validate post */
37
38 5
		if ($validateArray)
39
		{
40 4
			return $this->_error(
41
			[
42 4
				'route' => 'login',
43 4
				'message' => $validateArray
44
			]);
45
		}
46
47
		/* handle login */
48
49 1
		if ($this->_login($user?->id))
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_OBJECT_OPERATOR
Loading history...
50
		{
51 1
			return $this->_success(
52
			[
53 1
				'route' => 'admin',
54 1
				'timeout' => 0,
55 1
				'message' => $this->_language->get('logged_in'),
56 1
				'title' => $this->_language->get('welcome')
57
			]);
58
		}
59
60
		/* handle error */
61
62
		return $this->_error(
63
		[
64
			'route' => 'login'
65
		]);
66
	}
67
68
	/**
69
	 * sanitize the post
70
	 *
71
	 * @since 4.0.0
72
	 *
73
	 * @return array
74
	 */
75
76 5
	protected function _sanitizePost() : array
77
	{
78 5
		$numberFilter = new Filter\Number();
79 5
		$passwordFilter = new Filter\Password();
80 5
		$textFilter = new Filter\Text();
81 5
		$userFilter = new Filter\User();
82
83
		/* sanitize post */
84
85
		return
86
		[
87 5
			'user' => $userFilter->sanitize($this->_request->getPost('user')),
88 5
			'password' => $passwordFilter->sanitize($this->_request->getPost('password')),
89 5
			'task' => $numberFilter->sanitize($this->_request->getPost('task')),
90 5
			'solution' => $textFilter->sanitize($this->_request->getPost('solution'))
91
		];
92
	}
93
94
	/**
95
	 * validate the post
96
	 *
97
	 * @since 3.0.0
98
	 *
99
	 * @param array $postArray array of the post
100
	 *
101
	 * @return array
102
	 */
103
104 5
	protected function _validatePost(array $postArray = []) : array
105
	{
106 5
		$userValidator = new Validator\User();
107 5
		$passwordValidator = new Validator\Password();
108 5
		$captchaValidator = new Validator\Captcha();
109 5
		$settingModel = new Model\Setting();
110 5
		$user = $this->_getUser($postArray);
111 5
		$validateArray = [];
112
113
		/* validate post */
114
115 5
		if (!$postArray['user'])
116
		{
117 1
			$validateArray[] = $this->_language->get('user_empty');
118
		}
119 4
		else if (!$userValidator->validate($postArray['user']))
120
		{
121 1
			$validateArray[] = $this->_language->get('user_incorrect');
122
		}
123 3
		else if (!$user?->id)
124
		{
125 1
			$validateArray[] = $this->_language->get('login_incorrect');
126
		}
127 5
		if (!$postArray['password'])
128
		{
129 1
			$validateArray[] = $this->_language->get('password_empty');
130
		}
131 4
		else if (!$passwordValidator->validate($postArray['password']))
132
		{
133 1
			$validateArray[] = $this->_language->get('password_incorrect');
134
		}
135 3
		else if ($user?->id && !$passwordValidator->matchHash($postArray['password'], $user?->password))
136
		{
137 1
			$validateArray[] = $this->_language->get('login_incorrect');
138
		}
139 5
		if ($settingModel->get('captcha') > 0 && !$captchaValidator->validate($postArray['task'], $postArray['solution']))
140
		{
141 2
			$validateArray[] = $this->_language->get('captcha_incorrect');
142
		}
143 5
		return $validateArray;
144
	}
145
146
	/**
147
	 * get the user
148
	 *
149
	 * @since 4.0.0
150
	 *
151
	 * @param array $postArray array of the post
152
	 *
153
	 * @return object|null
154
	 */
155
156 5
	protected function _getUser(array $postArray = []) : ?object
157
	{
158 5
		$userModel = new Model\User();
159 5
		return $userModel->getByUser($postArray['user']);
160
	}
161
162
	/**
163
	 * login the user
164
	 *
165
	 * @since 3.0.0
166
	 *
167
	 * @param int $userId identifier of the user
168
	 *
169
	 * @return bool
170
	 */
171
172 1
	protected function _login(int $userId = null) : bool
173
	{
174 1
		$auth = new Auth($this->_request);
175 1
		return $auth->login($userId);
176
	}
177
}
178