Skip to content

Commit 4dc5fff

Browse files
committed
fix(daemon): trust /home as a root-owned alias on FreeBSD
private_log_directory_path_copy resolves a small allowlist of trusted top-level aliases before its component-wise O_NOFOLLOW path walk (Darwin's /tmp -> /private/tmp and /var -> /private/var). FreeBSD commonly exposes /home as a symlink to /usr/home. Treat it as a trusted root-owned alias so log directory paths under /home resolve correctly during the secure path walk. Signed-off-by: Pedro Ramos <131530838+pr9000@users.noreply.github.com>
1 parent f6a4d7f commit 4dc5fff

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/daemon/ipc.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,12 +1336,13 @@ static bool private_log_base_name_valid(const char *base_name) {
13361336
}
13371337

13381338
static char *private_log_directory_path_copy(const char *directory_path) {
1339-
#ifdef __APPLE__
1339+
#if defined(__APPLE__) || defined(__FreeBSD__)
13401340
/* Darwin exposes the trusted top-level aliases /tmp -> /private/tmp and
1341-
* /var -> /private/var. Resolve only those root-owned aliases before the
1341+
* /var -> /private/var. FreeBSD exposes /home -> /usr/home (or usr/home).
1342+
* Resolve only those root-owned aliases before the
13421343
* component-wise O_NOFOLLOW walk. Canonicalizing the complete caller path
13431344
* would follow an attacker-controlled cache/log symlink and is forbidden. */
1344-
static const char *const aliases[] = {"/tmp", "/var"};
1345+
static const char *const aliases[] = {"/tmp", "/var", "/home"};
13451346
for (size_t index = 0; index < sizeof(aliases) / sizeof(aliases[0]); index++) {
13461347
const char *alias = aliases[index];
13471348
size_t alias_length = strlen(alias);

0 commit comments

Comments
 (0)