VYPR
Moderate severityNVD Advisory· Published Oct 27, 2011· Updated Apr 29, 2026

CVE-2011-3871

CVE-2011-3871

Description

Puppet 2.7.x before 2.7.5, 2.6.x before 2.6.11, and 0.25.x, when running in --edit mode, uses a predictable file name, which allows local users to run arbitrary Puppet code or trick a user into editing arbitrary files.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
puppetRubyGems
>= 2.7.0, < 2.7.52.7.5
puppetRubyGems
< 2.6.112.6.11

Affected products

23
  • Puppetlabs/Puppet2 versions
    cpe:2.3:a:puppetlabs:puppet:2.7.0:*:*:*:*:*:*:*+ 1 more
    • cpe:2.3:a:puppetlabs:puppet:2.7.0:*:*:*:*:*:*:*
    • cpe:2.3:a:puppetlabs:puppet:2.7.1:*:*:*:*:*:*:*
  • cpe:2.3:a:puppet:puppet:0.25.0:*:*:*:*:*:*:*+ 20 more
    • cpe:2.3:a:puppet:puppet:0.25.0:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:0.25.1:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:0.25.2:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:0.25.3:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:0.25.4:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:0.25.5:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:0.25.6:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.0:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.1:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.10:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.2:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.3:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.4:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.5:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.6:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.7:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.8:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.6.9:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.7.2:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.7.3:*:*:*:*:*:*:*
    • cpe:2.3:a:puppet:puppet:2.7.4:*:*:*:*:*:*:*

Patches

2
343c7bd381b6

(#9792) Predictable temporary filename in ralsh.

https://github.com/puppetlabs/puppetDaniel PittmanSep 29, 2011via ghsa
1 file changed · +17 10
  • lib/puppet/application/resource.rb+17 10 modified
    @@ -85,18 +85,25 @@ def main
         end.map(&format).join("\n")
     
         if options[:edit]
    -      file = "/tmp/x2puppet-#{Process.pid}.pp"
    +      require 'tempfile'
    +      # Prefer the current directory, which is more likely to be secure
    +      # and, in the case of interactive use, accessible to the user.
    +      tmpfile = Tempfile.new('x2puppet', Dir.pwd)
           begin
    -        File.open(file, "w") do |f|
    -          f.puts text
    -        end
    -        ENV["EDITOR"] ||= "vi"
    -        system(ENV["EDITOR"], file)
    -        system("puppet -v #{file}")
    +        # sync write, so nothing buffers before we invoke the editor.
    +        tmpfile.sync = true
    +        tmpfile.puts text
    +
    +        # edit the content
    +        system(ENV["EDITOR"] || 'vi', tmpfile.path)
    +
    +        # ...and, now, pass that file to puppet to apply.  Because
    +        # many editors rename or replace the original file we need to
    +        # feed the pathname, not the file content itself, to puppet.
    +        system('puppet -v ' + tmpfile.path)
           ensure
    -        #if FileTest.exists? file
    -        #    File.unlink(file)
    -        #end
    +        # The temporary file will be safely removed.
    +        tmpfile.close(true)
           end
         else
           puts text
    
d76c30935460

(#9792) Predictable temporary filename in ralsh.

https://github.com/puppetlabs/puppetDaniel PittmanSep 29, 2011via ghsa
1 file changed · +17 10
  • lib/puppet/application/resource.rb+17 10 modified
    @@ -190,18 +190,25 @@ def main
         end.map(&format).join("\n")
     
         if options[:edit]
    -      file = "/tmp/x2puppet-#{Process.pid}.pp"
    +      require 'tempfile'
    +      # Prefer the current directory, which is more likely to be secure
    +      # and, in the case of interactive use, accessible to the user.
    +      tmpfile = Tempfile.new('x2puppet', Dir.pwd)
           begin
    -        File.open(file, "w") do |f|
    -          f.puts text
    -        end
    -        ENV["EDITOR"] ||= "vi"
    -        system(ENV["EDITOR"], file)
    -        system("puppet -v #{file}")
    +        # sync write, so nothing buffers before we invoke the editor.
    +        tmpfile.sync = true
    +        tmpfile.puts text
    +
    +        # edit the content
    +        system(ENV["EDITOR"] || 'vi', tmpfile.path)
    +
    +        # ...and, now, pass that file to puppet to apply.  Because
    +        # many editors rename or replace the original file we need to
    +        # feed the pathname, not the file content itself, to puppet.
    +        system('puppet -v ' + tmpfile.path)
           ensure
    -        #if FileTest.exists? file
    -        #    File.unlink(file)
    -        #end
    +        # The temporary file will be safely removed.
    +        tmpfile.close(true)
           end
         else
           puts text
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

14

News mentions

0

No linked articles in our index yet.