Issues (1182)

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.

includes/class-wc-https.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
if ( ! defined( 'ABSPATH' ) ) {
4
	exit; // Exit if accessed directly
5
}
6
7
/**
8
 * WC_HTTPS class.
9
 *
10
 * @class    WC_HTTPS
11
 * @version  2.2.0
12
 * @package  WooCommerce/Classes
13
 * @category Class
14
 * @author   WooThemes
15
 */
16
class WC_HTTPS {
17
18
	/**
19
	 * Hook in our HTTPS functions if we're on the frontend. This will ensure any links output to a page (when viewing via HTTPS) are also served over HTTPS.
20
	 */
21
	public static function init() {
22
		if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) && ! is_admin() ) {
23
			// HTTPS urls with SSL on
24
			$filters = array(
25
				'post_thumbnail_html',
26
				'wp_get_attachment_image_attributes',
27
				'wp_get_attachment_url',
28
				'option_stylesheet_url',
29
				'option_template_url',
30
				'script_loader_src',
31
				'style_loader_src',
32
				'template_directory_uri',
33
				'stylesheet_directory_uri',
34
				'site_url'
35
			);
36
37
			foreach ( $filters as $filter ) {
38
				add_filter( $filter, array( __CLASS__, 'force_https_url' ), 999 );
39
			}
40
41
			add_filter( 'page_link', array( __CLASS__, 'force_https_page_link' ), 10, 2 );
42
			add_action( 'template_redirect', array( __CLASS__, 'force_https_template_redirect' ) );
43
44
			if ( 'yes' == get_option( 'woocommerce_unforce_ssl_checkout' ) ) {
45
				add_action( 'template_redirect', array( __CLASS__, 'unforce_https_template_redirect' ) );
46
			}
47
		}
48
		add_action( 'http_api_curl', array( __CLASS__, 'http_api_curl' ), 10, 3 );
49
	}
50
51
	/**
52
	 * Force https for urls.
53
	 *
54
	 * @param mixed $content
55
	 * @return string
56
	 */
57
	public static function force_https_url( $content ) {
58
		if ( is_ssl() ) {
59
			if ( is_array( $content ) ) {
60
				$content = array_map( 'WC_HTTPS::force_https_url', $content );
61
			} else {
62
				$content = str_replace( 'http:', 'https:', $content );
63
			}
64
		}
65
		return $content;
66
	}
67
68
	/**
69
	 * Force a post link to be SSL if needed.
70
	 *
71
	 * @return string
72
	 */
73
	public static function force_https_page_link( $link, $page_id ) {
74
		if ( in_array( $page_id, array( get_option( 'woocommerce_checkout_page_id' ), get_option( 'woocommerce_myaccount_page_id' ) ) ) ) {
75
			$link = str_replace( 'http:', 'https:', $link );
76
		} elseif ( 'yes' === get_option( 'woocommerce_unforce_ssl_checkout' ) && ! wc_site_is_https() ) {
77
			$link = str_replace( 'https:', 'http:', $link );
78
		}
79
		return $link;
80
	}
81
82
	/**
83
	 * Template redirect - if we end up on a page ensure it has the correct http/https url.
84
	 */
85
	public static function force_https_template_redirect() {
86
		if ( ! is_ssl() && ( is_checkout() || is_account_page() || apply_filters( 'woocommerce_force_ssl_checkout', false ) ) ) {
87
88 View Code Duplication
			if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
				wp_safe_redirect( preg_replace( '|^http://|', 'https://', $_SERVER['REQUEST_URI'] ) );
90
				exit;
91
			} else {
92
				wp_safe_redirect( 'https://' . ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'] ) . $_SERVER['REQUEST_URI'] );
93
				exit;
94
			}
95
		}
96
	}
97
98
	/**
99
	 * Template redirect - if we end up on a page ensure it has the correct http/https url.
100
	 */
101
	public static function unforce_https_template_redirect() {
102
		if ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) {
103
			return;
104
		}
105
106
		if ( ! wc_site_is_https() && is_ssl() && $_SERVER['REQUEST_URI'] && ! is_checkout() && ! is_ajax() && ! is_account_page() && apply_filters( 'woocommerce_unforce_ssl_checkout', true ) ) {
107
108 View Code Duplication
			if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
				wp_safe_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ) );
110
				exit;
111
			} else {
112
				wp_safe_redirect( 'http://' . ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'] ) . $_SERVER['REQUEST_URI'] );
113
				exit;
114
			}
115
		}
116
	}
117
118
	/**
119
	 * Force posts to PayPal to use TLS v1.2. See:
120
	 * 		https://core.trac.wordpress.org/ticket/36320
121
	 * 		https://core.trac.wordpress.org/ticket/34924#comment:13
122
	 * 		https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US
123
	 */
124
	public static function http_api_curl( $handle, $r, $url ) {
125
		if ( strstr( $url, 'https://' ) && ( strstr( $url, '.paypal.com/nvp' ) || strstr( $url, '.paypal.com/cgi-bin/webscr' ) ) ) {
126
			curl_setopt( $handle, CURLOPT_SSLVERSION, 6 );
127
		}
128
	}
129
}
130
131
WC_HTTPS::init();
132