CVE-2016-3728 (published 2016-05-20T14:59Z)

Eval injection vulnerability in tftp_api.rb in the TFTP module in the Smart-Proxy in Foreman before 1.10.4 and 1.11.x before 1.11.2 allows remote attackers to execute arbitrary code via the PXE template type portion of the PATH_INFO to tftp/.

Severity: MEDIUM
CVSS v2 base score: 6.8 (AV:N/AC:M/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 8.8, HIGH (CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-284
cwe_name: Improper Access Control
description: The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
extended_description: 
            Access control involves the use of several protection mechanisms such as:
            
               Authentication (proving the identity of an actor)
               Authorization (ensuring that a given actor can access a resource), and
               Accountability (tracking of activities that were performed)
            
            When any mechanism is not applied or otherwise fails, attackers can compromise the security of the product by gaining privileges, reading sensitive information, executing commands, evading detection, etc.
            There are two distinct behaviors that can introduce access control weaknesses:
               
                  Specification: incorrect privileges, permissions, ownership, etc. are explicitly specified for either the user or the resource (for example, setting a password file to be world-writable, or giving administrator capabilities to a guest user). This action could be performed by the program or the administrator.
                  Enforcement: the mechanism contains errors that prevent it from properly enforcing the specified access control requirements (e.g., allowing the user to specify their own privileges, or allowing a syntactically-incorrect ACL to produce insecure settings). This problem occurs within the program itself, in that it does not actually enforce the intended security policy that the administrator specifies.
               
         
		 

Fix information:
repo_url: https://github.com/theforeman/smart-proxy
commit_details: repo_url: https://github.com/theforeman/smart-proxy
author: Lukas Zapletal
author_date: 2016-05-05 10:57:44+02:00
msg: Fixes #14931 - TFTP class instantiating fixed
repository: repo_url: https://github.com/theforeman/smart-proxy
repo_name: theforeman/smart-proxy
description: RESTful proxies for DNS, DHCP, TFTP, BMC and Puppet
repo_language: Ruby
owner: theforeman
file_changes: filename: tftp_api.rb
change_type: ModificationType.MODIFY
diff: @@ -8,13 +8,14 @@ module Proxy::TFTP
     helpers ::Proxy::Helpers
     authorize_with_trusted_hosts
     authorize_with_ssl_client
+    VARIANTS = ["Syslinux", "Pxegrub", "Pxegrub2", "Ztp", "Poap"].freeze
 
     helpers do
       def instantiate variant, mac=nil
         # Filenames must end in a hex representation of a mac address but only if mac is not empty
         log_halt 403, "Invalid MAC address: #{mac}"                  unless valid_mac?(mac) || mac.nil?
-        log_halt 403, "Unrecognized pxeboot config type: #{variant}" unless defined? variant.capitalize
-        eval "Proxy::TFTP::#{variant.capitalize}.new"
+        log_halt 403, "Unrecognized pxeboot config type: #{variant}" unless VARIANTS.include?(variant.capitalize)
+        Object.const_get("Proxy").const_get('TFTP').const_get(variant.capitalize).new
       end
 
       def create variant, mac

programming_language: Ruby
filename: tftp_api_test.rb
change_type: ModificationType.MODIFY
diff: @@ -17,6 +17,17 @@ class TftpApiTest < Test::Unit::TestCase
     @args = { :pxeconfig => "foo" }
   end
 
+  def test_instantiate_syslinux
+    obj = app.helpers.instantiate "syslinux", "AA:BB:CC:DD:EE:FF"
+    assert_equal "Proxy::TFTP::Syslinux", obj.class.name
+  end
+
+  def test_instantiate_nonexisting
+    subject = app
+    subject.helpers.expects(:log_halt).with(403, "Unrecognized pxeboot config type: Server").at_least(1)
+    subject.helpers.instantiate "Server", "AA:BB:CC:DD:EE:FF"
+  end
+
   def test_api_can_fetch_boot_file
     Proxy::Util::CommandTask.stubs(:new).returns(true)
     FileUtils.stubs(:mkdir_p).returns(true)

programming_language: Ruby