Skip to content

0.8.0

Choose a tag to compare

@hexblot hexblot released this 14 Sep 14:25
· 94 commits to main since this release
v0.8.0
abeb272

A feature release: the tool can now apply the fix it recommends, and open one pull request carrying
every fix it could verify. The default is unchanged and unchanged on purpose: without --apply nothing
in your project is written. It also says what it is doing while it works, after a first user on a large
lock file took several minutes of silent solving for a hang.

Upgrading from 0.7.0. Four of the security fixes below apply to code 0.7.0 shipped, and two of them
were rated P1 by the reviewer:

  • The advisory database was fetched with an IO object carrying the analysed project's authentication,
    and Composer reads TLS settings out of http-basic credentials, so a project could influence which
    certificates authenticate a publisher you chose.
  • A project could turn the advisory database off through extra.remediate.database, and it could do so
    around a --database-sha256 pin, which is meant to be the trust anchor.
  • --no-project-ignores discarded exceptions from your own configuration along with the project's.
  • A database this tool builds was created world-readable, though a build with --include may carry
    private advisories.

Also fixed for 0.7.0 users: a handled download failure printed Unhandled promise rejection … on
Composer 2.4 to 2.9, which is every supported version but the newest.

The new writing features had a fresh adversarial adoption assessment covering the action, the apply
path, the security boundary, the reports and the tests. Nine findings across it and its recheck are
answered, each with a test, and the reviewer confirmed them fixed. They are new all the same: read a
pull request the action opens before you merge it, as you would anyone's.

Added

  • It says what it is doing while it does it. A run now reports how many locked packages it matched,
    how many packages need fixing, and which one it is working on, with a running count of solver runs;
    a first run that has to fetch the advisory database says so before it starts. Those lines go to the
    error stream, so a report on standard output is still only the report, and -v still adds every
    candidate command as it is tried. Reported by the first user to run this on a large lock file, who
    reasonably took several minutes of silence for a hang.

  • A GitHub Action that opens one pull request with the fixes applied (Phase 5, complete).
    action.yml in this repository plans, applies with --apply --apply-no-install, and opens or
    updates a single pull request on one reused branch, rather than one pull request per package. It
    stops before touching anything when no finding has a verified fix, and again when the run changed
    neither the manifest nor the lock. The description is rendered by the new remediate:pr-body
    command from the JSON reports of the planning run and the applying run: which advisories closed,
    which survived and with what fix, what ran, and what the applying run warned about. It says plainly
    when a run changed the lock and closed nothing. Advisory text is escaped, since it is upstream data
    arriving in a rendered page. A fix that would edit composer.json is reported and not applied, since
    --apply refuses those without --apply-root-constraints.

  • --apply (Phase 5). The recommendation can now be run rather than only printed. It executes the
    command the report shows, in the project, with the project's own Composer, and then plans again, so
    what you read afterwards is the state the run left behind and not a prediction of it. composer.json
    and composer.lock are copied outside the project before anything runs and the report says where.
    It refuses when there is no verified command to run, when the recommendation would edit
    composer.json (--apply-root-constraints permits it), when those files changed while the plan was
    being computed, and when they are already modified in a git checkout (--apply-allow-dirty
    permits it). --apply-no-install writes the lock and leaves vendor/ alone, which is the shape a
    pull-request workflow wants. Nothing is applied without the flag: the default remains to recommend
    and write nothing.

  • Candidate builds its command from argument lists (requireArgumentLists(), updateArguments())
    that both the printed command and the applier use, so what a report promises and what --apply runs
    cannot drift apart.

Security

Answers to a third adversarial adoption review, this one of --apply and the shipped action. Seven
findings, each with a test.

  • The downloader carries the operator's credentials and nothing else. It was built from the
    caller's IO object, which holds authentication loaded from the analysed project; Composer reads TLS
    settings out of http-basic credentials, so a project could still decide which certificates
    authenticate a publisher the operator chose. A fresh IO is loaded from the operator's configuration
    alone.
  • A project cannot turn the advisory database off when a digest is pinned, and cannot turn it off
    quietly at all: extra.remediate.database set to composer or none is disclosed like any other
    source the project chooses, on the error stream as well as in the report, since a run that fails
    afterwards has no report to carry it.
  • --no-project-ignores keeps the operator's own exceptions. Which entries belong to the project
    is decided by reading the operator's configuration and the merged one and subtracting, not by asking
    Composer who wrote a key: it records one source per top-level key, so a project adding to
    config.audit.ignore made the operator's entries in that key look like its own, and dropping them
    discarded centrally approved exceptions.
  • The disclosures a run makes survive --apply. The second plan is a fresh object, so what the
    first run said about where advisories came from and who chose that used to vanish exactly where a
    reviewer is looking at an automated change.
  • The action builds its branch from the base, before planning. It planned and branched from
    whatever ref happened to be checked out, so a run on a feature branch carried unrelated commits into
    the pull request.
  • The action commits the two files it changed, not the whole index, so a file staged by an earlier
    workflow step cannot ride along in a security pull request.
  • The token authenticates git as well as the API. It is set on the remote rather than passed to
    the push, so fetches are authenticated too and --force-with-lease still has a remote-tracking ref
    to lease against.
  • The action's git calls override the checkout's authorization header. The token went into the
    remote's URL, but actions/checkout leaves an Authorization header in http.<server>/.extraheader
    and git sends that instead, so the server answered the checkout's identity and a supplied token had no
    effect on a push the checkout credential could not make. Every call that talks to the remote now
    resets that header for the duration of the call, changing nothing in the workflow's own configuration.
  • A project widening a scoped exception of the operator's is reported as the project's. Ownership
    compared rule names, so an operator excepting a package below one version and a project excepting the
    same package at any version looked like the same rule, and the widening passed undisclosed. Rules now
    carry their version constraint.
  • The action's script is a file, action/run.sh, with its own test harness
    (tests/Action/action-test.sh, composer test:action), which runs that exact script against a local
    git remote with stubbed composer and gh. Three of the findings above live in decisions the PHP
    suite cannot reach, and the harness caught a fourth defect introduced by the fix for one of them. What
    it does not cover is which credential a server actually receives, which needs a real HTTP server; it
    checks that the calls carry the header reset.

Answers to an Aikido scan of the workflows.

  • No job both runs third-party code and holds a credential that can change the repository. The
    advisory-database workflow is split: the build resolves Composer dependencies, runs this project's
    code and reads three upstream feeds with a read-only token, and hands its artefacts to a publish job
    that runs nothing but the attestation action and gh. Only that job has contents: write, and only
    it is bound to the advisory-db environment whose deployment-branch policy GitHub enforces. The CI
    matrix is read-only for the same reason, and the badges are pushed by a separate job that downloads
    two JSON files and nothing else. Composer installs run with --no-plugins --no-scripts in both
    workflows and in the GitLab template.
  • A database this tool builds is created readable by its owner alone (0600, in a 0700 directory
    when it has to create one). A build with --include carries private advisories, and the default path
    is a cache directory other users of the machine can often list; sharing one is now a deliberate copy.

Fixed

  • A handled download failure no longer prints an unhandled promise rejection. Composer's
    HttpDownloader::copy() discards the rejected promise before Composer 2.10, and react/promise reports
    it on stderr when that promise is collected, so a run that dealt with an unreachable publisher
    cleanly, or a mirror that publishes a .sha256 and no latest.json, printed
    Unhandled promise rejection with Composer\Downloader\TransportException: ... next to this tool's own
    explanation. Downloads now use the asynchronous form with a rejection handler, driven by a loop the
    locator owns, which behaves the same on every supported Composer version. Noticed in the output of a
    passing CI job.

Changed

  • Work reaches main through a pull request, one branch per unit of work; see the contributing page.
    CI follows: a push to main and a draft pull request run the single canonical job, and marking a
    pull request ready for review runs the full PHP and Composer matrices. Iterating in a draft therefore
    costs what a push used to, and the matrix is paid for once, when the work is done.