Skip to content

Fail closed when a locked hash cannot be checked - #11030

Merged
radoering merged 2 commits into
python-poetry:mainfrom
radoering:lockfile-hash-check
Aug 29, 2026
Merged

radoering merged 2 commits into
python-poetry:mainfrom
radoering:lockfile-hash-check

Conversation

@radoering

Copy link
Copy Markdown
Member

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

arpitjain099 and others added 2 commits August 29, 2026 18:35
Two layers bind an installed artifact to the hashes in poetry.lock, and an
index could skip both.

The chooser accepted any link that advertised no hash at all, without
comparing anything to the locked hashes, so 'no hash offered' was treated as
'accept' rather than 'compute and compare'. Removing that early accept lets
the link fall through to the existing calculate_sha256 path, which is what
the surrounding code already does for links advertising a different hash
type. A link whose computed hash matches the lock is still chosen.

The executor's post-download check only ran when the downloaded archive's
filename appeared in the lock's files list, so an artifact served under an
unlisted filename was never validated and its hash was never recorded. The
filename condition is gone; if the lock pins hashes, the archive is checked.
An archive the lock does not list now raises with that stated plainly, rather
than falling through the empty-known-hashes case into the less specific
'no usable hash type' message.

Both new tests fail without the corresponding change.

Signed-off-by: Arpit Jain <[email protected]>
Try links best-first, and stop as soon as one has a verified hash matching the lock. Verifying a hash requires a full download when the index does not provide hashes, so this avoids downloading every candidate when the first (best) one already matches.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the verification logic is wrong, an attacker-controlled or otherwise unverified distribution could be selected and installed, potentially executing arbitrary package code across affected installations without an obvious failure signal. Reverting prevents future instances but cannot undo code already installed or executed.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@radoering
radoering merged commit 1c9cd2f into python-poetry:main Aug 29, 2026
52 checks passed
mwalbeck pushed a commit to mwalbeck/docker-python-poetry that referenced this pull request Sep 6, 2026
This PR contains the following updates:

| Package | Update | Change | Pending |
|---|---|---|---|
| [poetry](https://github.com/python-poetry/poetry) ([changelog](https://python-poetry.org/history/)) | patch | `2.4.1` → `2.4.2` | `2.4.3` |

---

### Release Notes

<details>
<summary>python-poetry/poetry (poetry)</summary>

### [`v2.4.2`](https://github.com/python-poetry/poetry/blob/HEAD/CHANGELOG.md#242---2026-08-29)

[Compare Source](python-poetry/poetry@2.4.1...2.4.2)

##### Fixed

- Fix an issue where Poetry installs an artifact that is not listed in the lockfile when the package source does not provide a hash for this artifact ([#&#8203;11030](python-poetry/poetry#11030)).
- Fix a path traversal vulnerability when downloading files from a compromised URL and/or package source ([#&#8203;11029](python-poetry/poetry#11029)).
- Fix a path traversal vulnerability in sdist extraction on Python 3.10.0-3.10.12 and 3.11.0-3.11.4 that could allow malicious tarball files to write files outside the target directory ([#&#8203;11027](python-poetry/poetry#11027)).

</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 PR becomes conflicted, or you tick the rebase/retry checkbox.

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

---

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

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjAuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI2MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.walbeck.it/mwalbeck/docker-python-poetry/pulls/1760
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants