Issues (102)

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/Controller/Base.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
/*
4
    HCSF - A multilingual CMS and Shopsystem
5
    Copyright (C) 2014  Marcus Haase - [email protected]
6
7
    This program is free software: you can redistribute it and/or modify
8
    it under the terms of the GNU General Public License as published by
9
    the Free Software Foundation, either version 3 of the License, or
10
    (at your option) any later version.
11
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16
17
    You should have received a copy of the GNU General Public License
18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
namespace HaaseIT\HCSF\Controller;
22
23
24
use Zend\ServiceManager\ServiceManager;
25
26
class Base
27
{
28
    /**
29
     * @var \HaaseIT\HCSF\Page
30
     */
31
    protected $P;
32
33
    /**
34
     * @var ServiceManager
35
     */
36
    protected $serviceManager;
37
38
    /**
39
     * @var bool
40
     */
41
    protected $requireAdminAuth = false;
42
43
    /**
44
     * @var bool
45
     */
46
    protected $requireAdminAuthAdminHome = false;
47
48
    /**
49
     * @var bool
50
     */
51
    protected $requireModuleCustomer = false;
52
53
    /**
54
     * @var bool
55
     */
56
    protected $requireModuleShop = false;
57
58
    /**
59
     * @var \HaaseIT\HCSF\HelperConfig
60
     */
61
    protected $config;
62
63
    /**
64
     * @var \HaaseIT\HCSF\Helper
65
     */
66
    protected $helper;
67
68
    /**
69
     * Base constructor.
70
     * @param ServiceManager $serviceManager
71
     */
72
    public function __construct(ServiceManager $serviceManager)
73
    {
74
        $this->serviceManager = $serviceManager;
75
        $this->config = $serviceManager->get('config');
76
        $this->helper = $serviceManager->get('helper');
77
    }
78
79
    /**
80
     * @return \HaaseIT\HCSF\Page
81
     * @throws \Exception
82
     */
83
    public function getPage()
84
    {
85
        if ($this->requireAdminAuth) {
86
            $this->requireAdminAuth();
87
        }
88
        if ($this->requireModuleCustomer && !$this->config->getCore('enable_module_customer')) {
89
            throw new \Exception(404);
90
        }
91
        if ($this->requireModuleShop && !$this->config->getCore('enable_module_shop')) {
92
            throw new \Exception(404);
93
        }
94
        $this->preparePage();
95
        return $this->P;
96
    }
97
98
    public function preparePage()
99
    {
100
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    private function requireAdminAuth() {
107
108
        $adminusers = $this->config->getSecret('admin_users');
109
        if ($this->requireAdminAuthAdminHome && (empty($adminusers) || !count($adminusers))) {
110
            return true;
111
        } elseif (count($adminusers)) {
112
            $user = filter_var($_SERVER['PHP_AUTH_USER'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
113
            $pass = filter_var($_SERVER['PHP_AUTH_PW'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
114
115
            if (!empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) { // fix for php cgi mode
116
                //die($_SERVER['REDIRECT_HTTP_AUTHORIZATION']);
117
                list($user, $pass) = explode(':' , base64_decode(substr(filter_var($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], FILTER_SANITIZE_STRING), 6)));
118
            }
119
120
            if (!empty($user) && !empty($pass)) {
121
                $validated = !empty(
122
                    $adminusers[$user])
123
                    && password_verify($pass, $adminusers[$user]
124
                    );
125
            } else {
126
                $validated = false;
127
            }
128
129 View Code Duplication
            if (!$validated) {
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...
130
                header('WWW-Authenticate: Basic realm="'.$this->config->getSecret('admin_authrealm').'"');
131
                header('HTTP/1.0 401 Unauthorized');
132
                $this->helper->terminateScript('Not authorized');
133
            }
134
135 View Code Duplication
        } else {
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...
136
//            die('foo');
137
            header('WWW-Authenticate: Basic realm="'.$this->config->getSecret('admin_authrealm').'"');
138
            header('HTTP/1.0 401 Unauthorized');
139
            $this->helper->terminateScript('Not authorized');
140
        }
141
    }
142
}
143