Skip to content

Commit 4bd549d

Browse files
committed
Check for embedded ".." in the expanded I/O log dir and file.
Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent 186f945 commit 4bd549d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

logsrvd/iolog_writer.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,23 @@ create_iolog_path(struct connection_closure *closure)
596596
logsrvd_conf_iolog_dir());
597597
goto bad;
598598
}
599+
if (contains_dot_dot(expanded_dir)) {
600+
sudo_warnx(U_("unable to expand iolog path %s: path traversal attack"),
601+
logsrvd_conf_iolog_dir());
602+
goto bad;
603+
}
599604

600605
if (!expand_iolog_path(logsrvd_conf_iolog_file(), expanded_file,
601606
sizeof(expanded_file), &path_escapes[0], &path_closure)) {
602607
sudo_warnx(U_("unable to expand iolog path %s"),
603608
logsrvd_conf_iolog_file());
604609
goto bad;
605610
}
611+
if (contains_dot_dot(expanded_file)) {
612+
sudo_warnx(U_("unable to expand iolog path %s: path traversal attack"),
613+
logsrvd_conf_iolog_file());
614+
goto bad;
615+
}
606616

607617
len = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", expanded_dir,
608618
expanded_file);

0 commit comments

Comments
 (0)