Issues (170)

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.

plugins/recaptcha/index.php (5 issues)

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
class RecaptchaPlugin extends \RainLoop\Plugins\AbstractPlugin
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type RecaptchaPlugin has been defined more than once; this definition is ignored, only the first definition in plugins/_depricated/recaptcha/index.php (L3-139) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
4
{
5
	/**
6
	 * @return void
7
	 */
8
	public function Init()
9
	{
10
		$this->UseLangs(true);
11
12
		$this->addJs('js/recaptcha.js');
13
14
		$this->addHook('ajax.action-pre-call', 'AjaxActionPreCall');
15
		$this->addHook('filter.ajax-response', 'FilterAjaxResponse');
16
	}
17
18
	/**
19
	 * @return array
20
	 */
21
	public function configMapping()
22
	{
23
		return array(
24
			\RainLoop\Plugins\Property::NewInstance('public_key')->SetLabel('Site key')
25
				->SetAllowedInJs(true)
26
				->SetDefaultValue(''),
27
			\RainLoop\Plugins\Property::NewInstance('private_key')->SetLabel('Secret key')
28
				->SetDefaultValue(''),
29
			\RainLoop\Plugins\Property::NewInstance('theme')->SetLabel('Theme')
30
				->SetAllowedInJs(true)
31
				->SetType(\RainLoop\Enumerations\PluginPropertyType::SELECTION)
32
				->SetDefaultValue(array('light', 'dark')),
33
			\RainLoop\Plugins\Property::NewInstance('error_limit')->SetLabel('Limit')
34
				->SetType(\RainLoop\Enumerations\PluginPropertyType::SELECTION)
35
				->SetDefaultValue(array(0, 1, 2, 3, 4, 5))
36
				->SetDescription('')
37
		);
38
	}
39
40
	/**
41
	 * @return string
42
	 */
43
	private function getCaptchaCacherKey()
44
	{
45
		return 'CaptchaNew/Login/'.\RainLoop\Utils::GetConnectionToken();
46
	}
47
48
	/**
49
	 * @return int
50
	 */
51 View Code Duplication
	private function getLimit()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
	{
53
		$iConfigLimit = $this->Config()->Get('plugin', 'error_limit', 0);
54
		if (0 < $iConfigLimit)
55
		{
56
			$oCacher = $this->Manager()->Actions()->Cacher();
57
			$sLimit = $oCacher && $oCacher->IsInited() ? $oCacher->Get($this->getCaptchaCacherKey()) : '0';
58
59
			if (0 < \strlen($sLimit) && \is_numeric($sLimit))
60
			{
61
				$iConfigLimit -= (int) $sLimit;
62
			}
63
		}
64
65
		return $iConfigLimit;
66
	}
67
68
	/**
69
	 * @return void
70
	 */
71 View Code Duplication
	public function FilterAppDataPluginSection($bAdmin, $bAuth, &$aData)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
	{
73
		if (!$bAdmin && !$bAuth && \is_array($aData))
74
		{
75
			$aData['show_captcha_on_login'] = 1 > $this->getLimit();
76
		}
77
	}
78
79
	/**
80
	 * @param string $sAction
81
	 */
82
	public function AjaxActionPreCall($sAction)
83
	{
84
		if ('Login' === $sAction && 0 >= $this->getLimit())
85
		{
86
			$bResult = false;
87
88
			$sResult = $this->Manager()->Actions()->Http()->SendPostRequest(
89
				'https://www.google.com/recaptcha/api/siteverify',
90
				array(
91
					'secret' => $this->Config()->Get('plugin', 'private_key', ''),
92
					'response' => $this->Manager()->Actions()->GetActionParam('RecaptchaResponse', '')
93
				)
94
			);
95
96
			if ($sResult)
97
			{
98
				$aResp = @\json_decode($sResult, true);
99
				if (\is_array($aResp) && isset($aResp['success']) && $aResp['success'])
100
				{
101
					$bResult = true;
102
				}
103
			}
104
105
			if (!$bResult)
106
			{
107
				$this->Manager()->Actions()->Logger()->Write('RecaptchaResponse:'.$sResult);
108
				throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CaptchaError);
109
			}
110
		}
111
	}
112
113
	/**
114
	 * @param string $sAction
115
	 * @param array $aResponseItem
116
	 */
117 View Code Duplication
	public function FilterAjaxResponse($sAction, &$aResponseItem)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
	{
119
		if ('Login' === $sAction && $aResponseItem && isset($aResponseItem['Result']))
0 ignored issues
show
Bug Best Practice introduced by
The expression $aResponseItem of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
120
		{
121
			$oCacher = $this->Manager()->Actions()->Cacher();
122
			$iConfigLimit = (int) $this->Config()->Get('plugin', 'error_limit', 0);
123
124
			$sKey = $this->getCaptchaCacherKey();
125
126
			if (0 < $iConfigLimit && $oCacher && $oCacher->IsInited())
127
			{
128
				if (false === $aResponseItem['Result'])
129
				{
130
					$iLimit = 0;
131
					$sLimut = $oCacher->Get($sKey);
132
					if (0 < \strlen($sLimut) && \is_numeric($sLimut))
133
					{
134
						$iLimit = (int) $sLimut;
135
					}
136
137
					$oCacher->Set($sKey, ++$iLimit);
138
139
					if ($iConfigLimit <= $iLimit)
140
					{
141
						$aResponseItem['Captcha'] = true;
142
					}
143
				}
144
				else
145
				{
146
					$oCacher->Delete($sKey);
147
				}
148
			}
149
		}
150
	}
151
}
152