Commit 43deabf
authored
π fix(seed): verify sha256 of bundled wheels on load (#3119)
Security hardening. Bundled seed wheels were loaded straight off disk
and handed to pip without any integrity check. A corrupted or tampered
wheel sitting next to `embed/__init__.py` β whether from a botched
upgrade, a filesystem error, or a supply-chain compromise β would have
been silently installed into every new environment. π
The fix records the SHA-256 of every bundled wheel alongside
`BUNDLE_SUPPORT` in the generated `embed/__init__.py`, and verifies each
wheel the first time it is requested. Hashes are cached per wheel name
so the happy path keeps a single file read per interpreter run, and a
mismatch aborts with a clear `RuntimeError`. When virtualenv runs from a
zipapp the bytes are read straight from the archive entry, so the check
applies to both on-disk and zipapp layouts.
The hash table is produced by `tasks/upgrade_wheels.py` so future wheel
bumps stay in sync without manual bookkeeping. A new `--regen` mode lets
the generator rewrite the module from the wheels currently on disk
without re-downloading anything, which is how this PR produced the
initial table.1 parent 4e412b0 commit 43deabf
4 files changed
Lines changed: 336 additions & 103 deletions
File tree
- docs/changelog
- src/virtualenv/seed/wheels/embed
- tasks
- tests/unit/seed/wheels
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
47 | 73 | | |
48 | 74 | | |
49 | 75 | | |
50 | 76 | | |
51 | 77 | | |
| 78 | + | |
52 | 79 | | |
53 | 80 | | |
54 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
55 | 113 | | |
56 | 114 | | |
| 115 | + | |
57 | 116 | | |
58 | 117 | | |
59 | 118 | | |
| |||
0 commit comments