Issues (431)

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.

include/classes/csrftoken.class.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
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
3
4
class CSRFToken Extends Base {
5
  public $valid = 0;
6
  /**
7
   * Gets a basic csrf token
8
   * @param string $user user or IP/host address
9
   * @param string $type page name or other unique per-page identifier
10
   */
11
  public function getBasic($user, $type) {
12
    $date = date('m/d/y/H/i');
13
    $d = explode('/', $date);
14
    $seed = $this->buildSeed($user.$type, $d[0], $d[1], $d[2], $d[3], $d[4]);
15
    return $this->getHash($seed);
16
  }
17
  
18
  /**
19
   * Returns +1 min up to +15 min rollovers hashes
20
   * @param string $user user or IP/host address
21
   * @param string $type page name or other unique per-page identifier
22
   * @return array 1 minute ago up to 15 minute ago hashes
23
   */
24
  
25
  public function checkAdditional($user, $type) {
26
    $date = date('m/d/y/H/i');
27
    $d = explode('/', $date);
28
    $hashes = array();
29
    for ($x = 1; $x < 16; $x++){
30
        for ($y = 4;$d[$y]-- == 0;$y--);
31
        if ($d[4] < 0) { $d[4] = 59; }
32
        $hashes[$x-1] = $this->getHash($this->buildSeed($user.$type, $d[0], $d[1], $d[2], $d[3], $d[4]));
33
    }
34
    return $hashes;
35
  }
36
  
37
  /**
38
   * Builds a seed with the given data
39
   * @param string $data
40
   * @param int $year
41
   * @param int $month
42
   * @param int $day
43
   * @param int $hour
44
   * @param int $minute
45
   * @return string seed
46
   */
47
  private function buildSeed($data, $year, $month, $day, $hour, $minute) {
48
    return $this->salty.$year.$month.$day.$data.$hour.$minute.$this->salt;
0 ignored issues
show
The property salty does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
The property salt does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
49
  }
50
  
51
  /**
52
   * Checks if the token is correct as is, if not checks for rollovers with checkAdditional()
53
   * @param string $user user or IP/host address
54
   * @param string $type page name or other unique per-page identifier
55
   * @param string $token token to check against
56
   * @return boolean
57
   */
58
  public function checkBasic($user, $type, $token) {
59
    if (empty($token)) return false;
60
    $token_now = $this->getBasic($user, $type);
61
    if ($token_now !== $token) {
62
      $tokens_check = $this->checkAdditional($user, $type);
63
      $match = 0;
64
      foreach ($tokens_check as $checkit) {
65
        if ($checkit == $token) $match = 1;
66
      }
67
      return ($match) ? true : false;
68
    } else {
69
      return true;
70
    }
71
  }
72
  
73
  /**
74
   * Convenience method to get a token expired message with a token type, and ? image with description
75
   * @param string $tokentype if you want a specific tokentype, set it here
76
   * @param string $dowhat What will be put in the string "Simply $dowhat again to...", default is try
77
   */
78
  public static function getErrorWithDescriptionHTML($tokentype="", $dowhat="try") {
79
    return ($tokentype !== "") ? "$tokentype token expired, please try again ".self::getDescriptionImageHTML($dowhat) : "Token expired, please try again ".self::getDescriptionImageHTML($dowhat);
80
  }
81
  
82
  /**
83
   * Gets the HTML image (?) with short csrf description for users for the incorrect token error message
84
   * @param dowhat string What will be put in the string "Simply $dowhat again to...", default is try
85
   * @return string HTML image with description
86
   */
87
  public static function getDescriptionImageHTML($dowhat="try") {
88
    $string = "<img src='site_assets/bootstrap/images/questionmark.png' ";
89
    $string.= "title='Tokens are used to help us mitigate attacks; Simply ";
90
    $string.= htmlentities(strip_tags($dowhat));
91
    $string.= " again to continue' width='20px' height='20px'>";
92
    return $string;
93
  }
94
  
95
  private function getHash($string) {
96
    return hash('sha256', $this->salty.$string.$this->salt);
97
  }
98
}
99
100
$csrftoken = new CSRFToken();
101
$csrftoken->setDebug($debug);
102
$csrftoken->setMysql($mysqli);
103
$csrftoken->setSalt($config['SALT']);
104
$csrftoken->setSalty($config['SALTY']);
105
$csrftoken->setMail($mail);
106
$csrftoken->setUser($user);
107
$csrftoken->setToken($oToken);
108
$csrftoken->setConfig($config);
109
$csrftoken->setErrorCodes($aErrorCodes);
110