mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-09-14 14:18:23 -04:00
The TOCTOU / symlink-race suite for the secure resolver and operator-supplied paths: chdir/chmod/rename/mknod/source/dest symlink races, relative make_path and symlinked-parent cases, the operator-path matrix (--temp/partial/backup-dir, alt-dest basis, files-from, log-file, insecure-links), and the admin-file opens (--password-file / daemon secrets / config / log-file / early-input symlinks), plus the daemon module-confinement and chroot inner-module cases. Co-authored-by: Omar Elsayed <omarelsayed161@gmail.com>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# --files-from symlink policy matrix (also covers the shared open site used by
|
|
# --include-from / --exclude-from / --filter merge in exclude.c / options.c).
|
|
# Already refuses a foreign-owned symlink but does not honor --insecure-links --
|
|
# RED on the insecure cells.
|
|
|
|
import subprocess
|
|
|
|
from rsyncfns import rsync_argv, run_symlink_matrix, plant_operator_symlink
|
|
|
|
|
|
def case(ctx):
|
|
src = ctx.base / 'src'
|
|
dest = ctx.base / 'dest'
|
|
src.mkdir()
|
|
dest.mkdir()
|
|
(src / 'sentinel').write_text("X\n")
|
|
opt, victim = plant_operator_symlink(ctx, ctx.base, kind='file')
|
|
victim.write_text("sentinel\n") # attacker-controlled transfer list
|
|
extra = ['--insecure-links'] if ctx.insecure else []
|
|
subprocess.run(
|
|
rsync_argv('-a', f'--files-from={opt}', *extra, 'src/', 'dest/'),
|
|
cwd=str(ctx.base), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
# Followed == rsync read the out-of-tree list and transferred its named file.
|
|
return (dest / 'sentinel').exists()
|
|
|
|
|
|
run_symlink_matrix('--files-from', case)
|
|
print("--files-from symlink policy matrix: enforced")
|