CVE-2007-4559 python: ensure sanity in our tarfiles
commit37406b9d97f123576c811b9fe22b39b02af62f83
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 23 Sep 2022 00:32:25 +0000 (23 12:32 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 4 Oct 2022 03:48:43 +0000 (4 03:48 +0000)
treecd56cbe5d8fc1cf150e9859ced06ed0c4682df9e
parent6a5d03e2f7bfa84eea1f1c44604ab70b1257d349
CVE-2007-4559 python: ensure sanity in our tarfiles

Python's tarfile module is not very careful about paths that step out
of the target directory. We can be a bit better at little cost.

This was reported in 2007[1], and has recently been publicised [2, for
example].

We were informed of this bug in December 2021 by Luis Alberto López
Alvar, but decided then that there were no circumstances under which
this was a security concern. That is, if you can alter the backup
files, you can already do worse things. But there is a case to guard
against an administrator being tricked into trying to restore a file
that isn't based on a real backup.

[1] https://nvd.nist.gov/vuln/detail/CVE-2007-4559
[2] https://www.theregister.com/2022/09/22/python_vulnerability_tarfile/

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15185

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Oct  4 03:48:43 UTC 2022 on sn-devel-184
python/samba/netcmd/domain_backup.py
python/samba/ntacls.py
python/samba/safe_tarfile.py [new file with mode: 0644]
python/samba/tests/domain_backup.py
python/samba/tests/domain_backup_offline.py
python/samba/tests/safe_tarfile.py [new file with mode: 0644]
selftest/tests.py