encukou
(Petr Viktorin)
11
The feature is in now Python 3.8-3.12, either released or planned for the next security update.
Unfortunately, I failed to backport it to 3.7.
I use os.path.realpath to ensure files stay “in” the destination (see code here).
Unfortunately, Python 3.7’s os.path.realpath function does not resolve symbolic links on Windows (GH-54158). Teaching it to do so involved dozens of lines of platform-specific code and a fix-up commit, so it doesn’t seem like something I can backport to 3.7 (or worse, maintain separately in tarfile).
So, I don’t have a good way to prevent symlink attacks on Windows.
Limiting PEP-706 features to non-Windows platforms would be quite involved, I can’t realistically do it and test properly.
Backporting as-is would mean hasattr(tarfile, 'data_filter') would lie about data_filter protecting you from symlink attacks. Since I expect libraries to drop their home-grown security precautions if data_filter is available, this would be dangerous.
So, I cannot backport to 3.7 in good conscience.
Full disclosure: I will backport it to Python 3.6 for Red Hat, where Windows symlinks aren’t a concern. The 3.7 patch is available for any other redistributor.
I’m sorry I couldn’t do it for everyone.
2 Likes