Issues (1191)

Security Analysis    not enabled

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.

vote-ajax.php (2 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
include 'php/jodel-web.php';
4
5
if(isset($_GET['postId']) && $_GET['vote'])
6
{
7
	header('Content-Type: application/json');
8
	$voteResult = $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']);
9
    echo json_encode($voteResult);
10
    die();
11
}
12
13 View Code Duplication
if(isset($_GET['solution']) && isset($_POST['deviceUid']))
0 ignored issues
show
This code seems to be duplicated across 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...
14
{
15
	$jodelAccount = new JodelAccount($_POST['deviceUid']);
16
	$response = array("success" => $jodelAccount->verifyCaptcha());
17
	echo json_encode($response);
18
	die();
19
}
20
$userIsAdmin = isUserAdmin();
21
if(!$userIsAdmin)
22
{
23
	$userIsVoter = isUserVoter();
24
}
25
else
26
{
27
	$userIsVoter = false;
28
}
29
30
if(!$userIsVoter && !$userIsAdmin)
31
{
32
	error_log($_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php');
33
	$response = array("message" => $_SERVER['REMOTE_ADDR']  . ' used a wrong password on vote-ajax.php',"success" => false);
34
	echo json_encode($response);
35
	die();
36
}
37
else
38
{
39
	if($userIsVoter)
40
	{
41
		$result = $db->query("SELECT user_token, remaining_votes FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'");
42
		if($result->num_rows > 0)
43
		{
44
			$row = $result->fetch_assoc();
45
			$remaining_votes = $row['remaining_votes'];
46
		}
47
		if($remaining_votes <= 0)
48
		{
49
			$message = 'This voter account run out of votes. For more information please contact [email protected]';
50
			$success = false;
51
52
			$response = array("success" => $success, "message" => $message);
53
			echo json_encode($response);
54
			die();
55
		}
56
	}
57
		
58
59
	$message = "";
60
	$success = true;
61
	$token = "";
62
		if(isset($_POST['vote']) && isset($_POST['postId']))
63
		{
64
			$i = 0;
65
			$result = $db->query("SELECT access_token, device_uid FROM accounts WHERE device_uid NOT IN (SELECT device_uid FROM votes WHERE postId = '" . $_POST['postId'] . "')");
66
67
			if($result->num_rows > 0)
68
			{
69
				$row = $result->fetch_assoc();
70
				$accessToken = $row['access_token'];
71
				$deviceUid = $row['device_uid'];
72
				
73
				$jodelAccount = new JodelAccount($deviceUid);
74
75
				if(!$jodelAccount->isAccountVerified())
76
				{
77
					$message = "This account is not verified. Please verify this account first.";
78
					$captcha = $jodelAccount->getCaptcha();	
79
80
					$_GET['key'] = $captcha["key"];
81
					$_GET['deviceUid'] = $deviceUid;
82
83
					$success = false;
84
				}
85
				else
86
				{
87
					if($userIsVoter)
88
					{
89
						$remaining_votes = $remaining_votes - 1;
90
						$result = $db->query("UPDATE users 
91
	                                SET remaining_votes='" . $remaining_votes . "'
92
	                                WHERE user_token='" . $_COOKIE['JodelVoterPassword'] . "'");
93 View Code Duplication
						if($result === false)
0 ignored issues
show
This code seems to be duplicated across 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...
94
						{
95
	               			error_log("Update remaining votes failed: (" . $db->errno . ") " . $db->error);
96
	               		}
97
               			$db->close();
98
               		}
99
					$jodelAccount->votePostId($_POST['postId'], $_POST['vote']);
100
					//Feedback
101
				}
102
			}
103
			else
104
			{
105
				$message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.';
106
				$success = false;
107
			}
108
		}
109
110
	if(isset($captcha))
111
	{
112
		$response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid);
113
	}
114
	else
115
	{
116
		$response = array("success" => $success, "message" => $message);
117
	}
118
}
119
echo json_encode($response);
120
?>