Release tags have not been moved

Checks whether any of the package's version tags have been moved to different code after they were published.
category
security
weight
3

How Plumb checks this

What is inspected, and how the result is decided.

A version number is a promise that the code behind it will not change. When a maintainer moves a version tag to a different commit, people who install that version afterwards get different code than people who installed it before, and nothing tells them. Moving tags is also how an attacker who takes over a maintainer account would quietly change a release people already trust. A broken release should be fixed by publishing a new version, never by moving its tag.

Each time Plumb scans a package it records the commit that Packagist lists for every tagged version, and notes every time one of those commits changes. This works the same way on every source host.

The check passes when Plumb has never seen a version tag move, or when the most recent move is at least 12 months old. Every move counts, even one made minutes after a release. A move fails the check for its first 3 months, then earns a quarter of the credit, half after 6 months, and three quarters after 9 months. A newer move starts the count again. The check is not applicable when the package has no tagged versions.

Doing it well

Why this matters

A version number is a promise: 2.1.0 means the same code for everyone, forever. Composer finds that code through a Git tag, and on most hosts a tag can be moved to a different commit at any time.

When a tag moves, people who installed the version before and people who install it after get different code under the same number. Lock files that recorded the old commit stop matching, mirrors and caches disagree, and anyone who reviewed the release reviewed something that no longer exists. Moving a tag is also exactly how an attacker with a stolen maintainer account would change a trusted release without anyone noticing.

What good looks like

  • A version tag, once published, never changes.
  • A broken release is fixed by publishing a new version, such as 2.1.1, never by moving 2.1.0.
  • Release scripts never force-push tags.

How to do it

Release again instead of re-tagging

If you tagged the wrong commit or forgot a file, leave the tag alone and publish the next patch version. It costs a version number and nothing else. Note the problem in the release notes if it helps your users.

Remove force pushes from your tooling

Search your release scripts, Makefiles, and CI workflows for git tag -f, git tag --force, git push --force --tags, and git push -f origin <tag>, and remove them.

Lock tags where your host allows it

  • GitHub: turn on immutable releases in Settings, General, Releases, and publish every version as a release. Its tag can then never be moved.
  • GitHub: a tag ruleset that restricts updates and deletions blocks moves for tags without a release.
  • GitLab: add a protected tag rule, such as v*, under Settings, Repository, Protected tags.

Things to watch for

  • Retried release jobs. Some release tools delete and recreate the tag when a job is retried. Make retries publish a new version instead.
  • If a tag was moved anyway. Point it back at the commit it was originally released from as soon as you can, so new installs get the code people reviewed. If you did not move it yourself, treat it as a compromised account: revoke tokens and keys, check recent pushes, and tell your users which versions were affected. Publish any fix as a new version.
  • Mirrors. If your repository is mirrored from another host, a moved tag at the source is pushed to the mirror. Lock tags where releases are created.
  • Deleting and recreating. Deleting a tag and pushing a new one with the same name moves it just the same.

Further reading