-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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 CVE-2023-46604 - Apache ActiveMQ #18501
Conversation
This pull request is now ready for review. I added in a Windows/Linux and Unix (for OSX, although I don't have an OSX machine to test on) targets as ActiveMQ supports all these. Windows
Linux
Unix
|
def check | ||
connect | ||
|
||
res = sock.get_once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker
res = sock.get_once | |
begin | |
res = sock.get_once | |
ensure | |
disconnect if sock | |
end | |
|
||
return CheckCode::Unknown unless res | ||
|
||
len, _, magic = res.unpack('NCZ*') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker - and definitely not required; a bunch of our other modules use bindata for binary parsing for readability purposes:
|
||
sock.puts([data.length].pack('N') + data) | ||
|
||
retry_until_truthy(timeout: datastore['WfsDelay']) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for this PR; There might be an edgecase/bug in framework itself if this is required
['0.0.0', '5.15.15'] | ||
] | ||
|
||
ranges.each do |min, max| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker; potentially a missing feature in framework itself
documentation/modules/exploit/multi/misc/apache_activemq_rce_cve_2023_46604.md
Outdated
Show resolved
Hide resolved
documentation/modules/exploit/multi/misc/apache_activemq_rce_cve_2023_46604.md
Outdated
Show resolved
Hide resolved
|
…ve_2023_46604.md Co-authored-by: Brendan <[email protected]>
Co-authored-by: Brendan <[email protected]>
|
||
return CheckCode::Unknown unless magic == 'ActiveMQ' | ||
|
||
if res =~ /ProviderVersion...(\d+\.\d+\.\d+)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if res =~ /ProviderVersion...(\d+\.\d+\.\d+)/ | |
if res !~ /ProviderVersion...(\d+\.\d+\.\d+)/ | |
CheckCode::Detected | |
end |
Something like this would allow to reduce the level of nested indentation in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented something similar via ea21036 to reduce the nesting
end | ||
|
||
def on_request_uri(cli, request) | ||
if request.uri == get_resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if request.uri == get_resource | |
if request.uri != get_resource | |
super | |
end |
Again here, to reduce nested indentation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reduce indentation as suggested in 4272678
<list> | ||
<value>#{shell}</value> | ||
<value>#{flag}</value> | ||
<value><![CDATA[#{payload.encoded}]]></value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a stupid question, but could it be possible for the payload to contain the characters ]]>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, CDATA cannot cannot contain the sequence ]]>
, this was not an issue when testing any payloads. I guess the safest thing to do would be to sanity check that payload.encoded
does not include ]]>
, and if it does, fail gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check for this in fa8c400.
@sfewer-r7 quick question for you about this Is there ever a case where we could get the server to load the remote XML file via HTTPS instead of HTTP? I'm working on network signatures for this one and the XML in the body of the HTTP request would be a phenomenal signature... if we can always see it 😅 |
Hi @HuskyHacks , good question. For this specific Metasploit module I don't think it would work as setting the That aside, if the XML file was served over HTTPS, the client (ActiveMQ) would need to accept a self signed cert from the attacker (unless attacker supplies a CA signed cert), so depending on if the clients network stack verifies certs, serving the XML file over HTTPS may or may not work. I have not tested this. Sorry I cant give you a more concrete answer :) |
@sfewer-r7 thank you! That helps a lot. I'm now testing to see if I can coerce that XML load to use HTTPS with the original POC. Thanks! |
I have no idea if there's something else in the stack of dependencies that would affect the SSL status, and this is based off of about 5 minutes of code spelunking, but
|
Thanks Brendan, appreciate you investigating. I don't think this blocks this module, but it would be nice to have some way to "deregister" the TCP mixin from SSL in this specific instance, as the OpenWire protocol doesn't require it (AFAIK) and this would open up enabling SSL seperatly for the HttpServer. |
…fail before we attempt exploitation
Thanks for everyone's review/feedback. I have made all the edits I plan to unless there are any outstanding issues we want to address |
Release NotesThis pull request is an exploit module for CVE-2023-46604, affecting the OpenWire transport unmarshaller in Apache ActiveMQ. |
An interesting development here! Don't know if it's worth refactoring the current module but wanted to post here if anyone is interested in exploitation https://vulncheck.com/blog/cve-2023-44604-activemq-in-memory Turns out you don't need to shell out to execute code if you use the Nashorn engine to evaluate and execute code directly from within the process space of java. |
This pull request is an exploit module for CVE-2023-46604, affecting the OpenWire transport unmarshaller in Apache ActiveMQ. This exploit is based of this original work by X1r0z (https://github.com/X1r0z/ActiveMQ-RCE).
Opening this pull request as a draft while I work on it, the following needs to be done.
Example usage: