Issues (1210)

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.

thumbs/phpthumb.ico.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
//   phpThumb() by James Heinrich <[email protected]>   //
4
//        available at http://phpthumb.sourceforge.net      //
5
//         and/or https://github.com/JamesHeinrich/phpThumb //
6
//////////////////////////////////////////////////////////////
7
///                                                         //
8
// phpthumb.ico.php - .ICO output format functions          //
9
//                                                         ///
10
//////////////////////////////////////////////////////////////
11
12
/**
13
 * Class phpthumb_ico
14
 */
15
class phpthumb_ico
16
{
17
18
    // removed for XOOPS
19
    //function phpthumb_ico() {
20
    //  return true;
21
    //}
22
23
    /**
24
     * @param $gd_image_array
25
     * @return string
26
     */
27
    public function GD2ICOstring(&$gd_image_array)
28
    {
29
        foreach ($gd_image_array as $key => $gd_image) {
30
            $ImageWidths[$key]  = imagesx($gd_image);
31
            $ImageHeights[$key] = imagesy($gd_image);
32
            $bpp[$key]          = imageistruecolor($gd_image) ? 32 : 24;
33
            $totalcolors[$key]  = imagecolorstotal($gd_image);
34
35
            $icXOR[$key] = '';
36
            for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
37
                for ($x = 0; $x < $ImageWidths[$key]; $x++) {
38
                    $argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
39
                    $a    = round(255 * ((127 - $argb['alpha']) / 127));
40
                    $r    = $argb['red'];
41
                    $g    = $argb['green'];
42
                    $b    = $argb['blue'];
43
44
                    if ($bpp[$key] == 32) {
45
                        $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
46
                    } elseif ($bpp[$key] == 24) {
47
                        $icXOR[$key] .= chr($b) . chr($g) . chr($r);
48
                    }
49
50
                    if ($a < 128) {
51
                        @$icANDmask[$key][$y] .= '1';
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
52
                    } else {
53
                        @$icANDmask[$key][$y] .= '0';
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
54
                    }
55
                }
56
                // mask bits are 32-bit aligned per scanline
57
                while (strlen($icANDmask[$key][$y]) % 32) {
58
                    $icANDmask[$key][$y] .= '0';
59
                }
60
            }
61
            $icAND[$key] = '';
62
            foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
63
                for ($i = 0, $iMax = strlen($scanlinemaskbits); $i < $iMax; $i += 8) {
64
                    $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
65
                }
66
            }
67
        }
68
69
        foreach ($gd_image_array as $key => $gd_image) {
70
            $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
71
72
            // BITMAPINFOHEADER - 40 bytes
73
            $BitmapInfoHeader[$key] = '';
74
            $BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                              // DWORD  biSize;
75
            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);      // LONG   biWidth;
76
            // The biHeight member specifies the combined
77
            // height of the XOR and AND masks.
78
            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
79
            $BitmapInfoHeader[$key] .= "\x01\x00";                                      // WORD   biPlanes;
80
            $BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";                          // wBitCount;
81
            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biCompression;
82
            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);            // DWORD  biSizeImage;
83
            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // LONG   biXPelsPerMeter;
84
            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // LONG   biYPelsPerMeter;
85
            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biClrUsed;
86
            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                              // DWORD  biClrImportant;
87
        }
88
89
        $icondata = "\x00\x00";                                      // idReserved;   // Reserved (must be 0)
90
        $icondata .= "\x01\x00";                                      // idType;       // Resource Type (1 for icons)
91
        $icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;      // How many images?
92
93
        $dwImageOffset = 6 + (count($gd_image_array) * 16);
94
        foreach ($gd_image_array as $key => $gd_image) {
95
            // ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
96
97
            $icondata .= chr($ImageWidths[$key]);                     // bWidth;          // Width, in pixels, of the image
98
            $icondata .= chr($ImageHeights[$key]);                    // bHeight;         // Height, in pixels, of the image
99
            $icondata .= chr($totalcolors[$key]);                     // bColorCount;     // Number of colors in image (0 if >=8bpp)
100
            $icondata .= "\x00";                                      // bReserved;       // Reserved ( must be 0)
101
102
            $icondata .= "\x01\x00";                                  // wPlanes;         // Color Planes
103
            $icondata .= chr($bpp[$key]) . "\x00";                      // wBitCount;       // Bits per pixel
104
105
            $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
106
            $icondata     .= phpthumb_functions::LittleEndian2String($dwBytesInRes, 4);       // dwBytesInRes;    // How many bytes in this resource?
107
108
            $icondata      .= phpthumb_functions::LittleEndian2String($dwImageOffset, 4);      // dwImageOffset;   // Where in the file is this image?
109
            $dwImageOffset += strlen($BitmapInfoHeader[$key]);
110
            $dwImageOffset += strlen($icXOR[$key]);
111
            $dwImageOffset += strlen($icAND[$key]);
112
        }
113
114
        foreach ($gd_image_array as $key => $gd_image) {
115
            $icondata .= $BitmapInfoHeader[$key];
116
            $icondata .= $icXOR[$key];
117
            $icondata .= $icAND[$key];
118
        }
119
120
        return $icondata;
121
    }
122
}
123