1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-13 11:58:26 -06:00

Linux/FreeBSD: Add absolute paths for system binaries to prevent path hijacking (CVE-2024-54187, collaboration with SivertPL @__tfr)

This commit fixes a critical security vulnerability where VeraCrypt could be tricked into executing malicious binaries with elevated privileges. The vulnerability has two severe implications:

1. When sudo's secure_path option is disabled, attackers could execute malicious binaries with root privileges by placing them in user-writable PATH directories (e.g., making "sudo mount" execute a malicious mount binary)

2. By placing a malicious sudo binary in PATH, attackers could intercept and steal the user's password when VeraCrypt prompts for sudo authentication

The vulnerability allowed attackers to place malicious binaries in user-writable directories that appear in PATH before system directories, potentially leading to privilege escalation and credential theft.

Key changes:
- Implement FindSystemBinary() to locate executables in secure system paths
- Replace all relative binary paths with absolute paths for system commands
- Add security checks for executable permissions
- Update process execution to use absolute paths for:
  * sudo
  * mount
  * fsck
  * terminal emulators
  * file managers
  * system utilities (hdiutil, mdconfig, vnconfig, lofiadm)

The fix ensures all system binaries are called using their absolute paths from secure system directories, preventing both privilege escalation through PATH manipulation and password theft through sudo hijacking.

Security: CVE-2024-54187
This commit is contained in:
Mounir IDRASSI
2025-01-11 17:26:03 +01:00
parent 1b35abb191
commit 2cca2e1daf
9 changed files with 226 additions and 99 deletions

View File

@@ -47,7 +47,7 @@ namespace VeraCrypt
try
{
Process::Execute ("hdiutil", args);
Process::Execute ("/usr/bin/hdiutil", args);
}
catch (ExecutedProcessFailed &e)
{
@@ -84,7 +84,7 @@ namespace VeraCrypt
{
try
{
Process::Execute ("umount", args);
Process::Execute ("/usr/bin/umount", args);
break;
}
catch (ExecutedProcessFailed&)
@@ -114,7 +114,7 @@ namespace VeraCrypt
else
args.push_back ("/System/Applications/Utilities/Disk Utility.app");
Process::Execute ("open", args);
Process::Execute ("/usr/bin/open", args);
}
void CoreMacOSX::MountAuxVolumeImage (const DirectoryPath &auxMountPoint, const MountOptions &options) const
@@ -190,7 +190,7 @@ namespace VeraCrypt
{
try
{
xml = Process::Execute ("hdiutil", args);
xml = Process::Execute ("/usr/bin/hdiutil", args);
break;
}
catch (ExecutedProcessFailed &e)
@@ -233,7 +233,7 @@ namespace VeraCrypt
args.push_back (volImage);
args.push_back ("-force");
Process::Execute ("hdiutil", args);
Process::Execute ("/usr/bin/hdiutil", args);
}
catch (ExecutedProcessFailed&) { }
throw;