Skip to content

Commit 57f7125

Browse files
committed
(PUP-10627) Add default file permissions 640 for last_run_summary.yaml
Due to security concerns, this commit downgrades file permissions for `last_run_summary.yaml` from `644` to `640`. This allows only file owner and its group access to it by default.
1 parent 09405d4 commit 57f7125

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

acceptance/tests/agent/last_run_summary_report.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,24 @@
5050
end
5151
end
5252

53-
step "Check if the 'last_run_summary.yaml' report file created has '0644' permissions" do
53+
step "Check if the 'last_run_summary.yaml' report file created has '0640' permissions" do
5454
if agent['platform'] =~ /windows/
5555
on(agent, "icacls #{File.join(publicdir, 'last_run_summary.yaml')}") do |result|
5656
# Linux 'Owner' premissions class equivalent
5757
assert_match('Administrator:(R,W', result.stdout)
5858
# Linux 'Group' permissions class equivalent
5959
assert_match('None:(R)', result.stdout)
6060
# Linux 'Public' permissions class equivalent
61-
assert_match('Everyone:(R)', result.stdout)
61+
assert_match('Everyone:(Rc,S,RA)', result.stdout)
62+
# According to icacls docs:
63+
# Rc = Read control
64+
# S = Synchronize
65+
# RA = Read attributes
66+
# More at https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/icacls
6267
end
6368
else
6469
on(agent, "ls -al #{publicdir}") do |result|
65-
assert_match(/rw-r--r--.+last_run_summary\.yaml$/, result.stdout)
70+
assert_match(/rw-r-----.+last_run_summary\.yaml$/, result.stdout)
6671
end
6772
end
6873
end
@@ -86,19 +91,24 @@
8691
end
8792
end
8893

89-
step "Check if the 'last_run_summary.yaml' report file was created in the new location and still has '0644' permissions" do
94+
step "Check if the 'last_run_summary.yaml' report file was created in the new location and still has '0640' permissions" do
9095
if agent['platform'] =~ /windows/
9196
on(agent, "icacls #{File.join(custom_publicdir, 'last_run_summary.yaml')}") do |result|
9297
# Linux 'Owner' premissions class equivalent
9398
assert_match('Administrator:(R,W', result.stdout)
9499
# Linux 'Group' permissions class equivalent
95100
assert_match('None:(R)', result.stdout)
96101
# Linux 'Public' permissions class equivalent
97-
assert_match('Everyone:(R)', result.stdout)
102+
assert_match('Everyone:(Rc,S,RA)', result.stdout)
103+
# According to icacls docs:
104+
# Rc = Read control
105+
# S = Synchronize
106+
# RA = Read attributes
107+
# More at https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/icacls
98108
end
99109
else
100110
on(agent, "ls -al #{custom_publicdir}") do |result|
101-
assert_match(/rw-r--r--.+last_run_summary\.yaml$/, result.stdout)
111+
assert_match(/rw-r-----.+last_run_summary\.yaml$/, result.stdout)
102112
end
103113
end
104114
end

lib/puppet/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ def self.initialize_default_settings!(settings)
18091809
:lastrunfile => {
18101810
:default => "$publicdir/last_run_summary.yaml",
18111811
:type => :file,
1812-
:mode => "0644",
1812+
:mode => "0640",
18131813
:desc => "Where puppet agent stores the last run report summary in yaml format."
18141814
},
18151815
:lastrunreport => {

0 commit comments

Comments
 (0)