Skip to content

Commit 3e98ed4

Browse files
cfergeaugbraad
authored andcommitted
Issue #415 preflight: Don't download to /tmp/
We are currently downloading various binaries to /tmp with a well-known name, and (in the crc-driver-libvirt case), we are then making the file we downloaded suid. Since /tmp is world-writable, this can be abused by a local user racing with us, and overwriting crc-driver-libvirt after it's downloaded, but before it's made suid. This commit downloads the temporary files to ~/.crc/cache instead, which is safer as only the current user can write there. This is related to #415, even if the main goal is to avoid potential security issues.
1 parent c1bde93 commit 3e98ed4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/crc/preflight/preflight_checks_darwin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func checkVirtualBoxInstalled() (bool, error) {
5151

5252
func fixVirtualBoxInstallation() (bool, error) {
5353
logging.Debug("Downloading VirtualBox")
54-
// Download the driver binary in /tmp
55-
tempFilePath := filepath.Join(os.TempDir(), "virtualbox.dmg")
54+
// Download the virtualbox installer in ~/.crc/cache
55+
tempFilePath := filepath.Join(constants.MachineCacheDir, "virtualbox.dmg")
5656
_, err := dl.Download(virtualBoxDownloadURL, tempFilePath)
5757
if err != nil {
5858
return false, err

pkg/crc/preflight/preflight_checks_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ func checkMachineDriverLibvirtInstalled() (bool, error) {
245245

246246
func fixMachineDriverLibvirtInstalled() (bool, error) {
247247
logging.Debugf("Installing %s", libvirtDriverCommand)
248-
// Download the driver binary in /tmp
249-
tempFilePath := filepath.Join(os.TempDir(), libvirtDriverCommand)
248+
// Download the driver binary in ~/.crc/cache
249+
tempFilePath := filepath.Join(constants.MachineCacheDir, libvirtDriverCommand)
250250
_, err := download.Download(libvirtDriverDownloadURL, tempFilePath)
251251
if err != nil {
252252
return false, err

0 commit comments

Comments
 (0)