Issues (847)

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.

lib/exe/mediamanager.php (6 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
use dokuwiki\Extension\Event;
4
5
    if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
6
    define('DOKU_MEDIAMANAGER',1);
7
8
    // for multi uploader:
9
    @ini_set('session.use_only_cookies',0);
10
11
    require_once(DOKU_INC.'inc/init.php');
12
13
    global $INPUT;
14
    global $lang;
15
    global $conf;
16
    // handle passed message
17
    if($INPUT->str('msg1')) msg(hsc($INPUT->str('msg1')),1);
18
    if($INPUT->str('err')) msg(hsc($INPUT->str('err')),-1);
19
20
    global $DEL;
21
    // get namespace to display (either direct or from deletion order)
22
    if($INPUT->str('delete')){
23
        $DEL = cleanID($INPUT->str('delete'));
24
        $IMG = $DEL;
25
        $NS  = getNS($DEL);
26
    }elseif($INPUT->str('edit')){
27
        $IMG = cleanID($INPUT->str('edit'));
28
        $NS  = getNS($IMG);
29
    }elseif($INPUT->str('img')){
30
        $IMG = cleanID($INPUT->str('img'));
31
        $NS  = getNS($IMG);
32
    }else{
33
        $NS = cleanID($INPUT->str('ns'));
34
        $IMG = null;
35
    }
36
37
    global $INFO, $JSINFO;
38
    $INFO = !empty($INFO) ? array_merge($INFO, mediainfo()) : mediainfo();
39
    $JSINFO['id']        = '';
40
    $JSINFO['namespace'] = '';
41
    $AUTH = $INFO['perm'];    // shortcut for historical reasons
42
43
    $tmp = array();
44
    Event::createAndTrigger('MEDIAMANAGER_STARTED', $tmp);
45
    session_write_close();  //close session
46
47
    // do not display the manager if user does not have read access
48
    if($AUTH < AUTH_READ && !$fullscreen) {
49
        http_status(403);
50
        die($lang['accessdenied']);
51
    }
52
53
    // handle flash upload
54
    if(isset($_FILES['Filedata'])){
55
        $_FILES['upload'] =& $_FILES['Filedata'];
56
        $JUMPTO = media_upload($NS,$AUTH);
0 ignored issues
show
It seems like $NS can also be of type false; however, media_upload() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
57
        if($JUMPTO == false){
0 ignored issues
show
It seems like you are loosely comparing $JUMPTO of type false|string against false; this is ambiguous if the string can be empty. Consider using a strict comparison === instead.
Loading history...
58
            http_status(400);
59
            echo 'Upload failed';
60
        }
61
        echo 'ok';
62
        exit;
63
    }
64
65
    // give info on PHP caught upload errors
66
    if(!empty($_FILES['upload']['error'])){
67
        switch($_FILES['upload']['error']){
68
            case 1:
69
            case 2:
70
                msg(sprintf($lang['uploadsize'],
71
                    filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1);
72
                break;
73
            default:
74
                msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1);
75
        }
76
        unset($_FILES['upload']);
77
    }
78
79
    // handle upload
80
    if(!empty($_FILES['upload']['tmp_name'])){
81
        $JUMPTO = media_upload($NS,$AUTH);
0 ignored issues
show
It seems like $NS can also be of type false; however, media_upload() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
82
        if($JUMPTO) $NS = getNS($JUMPTO);
0 ignored issues
show
Bug Best Practice introduced by
The expression $JUMPTO of type false|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
83
    }
84
85
    // handle meta saving
86
    if($IMG && @array_key_exists('save', $INPUT->arr('do'))){
0 ignored issues
show
Bug Best Practice introduced by
The expression $IMG of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
87
        $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta'));
88
    }
89
90
    if($IMG && ($INPUT->str('mediado') == 'save' || @array_key_exists('save', $INPUT->arr('mediado')))) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $IMG of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
91
        $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta'));
92
    }
93
94
    if ($INPUT->int('rev') && $conf['mediarevisions']) $REV = $INPUT->int('rev');
95
96
    if($INPUT->str('mediado') == 'restore' && $conf['mediarevisions']){
97
        $JUMPTO = media_restore($INPUT->str('image'), $REV, $AUTH);
98
    }
99
100
    // handle deletion
101
    if($DEL) {
102
        $res = 0;
103
        if(checkSecurityToken()) {
104
            $res = media_delete($DEL,$AUTH);
105
        }
106
        if ($res & DOKU_MEDIA_DELETED) {
107
            $msg = sprintf($lang['deletesucc'], noNS($DEL));
108
            if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) {
109
                // current namespace was removed. redirecting to root ns passing msg along
110
                send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='.
111
                        rawurlencode($msg).'&edid='.$INPUT->str('edid'));
112
            }
113
            msg($msg,1);
114
        } elseif ($res & DOKU_MEDIA_INUSE) {
115
            if(!$conf['refshow']) {
116
                msg(sprintf($lang['mediainuse'],noNS($DEL)),0);
117
            }
118
        } else {
119
            msg(sprintf($lang['deletefail'],noNS($DEL)),-1);
120
        }
121
    }
122
    // finished - start output
123
124
    if (!$fullscreen) {
125
        header('Content-Type: text/html; charset=utf-8');
126
        include(template('mediamanager.php'));
127
    }
128
129
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
130