CVE-2012-3864 (published 2012-08-06T16:55Z)

Puppet before 2.6.17 and 2.7.x before 2.7.18, and Puppet Enterprise before 2.5.2, allows remote authenticated users to read arbitrary files on the puppet master server by leveraging an arbitrary user's certificate and private key in a GET request.

Severity: MEDIUM
CVSS v2 base score: 4.0 (AV:N/AC:L/Au:S/C:P/I:N/A:N)

Weakness information:
cwe_id: CWE-200
cwe_name: Exposure of Sensitive Information to an Unauthorized Actor
description: The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
extended_description: 
	   There are many different kinds of mistakes that introduce information exposures. The severity of the error can range widely, depending on the context in which the product operates, the type of sensitive information that is revealed, and the benefits it may provide to an attacker.  Some kinds of sensitive information include:
       
         private, personal information, such as personal messages, financial data, health records, geographic location, or contact details
         system status and environment, such as the operating system and installed packages
		 business secrets and intellectual property
		 network status and configuration
		 the product's own code or internal state
         metadata, e.g. logging of connections or message headers
		 indirect information, such as a discrepancy between two internal operations that can be observed by an outsider
       
	    Information might be sensitive to different parties, each of which may have their own expectations for whether the information should be protected.  These parties include:
               
                  the product's own users
                  people or organizations whose information is created or used by the product, even if they are not direct product users
		  the product's administrators, including the admins of the system(s) and/or networks on which the product operates
                  the developer
               
	    Information exposures can occur in different ways:
               
                  the code explicitly inserts sensitive information into resources or messages that are intentionally made accessible to unauthorized actors, but should not contain the information - i.e., the information should have been "scrubbed" or "sanitized"
                  a different weakness or mistake indirectly inserts the sensitive information into resources, such as a web script error revealing the full system path of the program.
                  the code manages resources that intentionally contain sensitive information, but the resources are unintentionally made accessible to unauthorized actors. In this case, the information exposure is resultant - i.e., a different weakness enabled the access to the information in the first place.
               
	    It is common practice to describe any loss of confidentiality as an "information exposure," but this can lead to overuse of CWE-200 in CWE mapping. From the CWE perspective, loss of confidentiality is a technical impact that can arise from dozens of different weaknesses, such as insecure file permissions or out-of-bounds read.  CWE-200 and its lower-level descendants are intended to cover the mistakes that occur in behaviors that explicitly manage, store, transfer, or cleanse sensitive information.
         
         

Fix information:
repo_url: https://github.com/puppetlabs/puppet
commit_details: repo_url: https://github.com/puppetlabs/puppet
author: Patrick Carlisle
author_date: 2012-06-21 15:52:58-07:00
msg: Add Selector terminus for file_content/file_metadata

This terminus is now the default, and encapsulates the behavior that was
previously in the IndirectionHooks. That is, we dynamically select the
terminus to use for a file request based on the key. However, for the
puppet master, we instead explicitly always use the FileServer terminus,
so that *all* requests for files from the master will go through
the file server. This ensures that we will never accidentally
serve local files on the puppet master.
repository: repo_url: https://github.com/puppetlabs/puppet
repo_name: puppetlabs/puppet
description: Server automation framework and application
repo_language: Ruby
owner: puppetlabs
file_changes: filename: master.rb
change_type: ModificationType.MODIFY
diff: @@ -231,6 +231,9 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
     # Cache our nodes in yaml.  Currently not configurable.
     Puppet::Node.indirection.cache_class = :yaml
 
+    Puppet::FileServing::Content.indirection.terminus_class = :file_server
+    Puppet::FileServing::Metadata.indirection.terminus_class = :file_server
+
     # Configure all of the SSL stuff.
     if Puppet::SSL::CertificateAuthority.ca?
       Puppet::SSL::Host.ca_location = :local

programming_language: Ruby
filename: configuration.rb
change_type: ModificationType.MODIFY
diff: @@ -64,7 +64,7 @@ class Puppet::FileServing::Configuration
 
     mount_name, path = request.key.split(File::Separator, 2)
 
-    raise(ArgumentError, "Cannot find file: Invalid path '#{mount_name}'") unless mount_name =~ %r{^[-\w]+$}
+    raise(ArgumentError, "Cannot find file: Invalid mount '#{mount_name}'") unless mount_name =~ %r{^[-\w]+$}
 
     return nil unless mount = find_mount(mount_name, request.environment)
     if mount.name == "modules" and mount_name != "modules"

programming_language: Ruby
filename: content.rb
change_type: ModificationType.MODIFY
diff: @@ -1,14 +1,13 @@
 require 'puppet/indirector'
 require 'puppet/file_serving'
 require 'puppet/file_serving/base'
-require 'puppet/file_serving/indirection_hooks'
 
 # A class that handles retrieving file contents.
 # It only reads the file when its content is specifically
 # asked for.
 class Puppet::FileServing::Content < Puppet::FileServing::Base
   extend Puppet::Indirector
-  indirects :file_content, :extend => Puppet::FileServing::IndirectionHooks
+  indirects :file_content, :terminus_class => :selector
 
   attr_writer :content
 

programming_language: Ruby
filename: metadata.rb
change_type: ModificationType.MODIFY
diff: @@ -3,7 +3,6 @@ require 'puppet/indirector'
 require 'puppet/file_serving'
 require 'puppet/file_serving/base'
 require 'puppet/util/checksums'
-require 'puppet/file_serving/indirection_hooks'
 
 # A class that handles retrieving file metadata.
 class Puppet::FileServing::Metadata < Puppet::FileServing::Base
@@ -11,7 +10,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
   include Puppet::Util::Checksums
 
   extend Puppet::Indirector
-  indirects :file_metadata, :extend => Puppet::FileServing::IndirectionHooks
+  indirects :file_metadata, :terminus_class => :selector
 
   attr_reader :path, :owner, :group, :mode, :checksum_type, :checksum, :ftype, :destination
 

programming_language: Ruby
filename: terminus_selector.rb
change_type: ModificationType.RENAME
diff: @@ -1,15 +1,12 @@
-require 'uri'
 require 'puppet/file_serving'
-require 'puppet/util'
 
 # This module is used to pick the appropriate terminus
 # in file-serving indirections.  This is necessary because
 # the terminus varies based on the URI asked for.
-module Puppet::FileServing::IndirectionHooks
+module Puppet::FileServing::TerminusSelector
   PROTOCOL_MAP = {"puppet" => :rest, "file" => :file}
 
-  # Pick an appropriate terminus based on the protocol.
-  def select_terminus(request)
+  def select(request)
     # We rely on the request's parsing of the URI.
 
     # Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol.

programming_language: Ruby
filename: selector.rb
change_type: ModificationType.ADD
diff: @@ -0,0 +1,29 @@
+require 'puppet/indirector/file_content'
+require 'puppet/indirector/code'
+require 'puppet/file_serving/terminus_selector'
+
+class Puppet::Indirector::FileContent::Selector < Puppet::Indirector::Code
+  desc "Select the terminus based on the request"
+  include Puppet::FileServing::TerminusSelector
+
+  def get_terminus(request)
+    indirection.terminus(select(request))
+  end
+
+  def find(request)
+    get_terminus(request).find(request)
+  end
+
+  def search(request)
+    get_terminus(request).search(request)
+  end
+
+  def authorized?(request)
+    terminus = get_terminus(request)
+    if terminus.respond_to?(:authorized?)
+      terminus.authorized?(request)
+    else
+      true
+    end
+  end
+end

programming_language: Ruby
filename: selector.rb
change_type: ModificationType.ADD
diff: @@ -0,0 +1,29 @@
+require 'puppet/indirector/file_metadata'
+require 'puppet/indirector/code'
+require 'puppet/file_serving/terminus_selector'
+
+class Puppet::Indirector::FileMetadata::Selector < Puppet::Indirector::Code
+  desc "Select the terminus based on the request"
+  include Puppet::FileServing::TerminusSelector
+
+  def get_terminus(request)
+    indirection.terminus(select(request))
+  end
+
+  def find(request)
+    get_terminus(request).find(request)
+  end
+
+  def search(request)
+    get_terminus(request).search(request)
+  end
+
+  def authorized?(request)
+    terminus = get_terminus(request)
+    if terminus.respond_to?(:authorized?)
+      terminus.authorized?(request)
+    else
+      true
+    end
+  end
+end

programming_language: Ruby
filename: file_serving.rb
change_type: ModificationType.MODIFY
diff: @@ -5,9 +5,7 @@ shared_examples_for "Puppet::FileServing::Files" do
 
     # It appears that the mocking somehow interferes with the caching subsystem.
     # This mock somehow causes another terminus to get generated.
-    term = @indirection.terminus(:rest)
-    @indirection.stubs(:terminus).with(:rest).returns term
-    term.expects(:find)
+    @indirection.terminus(:rest).expects(:find)
     @indirection.find(uri)
   end
 

programming_language: Ruby
filename: content_spec.rb
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@ require 'puppet/file_serving/content'
 describe Puppet::FileServing::Content do
   let(:path) { File.expand_path('/path') }
 
-  it "should should be a subclass of Base" do
+  it "should be a subclass of Base" do
     Puppet::FileServing::Content.superclass.should equal(Puppet::FileServing::Base)
   end
 
@@ -14,10 +14,6 @@ describe Puppet::FileServing::Content do
     Puppet::FileServing::Content.indirection.name.should == :file_content
   end
 
-  it "should should include the IndirectionHooks module in its indirection" do
-    Puppet::FileServing::Content.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks)
-  end
-
   it "should only support the raw format" do
     Puppet::FileServing::Content.supported_formats.should == [:raw]
   end

programming_language: Ruby
filename: metadata_spec.rb
change_type: ModificationType.MODIFY
diff: @@ -6,7 +6,7 @@ require 'puppet/file_serving/metadata'
 describe Puppet::FileServing::Metadata do
   let(:foobar) { File.expand_path('/foo/bar') }
 
-  it "should should be a subclass of Base" do
+  it "should be a subclass of Base" do
     Puppet::FileServing::Metadata.superclass.should equal(Puppet::FileServing::Base)
   end
 
@@ -14,10 +14,6 @@ describe Puppet::FileServing::Metadata do
     Puppet::FileServing::Metadata.indirection.name.should == :file_metadata
   end
 
-  it "should should include the IndirectionHooks module in its indirection" do
-    Puppet::FileServing::Metadata.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks)
-  end
-
   it "should have a method that triggers attribute collection" do
     Puppet::FileServing::Metadata.new(foobar).should respond_to(:collect)
   end

programming_language: Ruby
filename: terminus_selector_spec.rb
change_type: ModificationType.RENAME
diff: @@ -1,12 +1,12 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-require 'puppet/file_serving/indirection_hooks'
+require 'puppet/file_serving/terminus_selector'
 
-describe Puppet::FileServing::IndirectionHooks do
+describe Puppet::FileServing::TerminusSelector do
   before do
     @object = Object.new
-    @object.extend(Puppet::FileServing::IndirectionHooks)
+    @object.extend(Puppet::FileServing::TerminusSelector)
 
     @request = stub 'request', :key => "mymod/myfile", :options => {:node => "whatever"}, :server => nil, :protocol => nil
   end
@@ -14,17 +14,17 @@ describe Puppet::FileServing::IndirectionHooks do
   describe "when being used to select termini" do
     it "should return :file if the request key is fully qualified" do
       @request.expects(:key).returns File.expand_path('/foo')
-      @object.select_terminus(@request).should == :file
+      @object.select(@request).should == :file
     end
 
     it "should return :file if the URI protocol is set to 'file'" do
       @request.expects(:protocol).returns "file"
-      @object.select_terminus(@request).should == :file
+      @object.select(@request).should == :file
     end
 
     it "should fail when a protocol other than :puppet or :file is used" do
       @request.stubs(:protocol).returns "http"
-      proc { @object.select_terminus(@request) }.should raise_error(ArgumentError)
+      proc { @object.select(@request) }.should raise_error(ArgumentError)
     end
 
     describe "and the protocol is 'puppet'" do
@@ -35,15 +35,15 @@ describe Puppet::FileServing::IndirectionHooks do
       it "should choose :rest when a server is specified" do
         @request.stubs(:protocol).returns "puppet"
         @request.expects(:server).returns "foo"
-        @object.select_terminus(@request).should == :rest
+        @object.select(@request).should == :rest
       end
 
       # This is so a given file location works when bootstrapping with no server.
       it "should choose :rest when the Settings name isn't 'puppet'" do
         @request.stubs(:protocol).returns "puppet"
-        @request.stubs(:server).returns "foo"
+        # We have to stub this because we can't set name
         Puppet.settings.stubs(:value).with(:name).returns "foo"
-        @object.select_terminus(@request).should == :rest
+        @object.select(@request).should == :rest
       end
 
       it "should choose :file_server when the settings name is 'puppet' and no server is specified" do
@@ -51,8 +51,7 @@ describe Puppet::FileServing::IndirectionHooks do
 
         @request.expects(:protocol).returns "puppet"
         @request.expects(:server).returns nil
-        Puppet.settings.expects(:value).with(:name).returns "puppet"
-        @object.select_terminus(@request).should == :file_server
+        @object.select(@request).should == :file_server
       end
     end
   end

programming_language: Ruby