Issues (183)

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.

src/bb-library/Box/Update.php (1 issue)

Severity

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
 * BoxBilling
4
 *
5
 * @copyright BoxBilling, Inc (http://www.boxbilling.com)
6
 * @license   Apache-2.0
7
 *
8
 * Copyright BoxBilling, Inc
9
 * This source file is subject to the Apache-2.0 License that is bundled
10
 * with this source code in the file LICENSE
11
 */
12
13
class Box_Update
14
{
15
    /**
16
     * @var \Box_Di
17
     */
18
    protected $di = null;
19
20
    /**
21
     * @param \Box_Di $di
22
     */
23 1
    public function setDi($di)
24
    {
25 1
        $this->di = $di;
26 1
    }
27
28
    /**
29
     * @return \Box_Di
30
     */
31
    public function getDi()
32
    {
33
        return $this->di;
34
    }
35
36
    private $_url = 'http://api.boxbilling.com/compare-version.php';
37
38 4
    public function __construct()
39
    {
40 4
        if(defined('BB_VERSION_URL') && BB_VERSION_URL) {
41
            $this->_url = BB_VERSION_URL;
42
        }
43 4
    }
44
45
    /**
46
     * Returns latest information
47
     */
48
    private function _getLatestVersionInfo()
49
    {
50
        return $this->di['tools']->cache_function(array($this, 'getJson'), array(), 86400);
51
    }
52
53
    /**
54
     * Return latest version number
55
     * @return string
56
     */
57
    public function getLatestVersion()
58
    {
59
        $response = $this->_getLatestVersionInfo();
60
        if(!is_object($response)) {
61
            return Box_Version::VERSION;
62
        }
63
        return $response->version;
64
    }
65
66
    /**
67
     * Latest version link
68
     * @return string
69
     */
70
    public function getLatestVersionDownloadLink()
71
    {
72
        $response = $this->_getLatestVersionInfo();
73
        if(isset($response->update)) {
74
            return $response->update;
75
        }
76
        return $response->link;
77
    }
78
79
    /**
80
     * Check if we need to update current BoxBilling version
81
     * @return bool
82
     */
83
    public function getCanUpdate()
84
    {
85
        $version = $this->getLatestVersion();
86
        $result = Box_Version::compareVersion($version);
87
        return ($result > 0);
88
    }
89
90
    /**
91
     * Check if given file is same as original
92
     * @param string $file - filepath
93
     * @return bool
94
     */
95
    private function isHashValid($file)
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
96
    {
97
        if(!file_exists($file)) {
98
            return false;
99
        }
100
        
101
        $response = $this->_getLatestVersionInfo();
102
        $hash = md5($response->version.filesize($file));
103
        return ($hash == $response->hash);
104
    }
105
106
    public function getJson()
107
    {
108
        $url = $this->_url . '?current=' . Box_Version::VERSION;
109
        $curl = new Box_Curl($url);
110
        $curl->request();
111
        $response = $curl->getBody();
112
        return json_decode($response);
113
    }
114
115
    /**
116
     * Perform update
117
     *
118
     * @throws Exception
119
     */
120
    public function performUpdate()
121
    {
122
        if(!$this->getCanUpdate()) {
123
            throw new LogicException('You have latest version of BoxBilling. You do not need to update.');
124
        }
125
126
        error_log('Started BoxBilling auto-update script');
127
        $latest_version = $this->getLatestVersion();
128
        $latest_version_archive = BB_PATH_CACHE.DIRECTORY_SEPARATOR.$latest_version.'.zip';
129
130
        // download latest archive from link
131
        $content = $this->di['tools']->file_get_contents($this->getLatestVersionDownloadLink());
132
        $f = fopen($latest_version_archive,'wb');
133
        fwrite($f,$content,strlen($content));
134
        fclose($f);
135
136
        //@todo validate downloaded file hash
137
138
        // Extract latest archive on top of current version
139
        $ff = new Box_Zip($latest_version_archive);
140
        $ff->decompress(BB_PATH_ROOT);
141
142
        if(file_exists(BB_PATH_ROOT.'/bb-update.php')) {
143
            error_log('Calling bb-update.php script from auto-updater');
144
            $this->di['tools']->file_get_contents(BB_URL.'bb-update.php');
145
        }
146
        
147
        // clean up things
148
        $this->di['tools']->emptyFolder(BB_PATH_CACHE);
149
        $this->di['tools']->emptyFolder(BB_PATH_ROOT.'/install');
150
        rmdir(BB_PATH_ROOT.'/install');
151
        return true;
152
    }
153
}