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/api.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
/**
5
 * Helper class for our API
6
 **/
7
class Api extends Base {
8
  private $api_version = '1.0.0';
9
10
  function setStartTime($dStartTime) {
11
    $this->dStartTime = $dStartTime;
0 ignored issues
show
The property dStartTime 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...
12
  }
13
  function isActive($error=true) {
14
    if (!$this->setting->getValue('disable_api')) {
0 ignored issues
show
The property setting 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...
15
      return true;
16
    } else {
17
      if ($error == true) {
18
        unset($_SESSION['POPUP']);
19
        header('HTTP/1.1 501 Not implemented');
20
        die('501 Not implemented');
21
      }
22
    }
23
  }
24
25
  /**
26
   * Create API json object from input array
27
   * @param data Array data to create JSON for
28
   * @param force bool Enforce a JSON object
29
   * @return string JSON object
30
   **/
31
  function get_json($data, $force=false) {
32
    $json = json_encode(
33
      array( $_REQUEST['action'] => array(
34
        'version' => $this->api_version,
35
        'runtime' => (microtime(true) - $this->dStartTime) * 1000,
36
        'data' => $data
37
      )), $force ? JSON_FORCE_OBJECT : 0
38
    );
39
    // JSONP support issue #1700
40
    if (isset($_REQUEST['callback']) && ctype_alpha($_REQUEST['callback'])) {
41
      header('Content-type: application/json; charset=utf-8');
42
      return $_REQUEST['callback'] . '(' . $json . ');';
43
    }
44
    return $json;
45
  }
46
47
  /**
48
   * Check user access level to the API call
49
   **/
50
  function checkAccess($user_id, $get_id=NULL) {
51
    if (!empty($get_id) && is_array($get_id)) die("Access denied");
52
    if (is_array($user_id)) die("Access denied");
53
    if ( ! $this->user->isAdmin($user_id) && (!empty($get_id) && $get_id != $user_id || !is_int($user_id))) {
54
      // User is NOT admin and tries to access an ID that is not their own
55
      header("HTTP/1.1 401 Unauthorized");
56
      die("Access denied");
57
    } else if ($this->user->isAdmin($user_id) && !empty($get_id)) {
58
      // User is an admin and tries to fetch another users data
59
      $id = $get_id;
60
      // Is it a username or a user ID
61
      ctype_digit($_REQUEST['id']) ? $id = $get_id : $id = $this->user->getUserId($get_id);
62
    } else {
63
      $id = $user_id;
64
    }
65
    return $id;
66
  }
67
}
68
69
$api = new Api();
70
$api->setConfig($config);
71
$api->setUser($user);
72
$api->setSetting($setting);
73
$api->setStartTime($dStartTime=microtime(true));
74