Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ static int ona_open(const char *path, int flags, mode_t mode, char *out_abs, siz
&& ((strcmp(abspath, "/proc") == 0 && strcmp(comp, "self") == 0)
|| (strcmp(abspath, "/dev") == 0 && strcmp(comp, "fd") == 0));
if (!namespace_pin && lst.st_uid != 0 && lst.st_uid != trusted_uid) {
rprintf(FERROR,
"refusing to follow a symlink owned by an untrusted user; "
"use --insecure-links locally or \"insecure links = yes\" in a "
"daemon module ONLY if every path component is trusted\n");
saved_errno = ELOOP;
goto out;
}
Expand Down
16 changes: 14 additions & 2 deletions testsuite/symlink-race-dest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,20 @@
os.symlink(outside, dest / 'sub') # attacker-owned dest component
os.lchown(dest / 'sub', ATT_UID, ATT_UID)

subprocess.run(rsync_argv('-a', f'{src}/sub/', f'{dest}/sub/'),
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
proc = subprocess.run(
rsync_argv('-a', f'{src}/sub/', f'{dest}/sub/'),
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
text=True,
)

if proc.returncode == 0:
test_fail("attacker-owned destination symlink was not rejected")
if "refusing to follow a symlink owned by an untrusted user" not in proc.stderr:
test_fail(
"untrusted destination symlink failure omitted the actionable "
f"diagnostic: {proc.stderr!r}"
)

escaped = sorted(p.name for p in outside.iterdir())
if escaped:
Expand Down
Loading