Verify backup signature on self-update --rollback#12918
Merged
Conversation
API Surface ChangesIf any of the additions below are not intended as public API, mark them with New API SurfaceMethods
Modified API SurfaceMethods
|
self-update --rollback restored the newest *-old.phar backup from data-dir without verifying its signature. On systems where data-dir/COMPOSER_HOME is writable by other users, someone could plant a malicious backup that a privileged --rollback would then install over composer.phar. Rollback now downloads the published signature for the backed-up version and verifies the backup against it (reusing the existing self-update verification logic, extracted into verifyPhar()), aborting on a mismatch or an unfetchable signature. Snapshot/dev backups have no published signature, so verification is skipped with a warning and an interactive confirmation prompt. Rollback also warns (and prompts when interactive) if data-dir or the backup file is owned by another user or writable by others, and the docs now note that data-dir and COMPOSER_HOME must be treated as trusted, only-owner-writable locations.
8c64bff to
2322269
Compare
PrinsFrank
approved these changes
Jun 3, 2026
Contributor
PrinsFrank
left a comment
There was a problem hiding this comment.
Nice! I like the very thorough fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
composer self-update --rollbackrestored the newest*-old.pharbackup fromdata-dirand installed it overcomposer.pharwithout verifying its signature —rollback()only ranvalidatePhar()(a structural Phar parse), unlike the normal update path which verifies against the published signature.On a system where
data-dir/COMPOSER_HOMEis writable by other (less-privileged) users, someone could plant a malicious*-old.phar; a privileged user runningself-update --rollbackwould then install it over the composer binary, leading to code execution as that user. The preconditions make this low severity, but it's cheap to close.