Post by websiteworld » Wed Mar 19, 2025 3:40 am

Had 99% CPU on server, determined it was from a Germany based IP adddress doing hundreds of the following http queries. Blocked the IP on the firewall and the CPU went back down to normal instantly. Any ideas why this query caused high CPU useage? Maybe our Max_Connections is set to high on the MYSQL server?

Code: Select all

GET /index.php route=product%2Fcatalog%27+or+%28SELECT+1+FROM+%28SELECT+COUNT%28%2A%29%2C+CONCAT%28%28SELECT+%28SELECT+CONCAT%28GTID_SUBSET%28CAST%28SUBSTRING%28email%2C+1%2C+120%29+AS+CHAR%29%2C0x7e%29%29%29+FROM+%60pyrocreations2025%60.%60oc_customer_login%60+LIMIT+458171%2C+1%29%2C+FLOOR%28RAND%280%29+%2A+2%29%29+x+FROM+INFORMATION_SCHEMA.TABLES+GROUP+BY+x%29+a%29+and+%271%27%3D%271

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by IP_CAM » Wed Mar 19, 2025 5:22 am

You could post the IP-Address in charge of this, to enable others to block it in their .htaccess file as well. ;)

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by websiteworld » Wed Mar 19, 2025 6:17 am

23.88.75.49

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by nonnedelectari » Wed Mar 19, 2025 8:37 am

I wouldn't be concerned with "why this query caused high CPU useage" or the ip where it came from, I would be concerned with why your site executes sql injections in the first place.

Active Member
Online

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by ADD Creative » Wed Mar 19, 2025 7:17 pm

Look like an attempt to use SQL injection to extract information from your database.

Make sure you have display errors switch off in ALL THREE places, as it looks like an SQL injection that may require error display to be on.

Check both your PHP and OpenCart error logs as these may give you more information.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by paulfeakins » Wed Mar 19, 2025 7:59 pm

nonnedelectari wrote:
Wed Mar 19, 2025 8:37 am
I would be concerned with why your site executes sql injections in the first place.
It isn't necessarily executing the SQL though.

Just hitting a site with a huge number of requests could take it down even if there's no vulnerability.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by nonnedelectari » Wed Mar 19, 2025 9:57 pm

paulfeakins wrote:
Wed Mar 19, 2025 7:59 pm
nonnedelectari wrote:
Wed Mar 19, 2025 8:37 am
I would be concerned with why your site executes sql injections in the first place.
It isn't necessarily executing the SQL though.

Just hitting a site with a huge number of requests could take it down even if there's no vulnerability.
"hundreds of the following http queries", are peanuts.

Active Member
Online

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by websiteworld » Wed Mar 19, 2025 10:33 pm

nonnedelectari wrote:
Wed Mar 19, 2025 8:37 am
I wouldn't be concerned with "why this query caused high CPU useage" or the ip where it came from, I would be concerned with why your site executes sql injections in the first place.
They were getting a 503 error, however I think this filter can be added to IIS to mitigate

<filteringRules>
<filteringRule name="SQLInjection" scanUrl="false" scanQueryString="true">
<appliesTo>
<clear />
<add fileExtension=".asp" />
<add fileExtension=".aspx" />
<add fileExtension=".php" />
</appliesTo>
<denyStrings>
<clear />
<add string="--" />
<add string=";" />
<add string="/*" />
<add string="@" />
<add string="char" />
<add string="alter" />
<add string="begin" />
<add string="cast" />
<add string="create" />
<add string="cursor" />
<add string="declare" />
<add string="delete" />
<add string="drop" />
<add string="end" />
<add string="exec" />
<add string="fetch" />
<add string="insert" />
<add string="kill" />
<add string="open" />
<add string="select" />
<add string="sys" />
<add string="table" />
<add string="update" />
</denyStrings>
<scanHeaders>
<clear />
</scanHeaders>
</filteringRule>
</filteringRules>

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by ADD Creative » Wed Mar 19, 2025 11:22 pm

websiteworld wrote:
Wed Mar 19, 2025 10:33 pm
They were getting a 503 error, however I think this filter can be added to IIS to mitigate
Remember SQL filter like that can be bypassed.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by websiteworld » Thu Mar 20, 2025 12:19 am

ADD Creative wrote:
Wed Mar 19, 2025 11:22 pm
websiteworld wrote:
Wed Mar 19, 2025 10:33 pm
They were getting a 503 error, however I think this filter can be added to IIS to mitigate
Remember SQL filter like that can be bypassed.
They were getting a 503 error anyway, so the attempts fail. Any suggestions other than blocking the IP address to avoid the attempts from spiking the CPU?

Here is an example of the PHP Error

[18-Mar-2025 18:46:21 UTC] PHP Fatal error: Uncaught Exception: Error: Malformed GTID set specification 'pondaraashokpatro@rediffmail.com'.<br />Error No: 1772<br />SELECT * FROM oc_seo_url WHERE `query` = 'product/catalog' or (SELECT 1 FROM (SELECT COUNT(*), CONCAT((SELECT (SELECT CONCAT(GTID_SUBSET(CAST(SUBSTRING(email, 1, 120) AS CHAR),0x7e))) FROM `py2025`.`oc_customer_login` LIMIT 450881, 1), FLOOR(RAND(0) * 2)) x FROM INFORMATION_SCHEMA.TABLES GROUP BY x) a) and '1'='1' AND language_id = '1' in D:\cuswebs\www2015\py***********.com\system\library\db\mysqli.php:49
Stack trace:
#0 D:\cuswebs\www2015\storage-py\modification\system\library\db.php(55): DB\MySQLi->query()
#1 D:\cuswebs\www2015\storage-py\modification\catalog\controller\startup\seo_url.php(117): DB->query()
#2 D:\cuswebs\www2015\py\system\library\url.php(64): ControllerStartupSeoUrl->rewrite()
#3 D:\cuswebs\www2015\py\catalog\controller\error\not_found.php(32): Url->link()
#4 D:\cuswebs\www2015\storage-py\modification\system\engine\action.php(79): ControllerErrorNotFound->index()
#5 D:\cuswebs\www2015\storage-pyr\modification\system\engine\router.php(77): Action->execute()
#6 D:\cuswebs\www2015\storage-py\modification\system\engine\router.php(66): Router->execute()
#7 D:\cuswebs\www2015\py\system\framework.php(179): Router->dispatch()
#8 D:\cuswebs\www2015\py\system\startup.php(104): require_once('...')
#9 D:\cuswebs\www2015\py.com\index.php(19): start()
#10 {main}
thrown in D:\cuswebs\www2015\py***************.com\system\library\db\mysqli.php on line 49

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by ADD Creative » Thu Mar 20, 2025 8:04 am

Check the SQL query in modification\catalog\controller\startup\seo_url.php at line 117. It's probably vulnerable injection looking at the error log.

Also make make sure display errors in set to off in all 3 places. Your PHP settings, in system/config/default.php and in the settings. Not only can this cause minor notices and warnings to cause bigger errors, it can also be a security risk as some SQL injection methods rely on error messages to retrieve data (could that email address in the error log be one of your customer's?).

1. In your PHP settings make sure display_errors is set to Off. Use phpinfo() to check. It should be off by default, but there are lots of rubbish hosts out there.

2. In system/config/default.php set error_display to false.

3. In your OpenCart Setting on the server tab set Display Errors to No.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by websiteworld » Thu Mar 20, 2025 8:37 am

ADD Creative wrote:
Thu Mar 20, 2025 8:04 am
Check the SQL query in modification\catalog\controller\startup\seo_url.php at line 117. It's probably vulnerable injection looking at the error log.

Code: Select all

if(empty($url)){
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $data['route'] . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

				if ($query->num_rows && $query->row['keyword']) {
					$url .= '/' . $query->row['keyword'];
				} 
			}
ADD Creative wrote:
Thu Mar 20, 2025 8:04 am

1. In your PHP settings make sure display_errors is set to Off. Use phpinfo() to check. It should be off by default, but there are lots of rubbish hosts out there.
We own/operate the server and don't have a host. Everything is set to off in Opencart, I can view the PHP error logs.

That email is not a customer, so maybe they were trying to inject it into the database as a customer?

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by SohBH » Thu Mar 20, 2025 4:06 pm

Replace $data['route'] with $this->db->escape($data['route']) to fix SQL injection.

Web Development for service businesses serious about online growth


User avatar
Active Member

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by paulfeakins » Thu Mar 20, 2025 8:28 pm

websiteworld wrote:
Thu Mar 20, 2025 8:37 am
We own/operate the server and don't have a host.
You really shouldn't be running a live web server on an ecommerce site if you don't know how to protect against this sort of thing.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by ADD Creative » Thu Mar 20, 2025 8:55 pm

websiteworld wrote:
Thu Mar 20, 2025 8:37 am

Code: Select all

if(empty($url)){
			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $data['route'] . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

				if ($query->num_rows && $query->row['keyword']) {
					$url .= '/' . $query->row['keyword'];
				} 
			}
We own/operate the server and don't have a host. Everything is set to off in Opencart, I can view the PHP error logs.

That email is not a customer, so maybe they were trying to inject it into the database as a customer?
That code is vulnerable to SQL injection. As SohBH stated, "$data['route']" needs to be escaped. You will need to do this in the actual extension as if you refresh modification the vulnerability will return. You might want to contact the extension developer to report it.

The attack was trying to extract emails from the oc_customer_login table, not injecting it into the database. As long as you had correctly configured all the error display settings and both the PHP and OpenCart error logs are not public, it probably failed.

One other thing to note is that the attack uses a database name and a table name "`py2025`.`oc_customer_login`". If the database name is wrong then it could just be a bot looking for weakness, although you would expect the error to be a permissions error as the table doesn't exist. If the table name they are using in attacks is correct then they have most likely been successful at some point.

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by khnaz35 » Thu Mar 20, 2025 11:44 pm

You could do it like this.

Code: Select all

if (empty($url)) {
    $route = $this->db->escape($data['route']);  // Escape the route input to prevent SQL injection
    $language_id = (int)$this->config->get('config_language_id');  // Ensure language_id is cast to integer

    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $route . "' AND language_id = '" . $language_id . "'");

    if ($query->num_rows && $query->row['keyword']) {
        $url .= '/' . $query->row['keyword'];
    } 
}

Got an urgent question that’s keeping you up at night? There might just be a magical inbox ready to help: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by websiteworld » Fri Mar 21, 2025 11:06 pm

paulfeakins wrote:
Thu Mar 20, 2025 8:28 pm
websiteworld wrote:
Thu Mar 20, 2025 8:37 am
We own/operate the server and don't have a host.
You really shouldn't be running a live web server on an ecommerce site if you don't know how to protect against this sort of thing.
These kind of comments are useless. Nothing happened on the server, the attempt failed and was easily mitigated. As other helpful users pointed out, this is an issue with an add on or Journal Theme and the code needs revised! Thanks to those who pointed this out, will report the bug.

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by nonnedelectari » Fri Mar 21, 2025 11:27 pm

websiteworld wrote:
Fri Mar 21, 2025 11:06 pm
paulfeakins wrote:
Thu Mar 20, 2025 8:28 pm
websiteworld wrote:
Thu Mar 20, 2025 8:37 am
We own/operate the server and don't have a host.
You really shouldn't be running a live web server on an ecommerce site if you don't know how to protect against this sort of thing.
These kind of comments are useless. Nothing happened on the server, the attempt failed and was easily mitigated. As other helpful users pointed out, this is an issue with an add on or Journal Theme and the code needs revised! Thanks to those who pointed this out, will report the bug.
"the attempt failed", well, a successful sql injection with your cpu going to 99%, I would say that is arguably a pretty successful effort.

Active Member
Online

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by websiteworld » Sat Mar 22, 2025 1:21 am

For anyone that is interested, the extension that has this vulnerability is on the OpenCart Marketplace- TMD Product Reviews Pro

https://www.opencart.com/index.php?rout ... n_id=15214

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am

Post by websiteworld » Sat Mar 22, 2025 8:14 pm

Developer claims there isn't an issue as noted here. :-0

See attached.

Attachments

???
Screenshot 2025-03-22 081052.png

User avatar
New member

Posts

Joined
Thu Oct 18, 2012 3:11 am
Who is online

Users browsing this forum: Amazon [Bot], nonnedelectari and 152 guests