The additional risk here is that installing a wheel is currently safe. IMO this proposal needs to be careful not to introduce any additional risks for a hypothetical user who runs pip install --only-binary :all:
.
The threat I’d be most concerned about here is a compromised wheel that contains the exact same code in it as the original wheel, but has a malicious LINKS
file added. That’s the easiest case for a user to miss, and so probably the most tempting target for an attacker.
However, I do agree that we shouldn’t get too obsessed with security. The context is still “a user instructs a program they are trusting to download a package they are trusting from a hosting service they trust, using protocols they trust, and then they are invoking code from the installed package without further checking on the integrity of that package”. That’s a lot of (quite possibly unwarranted!) trust…
What I think is important is to try to avoid adding features without a reasonable motivation for them. The most secure feature is the one that doesn’t exist, after all…
FWIW, I think there is a good motivation for supporting this PEP on all platforms - encouraging “only works on platform X” is problematic as it fragments the community, and makes building a working system that much harder. So I’m -1 on making this Unix-only unless it is only for support of a Unix-only capability like shared library aliases.
The problem is that on Windows, unlike Unix, whether symlinks are supported isn’t a property of the filesystem alone, but also depends on the user’s current rights. It’s perfectly possible for a user to be able to uninstall a package they previously installed, but unable to reinstall that exact same package into the exact same environment at a later date.
Also, on Windows, symlinks are less common, so tools are less likely to handle them correctly. For example the info-zip command line zip tool will copy a symlink into a zipfile as a directory:
> set-content a "Some text"
> new-item -type SymbolicLink -Target a b
> zip -9 c.zip a b
adding: a (172 bytes security) (stored 0%)
adding: b/ (stored 0%)
> unzip -l .\c.zip
Archive: ./c.zip
Length Date Time Name
--------- ---------- ----- ----
11 21/05/2024 15:36 a
0 01/01/1980 00:00 b/
--------- -------
11 2 files
7-zip fails to include symlinks, saying “WARNING: The directory name is invalid”. Git on Windows seems to treat symlinks as normal files containing the name of the target. These or other issues could result in backup solutions or development workflows being broken if symlinks are used too freely.
So I think there are both technical and “social” reasons for not treating Windows and Unix the same when it comes to symlink support. It may be that we have to accept some level of risk, and assume that if people use symlinks, they know how to deal with them, but that also means we should strive not to use symlinks more than necessary, or without sufficient visibility.