Issues (865)

Security Analysis    4 potential vulnerabilities

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 (1)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (2)
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 (1)
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.

payment-forms/elements/address-fields.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Displays an address field in payment form
4
 *
5
 * This template can be overridden by copying it to yourtheme/invoicing/payment-forms/elements/address-fields.php.
6
 *
7
 * @version 1.0.19
8
 * @var array $fields
9
 * @var string $field_type Either billing or shipping
10
 * @var string $uniqid A unique prefix for all ids
11
 * @var string $country The current user's country
12
 * @var GetPaid_Payment_Form $form
13
 */
14
15
defined( 'ABSPATH' ) || exit;
16
17
$field_type = sanitize_key( $field_type );
18
19
echo "<div class='row " . esc_attr( $field_type ) . "'>";
20
21
// Prepare current user.
22
if ( ! empty( $form->invoice ) ) {
23
    $user_id = $form->invoice->get_user_id();
24
}
25
26
if ( empty( $user_id ) && is_user_logged_in() ) {
27
    $user_id = get_current_user_id();
28
}
29
30
if ( ! empty( $user_id ) ) {
31
    $user  = wp_get_current_user();
32
}
33
34
foreach ( $fields as $address_field ) {
35
36
    // Skip if it is hidden.
37
    if ( empty( $address_field['visible'] ) ) {
38
        continue;
39
    }
40
41
    do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field );
42
43
    // Prepare variables.
44
    $field_name  = $address_field['name'];
45
    $field_name  = "{$field_type}[$field_name]";
46
    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
47
    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
48
    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( __( wp_unslash( $address_field['placeholder'] ), 'invoicing' ) );
0 ignored issues
show
It seems like wp_unslash($address_field['placeholder']) can also be of type array; however, parameter $text of __() 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

48
    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( __( /** @scrutinizer ignore-type */ wp_unslash( $address_field['placeholder'] ), 'invoicing' ) );
Loading history...
49
    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( __( wp_unslash( $address_field['description'] ), 'invoicing' ) );
50
    $value       = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : '';
51
    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( __( wp_unslash( $address_field['label'] ), 'invoicing' ) );
52
53
    $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] );
54
    if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) {
55
        $value = call_user_func( array( $form->invoice, $method_name ) );
56
    }
57
58
    if ( empty( $value ) && 'wpinv_first_name' === $address_field['name'] && ! empty( $user ) ) {
59
        $value = $user->first_name;
60
    }
61
62
    if ( empty( $value ) && 'wpinv_last_name' === $address_field['name'] && ! empty( $user ) ) {
63
        $value = $user->last_name;
64
    }
65
66
    if ( ! empty( $address_field['required'] ) ) {
67
        $label .= "<span class='text-danger'> *</span>";
68
    }
69
70
    // Display the country.
71
    if ( 'wpinv_country' === $address_field['name'] ) {
72
73
        echo "<div class='form-group mb-3 " . esc_attr( $wrap_class ) . " getpaid-address-field-wrapper__country'";
74
75
        aui()->select(
76
            array(
77
                'options'          => wpinv_get_country_list(),
78
                'name'             => esc_attr( $field_name ),
79
                'id'               => sanitize_html_class( $field_name ) . $uniqid,
80
                'value'            => esc_attr( $country ),
81
                'placeholder'      => $placeholder,
82
                'required'         => ! empty( $address_field['required'] ),
83
                'label'            => wp_kses_post( $label ),
84
                'label_type'       => 'vertical',
85
                'help_text'        => $description,
86
                'class'            => 'getpaid-address-field wpinv_country',
87
                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__country',
88
                'extra_attributes' => array(
89
                    'autocomplete'    => "$field_type country",
90
                    'data-ip-country' => getpaid_get_ip_country(),
91
                ),
92
                'no_wrap'          => true,
93
            ),
94
            true
95
        );
96
97
        if ( wpinv_should_validate_vat_number() ) {
98
99
            aui()->input(
100
                array(
101
                    'type'       => 'checkbox',
102
                    'name'       => 'confirm-address',
103
                    'id'         => "shipping-toggle$uniqid",
104
                    'wrap_class' => 'getpaid-address-field-wrapper__address-confirm mt-1 d-none',
105
                    'required'   => false,
106
                    'label'      => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>",
107
                    'value'      => 1,
108
                    'checked'    => true,
109
                    'class'      => 'w-auto',
110
                ),
111
                true
112
            );
113
114
        }
115
116
        echo '</div>';
117
118
    }
119
120
    // Display the state.
121
    elseif ( 'wpinv_state' == $address_field['name'] ) {
122
123
        if ( empty( $value ) ) {
124
            $value = wpinv_get_default_state();
125
        }
126
127
        getpaid_get_states_select_markup(
128
            $country,
129
            $value,
130
            $placeholder,
131
            $label,
132
            $description,
133
            ! empty( $address_field['required'] ),
134
            $wrap_class,
135
            $field_name,
136
            true
137
        );
138
139
    } else {
140
141
        $key      = str_replace( 'wpinv_', '', $address_field['name'] );
142
        $key      = esc_attr( str_replace( '_', '-', $key ) );
143
        $autocomplete = '';
144
        $replacements = array(
145
            'zip'        => 'postal-code',
146
            'first-name' => 'given-name',
147
            'last-name'  => 'family-name',
148
            'company'    => 'organization',
149
            'address'    => 'street-address',
150
            'phone'      => 'tel',
151
            'city'       => 'address-level2',
152
        );
153
154
155
        if ( isset( $replacements[ $key ] ) ) {
156
            $autocomplete = array(
157
                'autocomplete' => "$field_type {$replacements[ $key ]}",
158
            );
159
        }
160
161
        $append = '';
162
163
        if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) {
164
            $valid    = esc_attr__( 'Valid', 'invoicing' );
165
            $invalid  = esc_attr__( 'Invalid', 'invoicing' );
166
            $validate = esc_attr__( 'Validate', 'invoicing' );
167
            $append   = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>";
168
        }
169
170
        if ( 'billing' === $field_type ) {
171
            $description .= '<div class="getpaid-error-' . esc_attr( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>';
172
        }
173
174
        aui()->input(
175
            array(
176
                'name'              => esc_attr( $field_name ),
177
                'id'                => sanitize_html_class( $field_name ) . $uniqid,
178
                'required'          => ! empty( $address_field['required'] ),
179
                'placeholder'       => $placeholder,
180
                'label'             => wp_kses_post( $label ),
181
                'label_type'        => 'vertical',
182
                'help_text'         => $description,
183
                'type'              => 'text',
184
                'value'             => apply_filters( 'getpaid_payment_form_value_' . $address_field['name'], esc_attr( $value ) ),
185
                'class'             => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
186
                'wrap_class'        => "$wrap_class getpaid-address-field-wrapper__$key",
187
                'label_class'       => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
188
                'extra_attributes'  => $autocomplete,
189
                'input_group_right' => $append,
190
            ),
191
            true
192
        );
193
194
    }
195
196
    do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field );
197
}
198
199
echo '</div>';
200