Issues (40)

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.

lib/Hooks.php (1 issue)

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
 *
5
 * @author Semih Serhat Karakaya
6
 * @copyright Copyright (c) 2016, ITU IT HEAD OFFICE.
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Security;
24
25
use OC\User\LoginException;
26
use OCP\IUserManager;
27
use OCP\IRequest;
28
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
29
use Symfony\Component\EventDispatcher\GenericEvent;
30
31
/**
32
 * Class Hooks
33
 * @package OCA\Secuity\Lib
34
 */
35
class Hooks {
36
37
    /** @var \OC\User\Manager */
38
    private $userManager;
39
40
    /** @var Throttle*/
41
    private $throttle;
42
43
    /** @var IRequest*/
44
    private $request;
45
46
    /** @var PasswordValidator */
47
    private $passValidator;
48
49
    /** @var EventDispatcherInterface */
50
    private $dispatcher;
51
52
    /**
53
     * @param IUserManager $userManager
54
     * @param Throttle $throttle
55
     * @param IRequest $request
56
     * @param PasswordValidator $passValidator
57
     * @param EventDispatcherInterface $dispatcher
58
     */
59
    public function __construct($userManager, $throttle, $request, $passValidator, $dispatcher){
60
        $this->userManager = $userManager;
0 ignored issues
show
Documentation Bug introduced by
It seems like $userManager of type object<OCP\IUserManager> is incompatible with the declared type object<OC\User\Manager> of property $userManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
        $this->throttle = $throttle;
62
        $this->request = $request;
63
        $this->passValidator = $passValidator;
64
        $this->dispatcher = $dispatcher;
65
66
    }
67
68
    public function register() {
69
        $this->userManager->listen('\OC\User', 'preLogin', function($uid) {
70
            $this->preLoginCallback($uid);
71
        });
72
73
        $this->userManager->listen('\OC\User', 'failedLogin', function($uid) {
74
            $this->failedLoginCallback($uid);
75
        });
76
        
77
        $this->userManager->listen('\OC\User', 'postLogin', function($user) {
78
            /** @var $user \OC\User\User */
79
            $this->postLoginCallback($user->getUID());
80
        });
81
82
        $this->dispatcher->addListener('OCP\User::validatePassword', function(GenericEvent $event) {
83
            $this->passValidator->validate($event->getArgument('password'));
84
        });
85
86
    }
87
88
    /**
89
     * @param string $uid
90
     */
91
    public function failedLoginCallback($uid) {
92
        $this->throttle->addFailedLoginAttempt($uid, $this->request->getRemoteAddress());
93
    }
94
95
    /**
96
     * @param string $uid
97
     */
98
    public function postLoginCallback($uid) {
99
        $this->throttle->clearSuspiciousAttemptsForUidIpCombination($uid, $this->request->getRemoteAddress());
100
    }
101
102
    /**
103
     * @param string $uid
104
     * @throws LoginException
105
     */
106
    public function preLoginCallback($uid) {
107
        $this->throttle->applyBruteForcePolicy($uid, $this->request->getRemoteAddress());
108
    }
109
}
110