Skip to content

Commit 8dc2b93

Browse files
committed
More secure default server setting
Under some fairly obscure conditions, defaulting the server setting to 'puppet' can be a security concern. Because the worst case scenario involves a user accidentally running `puppet agent -t` on an untrusted network, this PR removes the default completely when non-root. Otherwise, it just prints a deprecation warning. Fixes voxpupuli/security-tracking#22
1 parent 1c17eb4 commit 8dc2b93

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

lib/puppet/defaults.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,8 +1650,19 @@ def self.initialize_default_settings!(settings)
16501650
:desc => "The root directory of devices' $confdir.",
16511651
},
16521652
:server => {
1653-
:default => "puppet",
1654-
:desc => "The primary Puppet server to which the Puppet agent should connect.",
1653+
:default => '', # use an empty string so dependent settings can resolve without crashing
1654+
:desc => "The primary Puppet server to which the Puppet agent should connect.",
1655+
:call_hook => :on_initialize_and_write,
1656+
:hook => proc do |value|
1657+
if value.empty?
1658+
if Puppet.features.root?
1659+
Puppet.deprecation_warning('OpenVox will not default to `server=puppet` as of version 9.0. Please update your configuration appropriately.')
1660+
Puppet.settings[:server] = 'puppet'
1661+
else
1662+
Puppet.deprecation_warning('"server" must be specified when running as a non-privileged user. (Did you mean to run as root?)')
1663+
end
1664+
end
1665+
end
16551666
},
16561667
:server_list => {
16571668
:default => [],

spec/unit/defaults_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
end
99
end
1010

11+
describe 'server' do
12+
it 'should default to `puppet` when root' do
13+
allow(Puppet.features).to receive(:root?).and_return(true)
14+
Puppet.initialize_settings
15+
expect(Puppet.settings[:server]).to eq('puppet')
16+
end
17+
18+
it 'should default to empty value when non-root' do
19+
expect(Puppet).to receive(:deprecation_warning)
20+
Puppet.initialize_settings
21+
expect(Puppet.settings[:server]).to eq('')
22+
end
23+
end
24+
1125
describe 'strict' do
1226
it 'should accept the valid value :off' do
1327
expect {Puppet.settings[:strict] = 'off'}.to_not raise_exception
@@ -146,7 +160,7 @@
146160

147161
describe "deprecated settings" do
148162
it 'does not issue a deprecation warning by default' do
149-
expect(Puppet).to receive(:deprecation_warning).never
163+
expect(Puppet).to receive(:deprecation_warning).with(/"server" must be specified when running as a non-privileged user/)
150164

151165
Puppet.initialize_settings
152166
end

0 commit comments

Comments
 (0)