Skip to content

Do not remove files outside the venv on uninstall#18942

Merged
konstin merged 8 commits intomainfrom
konsti/better-venv-validation
Apr 9, 2026
Merged

Do not remove files outside the venv on uninstall#18942
konstin merged 8 commits intomainfrom
konsti/better-venv-validation

Conversation

@konstin
Copy link
Copy Markdown
Member

@konstin konstin commented Apr 9, 2026

Check that only files inside the installation scheme can be removed when uv uninstalls a package. This fixes a bug where uv would try to remove arbitrary files due to a malformed or malicious RECORD file in a wheel. For venvs, the installation prefix is the entire venv, as .data/data allows wheels to write to the entire venv, so all files in the venv can also be removed.

This is both a correctness fix (uv should never remove files outside its domain) and a low severity security fix, where a malicious wheel could remove a user's files during uninstallation, such as a uv sync that upgrades the package version. Note that this requires an attacker having control over the wheel, which also allows them to modify arbitrary Python code. There are no known cases of wheels actually referencing files outside the installation scheme in their RECORD.

Check that only files inside the installation scheme can be removed when uv uninstalls a package. This fixes a bug where uv would try to remove arbitrary files due to a malformed or malicious RECORD file in a wheel. For venvs, the installation prefix is the entire venv, as `.data/data` allows wheels to write to the entire venv, so all files in the venv can also be removed.

This is both a correctness fix (uv should never remove files outside its domain) and a low severity security fix, where a malicious wheel could remove a user's files during uninstallation, such as a `uv sync` that upgrades the package version. Note that this requires an attacker having control over the wheel, which also allows them to modify arbitrary Python code. There are no known cases of wheels actually referencing files outside the installation scheme in their RECORD.
@konstin konstin added the bug Something isn't working label Apr 9, 2026
@konstin konstin enabled auto-merge (squash) April 9, 2026 08:58
@konstin konstin disabled auto-merge April 9, 2026 08:59
@konstin konstin changed the title Validate and heal RECORD during installation Do not remove files outside the venv on uninstall Apr 9, 2026
@konstin konstin enabled auto-merge (squash) April 9, 2026 09:00
@konstin konstin merged commit a0e461a into main Apr 9, 2026
80 checks passed
@konstin konstin deleted the konsti/better-venv-validation branch April 9, 2026 10:18
naveenOnarayanan pushed a commit to doppelxyz/uv that referenced this pull request Apr 9, 2026
Check that only files inside the installation scheme can be removed when
uv uninstalls a package. This fixes a bug where uv would try to remove
arbitrary files due to a malformed or malicious RECORD file in a wheel.
For venvs, the installation prefix is the entire venv, as `.data/data`
allows wheels to write to the entire venv, so all files in the venv can
also be removed.

This is both a correctness fix (uv should never remove files outside its
domain) and a low severity security fix, where a malicious wheel could
remove a user's files during uninstallation, such as a `uv sync` that
upgrades the package version. Note that this requires an attacker having
control over the wheel, which also allows them to modify arbitrary
Python code. There are no known cases of wheels actually referencing
files outside the installation scheme in their RECORD.
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Apr 15, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [uv](https://github.com/astral-sh/uv) | patch | `0.11.5` → `0.11.6` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (uv)</summary>

### [`v0.11.6`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0116)

[Compare Source](astral-sh/uv@0.11.5...0.11.6)

Released on 2026-04-09.

This release resolves a low severity security advisory in which wheels with malformed RECORD entries could delete arbitrary files on uninstall. See [GHSA-pjjw-68hj-v9mw](GHSA-pjjw-68hj-v9mw) for details.

##### Bug fixes

- Do not remove files outside the venv on uninstall ([#&#8203;18942](astral-sh/uv#18942))
- Validate and heal wheel `RECORD` during installation ([#&#8203;18943](astral-sh/uv#18943))
- Avoid `uv cache clean` errors due to Win32 path normalization ([#&#8203;18856](astral-sh/uv#18856))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMTAuOCIsInVwZGF0ZWRJblZlciI6IjQzLjExMC44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant