Issues (632)

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.

Apps/Model/Front/User/FormLogin.php (1 issue)

Severity
1
<?php
2
3
namespace Apps\Model\Front\User;
4
5
use Apps\ActiveRecord\User;
6
use Apps\ActiveRecord\UserLog;
7
use Ffcms\Core\App;
8
use Ffcms\Core\Arch\Model;
9
use Ffcms\Core\Helper\Crypt;
10
use Ffcms\Core\Interfaces\iUser;
11
12
/**
13
 * Class FormLogin. User login business logic model
14
 * @package Apps\Model\Front\User
15
 */
16
class FormLogin extends Model
17
{
18
    public $email;
19
    public $password;
20
    public $captcha;
21
22
    private $_captcha = false;
23
24
    /**
25
     * Construct FormLogin. Pass is captcha used inside
26
     * @param bool $captcha
27
     */
28
    public function __construct($captcha = false)
29
    {
30
        $this->_captcha = $captcha;
31
        // tell that we shall use csrf protection
32
        parent::__construct(true);
33
    }
34
35
    /**
36
     * Login validation rules
37
     * @return array
38
     */
39
    public function rules(): array
40
    {
41
        $rules = [
42
            [['email', 'password'], 'required'],
43
            ['email', 'length_min', '2'],
44
            ['password', 'length_min', '3'],
45
            ['email', 'email'],
46
            ['captcha', 'used']
47
        ];
48
        if ($this->_captcha) {
49
            $rules[] = ['captcha', 'App::$Captcha::validate'];
50
        }
51
        return $rules;
52
    }
53
54
    /**
55
     * Form labels
56
     * @return array
57
     */
58
    public function labels(): array
59
    {
60
        return [
61
            'email' => __('Email'),
62
            'password' => __('Password'),
63
            'captcha' => __('Captcha')
64
        ];
65
    }
66
67
    /**
68
     * Try user auth after form validate
69
     * @return bool
70
     */
71
    public function tryAuth(): bool
72
    {
73
        /** @var User $user */
74
        $user = User::where('email', $this->email)
75
            ->first();
76
77
        // row found, check if approved and compare password
78
        if ($user && !$user->approve_token) {
79
            // check if legacy password hash used (ffcms 3.0 or early)
80
            if (Crypt::isOldPasswordHash($user->password) && App::$Security->password_hash($this->password) === $user->password) {
0 ignored issues
show
Deprecated Code introduced by
The function Ffcms\Core\Helper\Security::password_hash() has been deprecated. ( Ignorable by Annotation )

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

80
            if (Crypt::isOldPasswordHash($user->password) && /** @scrutinizer ignore-deprecated */ App::$Security->password_hash($this->password) === $user->password) {
Loading history...
81
                // update password to new blowfish crypt hash
82
                $user->password = Crypt::passwordHash($this->password);
83
                $user->save();
84
                return $this->openSession($user);
85
            }
86
87
            // validate new password hash
88
            if (Crypt::passwordVerify($this->password, $user->password)) {
89
                return $this->openSession($user);
90
            }
91
        }
92
        // auth failed
93
        return false;
94
    }
95
96
    /**
97
     * Open session and store data token to db
98
     * @param iUser $userObject
99
     * @return bool
100
     */
101
    public function openSession(iUser $userObject): bool
102
    {
103
        if (!$userObject || $userObject->id < 1) {
104
            return false;
105
        }
106
107
        // write session data
108
        App::$Session->set('ff_user_id', $userObject->id);
109
110
        // write user log
111
        $log = new UserLog();
112
        $log->user_id = $userObject->id;
113
        $log->type = 'AUTH';
114
        $log->message = __('Successful authorization from ip: %ip%', ['ip' => App::$Request->getClientIp()]);
115
        $log->save();
116
117
        return true;
118
    }
119
}
120