Issues (431)

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/classes/mail.class.php (1 issue)

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
(!cfip()) ? header('HTTP/1.1 401 Unauthorized') : 0;
3
4
class Mail extends Base {
5
  /**
6
  * Mail form contact site admin
7
  * @param senderName string senderName
8
  * @param senderEmail string senderEmail
9
  * @param senderSubject string senderSubject
10
  * @param senderMessage string senderMessage
11
  * @param email string config Email address
12
  * @param subject string header subject
13
  * @return bool
14
  **/
15
  public function contactform($senderName, $senderEmail, $senderSubject, $senderMessage) {
16
    $this->debug->append("STA " . __METHOD__, 4);
17 View Code Duplication
    if (empty($senderEmail) || !filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) {
18
      $this->setErrorMessage($this->getErrorMsg('E0023'));
19
      return false;
20
    }
21
    if (strlen(strip_tags($senderMessage)) < strlen($senderMessage)) {
22
      $this->setErrorMessage($this->getErrorMsg('E0024'));
23
      return false;
24
    }
25
    $aData['senderName'] = $senderName;
26
    $aData['senderEmail'] = $senderEmail;
27
    $aData['senderSubject'] = $senderSubject;
28
    $aData['senderMessage'] = $senderMessage;
29
    $aData['email'] = $this->setting->getValue('website_email', '[email protected]');
30
    $aData['subject'] = 'Contact Form';
31
      if ($this->sendMail('contactform/body', $aData)) {
32
        return true;
33
     } else {
34
       $this->setErrorMessage( 'Unable to send email' );
35
       return false;
36
     }
37
    return false;
38
  }
39
40
  /**
41
   * Send a mail with templating via Smarty and Siftmailer
42
   * @param template string Template name within the mail folder, no extension
43
   * @param aData array Data array with some required fields
44
   *     subject : Mail Subject
45
   *     email   : Destination address
46
   **/
47
  public function sendMail($template, $aData, $throttle=false) {
48
    // Prepare SMTP transport and mailer
49
    $transport_type = $this->config['swiftmailer']['type'];
0 ignored issues
show
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
50
    if ($transport_type == 'sendmail') {
51
      $transport = Swift_SendmailTransport::newInstance($this->config['swiftmailer'][$transport_type]['path'] . ' ' . $this->config['swiftmailer'][$transport_type]['options']);
52
    } else if ($this->config['swiftmailer']['type'] == 'smtp') {
53
      $transport = Swift_SmtpTransport::newInstance($this->config['swiftmailer']['smtp']['host'], $this->config['swiftmailer']['smtp']['port'], $this->config['swiftmailer']['smtp']['encryption']);
54
      if (!empty($this->config['swiftmailer']['smtp']['username']) && !empty($this->config['swiftmailer']['smtp']['password'])) {
55
        $transport->setUsername($this->config['swiftmailer']['smtp']['username']);
56
        $transport->setPassword($this->config['swiftmailer']['smtp']['password']);
57
      }
58
    }
59
    $mailer = Swift_Mailer::newInstance($transport);
60
61
    // Throttle mails to x per minute, used for newsletter for example
62
    if ($this->config['swiftmailer']['type'] == 'smtp' && $throttle) {
63
      $mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
64
        $this->config['swiftmailer']['smtp']['throttle'], Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
65
      ));
66
    }
67
68
    // Prepare the smarty templates used
69
    $this->smarty->clearCache(TEMPLATE_DIR . '/mail/' . $template . '.tpl');
70
    $this->smarty->clearCache(TEMPLATE_DIR . '/mail/subject.tpl');
71
    $this->smarty->assign('WEBSITENAME', $this->setting->getValue('website_name'));
72
    $this->smarty->assign('SUBJECT', $aData['subject']);
73
    $this->smarty->assign('DATA', $aData);
74
75
    // Create new message for Swiftmailer
76
    $senderEmail = $this->setting->getValue('website_email', '[email protected]');
77
    $senderName = $this->setting->getValue('website_name', '[email protected]');
78
    $message = Swift_Message::newInstance()
79
      ->setSubject($this->smarty->fetch(TEMPLATE_DIR . '/mail/subject.tpl'))
80
      ->setFrom(array( $senderEmail => $senderName))
81
      ->setTo($aData['email'])
82
      ->setSender($senderEmail)
83
      ->setReturnPath($senderEmail)
84
      ->setBody($this->smarty->fetch(TEMPLATE_DIR . '/mail/' . $template . '.tpl'), 'text/html');
85
    if (isset($aData['senderName']) &&
86
        isset($aData['senderEmail']) &&
87
        strlen($aData['senderName']) > 0 &&
88
        strlen($aData['senderEmail']) > 0 &&
89
        filter_var($aData['senderEmail'], FILTER_VALIDATE_EMAIL))
90
      $message->setReplyTo(array($aData['senderEmail'] => $aData['senderName']));
91
92
    // Send message out with configured transport
93
    try {
94
      if ($mailer->send($message)) return true;
95
    } catch (Exception $e) {
96
      $this->setErrorMessage($e->getMessage());
97
      return false;
98
    }
99
    $this->setErrorMessage($this->sqlError('E0031'));
100
    return false;
101
  }
102
}
103
104
// Make our class available automatically
105
$mail = new Mail ();
106
$mail->setDebug($debug);
107
$mail->setMysql($mysqli);
108
$mail->setSmarty($smarty);
109
$mail->setConfig($config);
110
$mail->setSetting($setting);
111
$mail->setErrorCodes($aErrorCodes);
112