Skip to content

Commit f8a8321

Browse files
authored
Merge pull request #602 from Dstack-TEE/issue/557-runtime-event-log-fs-perms
Restrict runtime event log permissions
2 parents 9a5b3e4 + d30027e commit f8a8321

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cc-eventlog/src/runtime_events.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,18 @@ impl RuntimeEvent {
6464
.context("failed to get event log directory")?;
6565
fs::create_dir_all(logfile_dir).context("failed to create event log directory")?;
6666

67-
let mut logfile = fs::OpenOptions::new()
68-
.append(true)
69-
.create(true)
67+
let mut options = fs::OpenOptions::new();
68+
options.append(true).create(true);
69+
70+
// Restrict runtime event log visibility and writability to the owner (root).
71+
// This avoids other processes in the CVM tampering with or reading the log.
72+
#[cfg(unix)]
73+
{
74+
use fs_err::os::unix::fs::OpenOptionsExt;
75+
options.mode(0o600);
76+
}
77+
78+
let mut logfile = options
7079
.open(logfile_path)
7180
.context("failed to open event log file")?;
7281

0 commit comments

Comments
 (0)