Issues (632)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

Apps/Controller/Api/Main.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Apps\Controller\Api;
4
5
use Apps\Model\Basic\Antivirus;
6
use elFinder;
7
use elFinderConnector;
8
use Extend\Core\Arch\ApiController;
9
use Ffcms\Core\App;
10
use Ffcms\Core\Exception\ForbiddenException;
11
use Ffcms\Core\Helper\FileSystem\File;
12
use Ffcms\Core\Helper\Type\Str;
13
14
/**
15
 * Class Main. Basic api features for ffcms
16
 * @package Apps\Controller\Api
17
 */
18
class Main extends ApiController
19
{
20
    /**
21
     * Test action
22
     * @return string
23
     */
24
    public function actionIndex(): ?string
25
    {
26
        $this->setJsonHeader();
27
        return json_encode(['status' => 1, 'value' => 'Welcome, man!']);
28
    }
29
30
    /**
31
     * Elfinder injector file listing
32
     * @throws ForbiddenException
33
     */
34
    public function actionFiles()
35
    {
36
        $user = App::$User->identity();
37
38
        if (!$user || !$user->role->can('admin/main/files')) {
39
            throw new ForbiddenException('This action is not allowed!');
40
        }
41
42
        $this->setJsonHeader();
43
        $connector = new elFinderConnector(new elFinder([
44
            'locale' => '',
45
            'roots' => [
46
                [
47
                    'driver' => 'LocalFileSystem',
48
                    'path' => root . '/upload/',
49
                    'URL' => App::$Alias->scriptUrl . '/upload/'
50
                ]
51
            ]
52
        ]));
53
54
        $connector->run();
55
    }
56
57
    /**
58
     * Make scan and display scan iteration data
59
     * @return string|null
60
     * @throws ForbiddenException
61
     * @throws \Ffcms\Core\Exception\NativeException
62
     * @throws \Ffcms\Core\Exception\SyntaxException
63
     */
64
    public function actionAntivirus(): ?string
65
    {
66
        $user = App::$User->identity();
67
        if (!$user || !$user->role->can('admin/main/antivirus')) {
68
            throw new ForbiddenException('This action is not allowed!');
69
        }
70
71
        $scanner = new Antivirus();
72
73
        $this->setJsonHeader();
74
        return json_encode($scanner->make());
75
    }
76
77
    /**
78
     * Remove previous scan files
79
     * @return string
80
     * @throws ForbiddenException
81
     */
82
    public function actionAntivirusclear(): string
83
    {
84
        $user = App::$User->identity();
85
        if (!$user || !$user->role->can('admin/main/antivirus')) {
86
            throw new ForbiddenException('This action is not allowed!');
87
        }
88
89
        File::remove('/Private/Antivirus/Infected.json');
90
        File::remove('/Private/Antivirus/ScanFiles.json');
91
92
        $this->setJsonHeader();
93
        return json_encode(['status' => 1]);
94
    }
95
96
    /**
97
     * Show scan results
98
     * @return string
99
     * @throws ForbiddenException
100
     */
101
    public function actionAntivirusresults(): string
102
    {
103
        $user = App::$User->identity();
104
        if (!$user || !$user->role->can('admin/main/antivirus')) {
105
            throw new ForbiddenException('This action is not allowed!');
106
        }
107
108
        $response = null;
109
        if (!File::exist('/Private/Antivirus/Infected.json')) {
110
            $response = ['status' => 0];
111
        } else {
112
            $data = json_decode(File::read('/Private/Antivirus/Infected.json'));
0 ignored issues
show
It seems like Ffcms\Core\Helper\FileSy...tivirus/Infected.json') can also be of type false; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

112
            $data = json_decode(/** @scrutinizer ignore-type */ File::read('/Private/Antivirus/Infected.json'));
Loading history...
113
            $compile = [];
114
            foreach ($data as $file => $sign) {
115
                $file = Str::replace('\\', '/', Str::sub($file, strlen(root)));
116
                $compile[$file][] = $sign;
117
            }
118
119
            $response = ['status' => 1, 'data' => $compile];
120
        }
121
122
        $this->setJsonHeader();
123
        return json_encode($response);
124
    }
125
126
    /**
127
     * Download news from ffcms.org server and show it with caching & saving
128
     * @return string|null
129
     * @throws \Psr\Cache\InvalidArgumentException
130
     */
131
    public function actionNews(): ?string
132
    {
133
        $this->setJsonHeader();
134
        // get ffcms news if cache is not available
135
        $cache = App::$Cache->getItem('download.ffcms.api.news.' . $this->lang);
136
        if (!$cache->isHit()) {
137
            $cache->set(File::getFromUrl('https://ffcms.org/api/api/news?lang=' . $this->lang))
138
                ->expiresAfter(1440);
139
        }
140
        return $cache->get();
141
    }
142
}
143