Issues (4069)

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.

include/Smarty/plugins/function.math.php (5 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
 * Smarty plugin
4
 * @package Smarty
5
 * @subpackage plugins
6
 */
7
8
9
/**
10
 * Smarty {math} function plugin
11
 *
12
 * Type:     function<br>
13
 * Name:     math<br>
14
 * Purpose:  handle math computations in template<br>
15
 * @link http://smarty.php.net/manual/en/language.function.math.php {math}
16
 *          (Smarty online manual)
17
 * @author   Monte Ohrt <monte at ohrt dot com>
18
 * @param array
19
 * @param Smarty
20
 * @return string
21
 */
22 1
function smarty_function_math($params, &$smarty)
23
{
24
    // be sure equation parameter is present
25 3
    if (empty($params['equation'])) {
26
        $smarty->trigger_error("math: missing equation parameter");
27
        return;
28
    }
29
30
    // strip out backticks, not necessary for math
31 3
    $equation = str_replace('`','',$params['equation']);
32
33
    // make sure parenthesis are balanced
34 3
    if (substr_count($equation,"(") != substr_count($equation,")")) {
35
        $smarty->trigger_error("math: unbalanced parenthesis");
36
        return;
37
    }
38
39
    // match all vars in equation, make sure all are passed
40 3
    preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
41 3
    $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
42
                           'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
43
    
44 3
    foreach($match[1] as $curr_var) {
45 1
        if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
46
            $smarty->trigger_error("math: function call $curr_var not allowed");
47 1
            return;
48
        }
49
    }
50
51 3
    foreach($params as $key => $val) {
52 3
        if ($key != "equation" && $key != "format" && $key != "assign") {
53
            // make sure value is not empty
54 1
            if (strlen($val)==0) {
55
                $smarty->trigger_error("math: parameter $key is empty");
56
                return;
57
            }
58 1
            if (!is_numeric($val)) {
59
                $smarty->trigger_error("math: parameter $key: is not numeric");
60
                return;
61
            }
62 3
            $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
63
        }
64
    }
65
66 3
    eval("\$smarty_math_result = ".$equation.";");
0 ignored issues
show
The function smarty_function_math() contains an eval expression.

On one hand, eval might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM, eval prevents some optimization that they perform.

Loading history...
67
68 3
    if (empty($params['format'])) {
69 3
        if (empty($params['assign'])) {
70
            return $smarty_math_result;
0 ignored issues
show
The variable $smarty_math_result does not exist. Did you mean $smarty?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
71
        } else {
72 3
            $smarty->assign($params['assign'],$smarty_math_result);
0 ignored issues
show
The variable $smarty_math_result does not exist. Did you mean $smarty?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
73
        }
74
    } else {
75
        if (empty($params['assign'])){
76
            printf($params['format'],$smarty_math_result);
0 ignored issues
show
The variable $smarty_math_result does not exist. Did you mean $smarty?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
77
        } else {
78
            $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
0 ignored issues
show
The variable $smarty_math_result does not exist. Did you mean $smarty?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
79
        }
80
    }
81 3
}
82
83
/* vim: set expandtab: */
84
85
?>