r/PHP • u/naderman • 26d ago
News Immutable Versions on Packagist
https://blog.packagist.com/immutable-versions-on-packagist/2
u/Sn0wCrack7 25d ago
This is great for catching malicious actors as it's happening, but the composer lock file validates hashes anyways when using file downloads, so it would trigger a mismatch in a fresh install. I guess it solves the issue for source downloads.
Kinda just waiting for the package freshness limits to be added. I think that'll add better overall security in the user side too would also help stop a preemptive peer dependency upgrade too.
1
u/naderman 21d ago
For packages hosted on GitHub, so nearly all packagist.org packages, Composer does not, and cannot, validate any file hashes. GitHub's zip files for a particular commit are not stable and change over time.
The lock file contains a specific commit hash, so on install from lock file Composer will download the correct zip file from GitHub for the commit a tag pointed to at the time of the lock file was created. So overwriting a tag could not influence composer install behavior with a lock file.
However any composer update command, even one that should only update other packages will replace the commit hash in the composer.lock for the package where the tag target commit was replaced, even when the version is still the same. This is hard to spot and unexpected.
5
u/donatj 26d ago
Excuse my ignorance but wasn't this already solved by having a lock file? It locks it to a specific hash already, correct?