Skip to content

Reject TLS connections presenting distrusted intermediate certificates - #13146

Merged
Seldaek merged 6 commits into
composer:mainfrom
Seldaek:tls-chain-denylist
Oct 21, 2026
Merged

Seldaek merged 6 commits into
composer:mainfrom
Seldaek:tls-chain-denylist

Conversation

@Seldaek

@Seldaek Seldaek commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Composer prefers the system CA store, which may still trust the roots of the compromised eMudhra intermediates (see https://emudhra.we-have-a-problem.com/). This checks the chain presented by the server against CaBundle::findDistrustedCertificate() and rejects the connection if it contains one of them.

  • PHP 8.4+ with curl: checked in CURLOPT_PREREQFUNCTION, after the TLS handshake but before the request is sent. Curl keeps aborted connections in its pool and only exposes the chain on the request that opened the connection, so the host is remembered as distrusted for the rest of the process.
  • Older PHP / streams: checked once the response comes in, the response is rejected and a warning is printed that the request (and any credentials it carried) was already sent. Subsequent requests to that host are blocked before being sent.

A SecurityException is thrown rather than a TransportException, so code that falls back on transport errors (VCS drivers falling back to cloning, alternate dist URLs, optional repo files, ...) does not swallow it. ComposerRepository and VcsRepository also rethrow it from their catch-all fallbacks.

Overhead is ~0.3ms per new TLS connection (nothing on reused ones). certinfo is excluded from the per-tick progress comparison so enabling CURLOPT_CERTINFO does not make every tick copy and compare the full chain.

Requires composer/ca-bundle 1.6.0 (composer/ca-bundle#153).

The system CA store may still trust the roots of the compromised eMudhra
intermediates, so the chain presented by the server is checked against
composer/ca-bundle's denylist. On PHP 8.4+ with curl this happens before the
request is sent, otherwise only afterwards with a warning that credentials may
have leaked.
@private-packagist

Copy link
Copy Markdown
Contributor

composer.lock

Package changes

Package Operation From To About
composer/ca-bundle upgrade 1.5.14 1.6.0 diff

Settings · Docs · Powered by Private Packagist

@Seldaek
Seldaek marked this pull request as ready for review October 20, 2026 21:15
@Seldaek Seldaek added this to the 2.11 milestone Oct 20, 2026
@Seldaek
Seldaek merged commit 66c06e8 into composer:main Oct 21, 2026
24 checks passed
noahd1 added a commit to qltysh/qlty that referenced this pull request Oct 28, 2026
#2974)

The CLI installs Composer once, into
`~/.qlty/cache/tools/composer/generic-<hash>`, and never replaces it.
That directory name is the same on every machine and every CLI release,
so a machine keeps the Composer it first installed. This PR pins
Composer to 2.10.3 and puts the pin in the cache keys, so changing it
moves every machine to the new Composer, the way a runtime bump moves
Node or Python. PHP plugins are also keyed on the major and minor
version of the system PHP.

> [!IMPORTANT]
> This PR does not fix the eMudhra exposure yet. Composer 2.10.3, the
newest stable release, has neither part of the upstream fix (see [What
this doesn't fix yet](#what-this-doesnt-fix-yet)). The fix reaches
machines only after Composer ships a stable release with it, likely
2.11.0, and `COMPOSER_VERSION` moves to that release. Until then, this
PR only adds the pin and the cache keys that let that bump reach every
machine.

Part of qltysh/qltysh#1187.

## Problem

On Windows, and on Linux hosts without a system CA bundle, Composer
checks certificates against the Mozilla list bundled in its phar. A
Composer cached long ago keeps an old list. Upstream fixed the
[compromised eMudhra
intermediates](https://emudhra.we-have-a-problem.com/) in two parts:
composer/ca-bundle 1.6.0 and a chain check in Composer itself. Once a
stable Composer ships both, machines need to move to it without anyone
clearing caches by hand.

## What changed

- **Pinned Composer.** `COMPOSER_VERSION` is 2.10.3, the newest stable
release. The installer runs with `--version=2.10.3`, so it downloads
that release and verifies its signature, or fails. npm, pip and gem have
no separate pin either; each comes with its pinned runtime, so this
follows the same model.
- **Cache keys.** Composer installs into `composer/2.10.3-<hash>`. Each
PHP plugin's cache key now includes Composer's, so changing the pin
reinstalls Composer and every PHP plugin.
- **System PHP version.** The PHP runtime's cache key includes the major
and minor version of the `php` on `PATH`, read once per run with `php
-r`. Every PHP plugin's key includes the runtime's. Plugins are
installed with `composer require`, which picks dependencies for the PHP
that runs it, so a move from 8.3 to 8.4 reinstalls the plugins. Patch
releases and loaded extensions don't change the key. If `php` can't be
run, the key uses a placeholder and the install fails as before.
- **When Composer is set up.** Composer is now set up before each PHP
plugin install instead of during the PHP runtime install. A PHP runtime
installed by an earlier CLI is already marked done, so its install step
would never set up the new Composer directory.

Old `generic-*` directories and the previous plugin directories stay on
disk, unused.

## What this costs

- Upgrading the CLI reinstalls Composer and every PHP plugin on the
first run, and again whenever the pin moves or the machine's PHP minor
version changes. That run has to reach getcomposer.org and Packagist, so
a machine that is offline or behind a firewall that blocks those hosts
fails until it can reach them.
- Runs with a PHP plugin enabled make one `php` call to read the
version, about 60 ms on macOS arm64.
- Since 2.9.0 (2025-11-13), Composer refuses to install package versions
that have security advisories. Machines whose cached Composer predates
2.9.0 now reinstall their PHP plugins under 2.10.3, so a plugin version
pinned in `qlty.toml` that has an advisory fails to install. For
example, `php-codesniffer` 3.13.5 fails with `PKSA-rdkp-vv9z-mjkg`.
Machines with no cached Composer already get the newest stable release
and already fail on those versions today. The way back is to move the
plugin to a version without an advisory; the default plugin versions
install. Composer's `COMPOSER_NO_SECURITY_BLOCKING` opt-out doesn't
help, because the CLI passes only `HOME` and the proxy variables to
installs.
- PHP older than 7.2.5 can't run Composer 2.10.3. The unpinned installer
used to fall back to the 2.2 LTS release there.

## What this doesn't fix yet

Composer 2.10.3 has neither part of the upstream fix:

- **The bundle.** Its phar bundles composer/ca-bundle 1.5.12 (Mozilla
data from 2026-05-14), which still contains `emSign ECC Root CA - G3`.
[ca-bundle
1.6.0](https://github.com/composer/ca-bundle/releases/tag/1.6.0) removes
that root and adds `CaBundle::findDistrustedCertificate()`, which
matches the eight compromised intermediates by public-key hash.
- **The chain check.** Sectigo's AAA Certificate Services root also
cross-signed the intermediates, so removing the emSign root doesn't stop
them on a trust store that trusts Sectigo's root.
[composer/composer#13146](composer/composer#13146)
checks every new TLS chain against that list. With PHP 8.4+ and curl it
drops the connection before sending the request. On older PHP, or
without curl, it catches the chain only after the request has gone out.

Because of the cross-signing, hosts that use a system CA store are
exposed too if that store trusts Sectigo's root or the emSign root. The
exposure isn't limited to Windows and bundle-less Linux hosts.

Composer 2.11.0-RC1 (2026-10-22) has both parts. The newest stable
release is still 2.10.3, and Composer has no 2.10 maintenance branch, so
the stable fix will likely be 2.11.0. The follow-up is to move
`COMPOSER_VERSION` to it once it ships.

## Testing

**End to end, macOS arm64, PHP 8.4.8**, in a scratch `HOME` and repo
with php-codesniffer 3.13.6:

| Run | What the CLI did |
|---|---|
| Released 0.660.0 | Created `composer/generic-42cc848a9f5e`,
`php/8.3.7-12a5d18ee896` and `php-codesniffer/3.13.6-7b1c3d4ae3cb` |
| This branch, first run | Installed Composer 2.10.3 into
`composer/2.10.3-16155ab30ac5`, then created a new PHP runtime directory
and reinstalled php-codesniffer under a new key. It reported the
expected issue. |
| This branch, second run | Created nothing new |
| This branch, `php` wrapper reporting 8.3 | Created a new PHP runtime
directory and reinstalled php-codesniffer. Composer was left as it was.
|
| This branch, back on 8.4 | Reused the 8.4 directories |

**Unit tests** cover the pinned version in Composer's cache directory,
`pre_install` running the installer with `--version`, and reading the
PHP version from `php -r` output, including after a startup warning.

**Repo checks:** `cargo check`, `qlty fmt` and `qlty check --level=low`
reported nothing, and `cargo test` passed.

Not tested here: Windows, and the PHP plugin test suites. CI runs those.

This overlaps with #2947 in `php.rs` and `composer.rs`. Both
add `PhpPackage::pre_install` and a `PhpPackage::composer()` helper, and
both change `Php::update_hash`. With managed PHP the version is already
in the key through the download URL, so the system PHP check would apply
only to `php = "system"`.

Proposed release note for this CLI version:

> PHP plugins reinstall once on the first run after upgrading, and again
whenever the system PHP moves to a new minor version. A PHP plugin
pinned to a version with a known security advisory no longer installs;
move it to a newer version in `qlty.toml`. Very old PHP releases can no
longer set up Composer, so PHP plugins don't install on them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
noahd1 added a commit to qltysh/qlty that referenced this pull request Oct 29, 2026
Part of #2981 and qltysh/qltysh#1187.

## Problem

The CLI pins Composer 2.10.3. Its phar bundles composer/ca-bundle
1.5.12, which still contains `emSign ECC Root CA - G3`, the root that
the [compromised eMudhra
intermediates](https://emudhra.we-have-a-problem.com/) chain to.
Composer checks certificates against that bundle on Windows and on Linux
hosts without a system CA bundle. 2.10.3 also lacks the check that
rejects those intermediates when a system store trusts the Sectigo root
that cross-signed them.

## What changed

- **Composer 2.11.0.** `COMPOSER_VERSION` moves to 2.11.0, which
Composer released as stable on 2026-10-29. It bundles ca-bundle 1.6.0,
which drops the emSign root. It also includes
[composer/composer#13146](composer/composer#13146),
which rejects TLS connections that present the compromised intermediates
even when the system store trusts their roots. Since
[#2974](#2974), the pin is part of
Composer's directory and of every PHP plugin's cache key. Each machine
installs 2.11.0 and reinstalls its PHP plugins on the next run, with no
cache clearing.

This is the whole change. The first revision also added test seams for
the cache keys. They move to a follow-up PR, so this one stays a
one-line change and merges cleanly next to #2982.

## Checking the 2.11.0 phar

The phar was downloaded from getcomposer.org, and files were read
through `phar://` without running it. 2.10.3 was checked the same way as
a control.

| Check | 2.10.3 | 2.11.0 |
|---|---|---|
| SHA-256 matches getcomposer.org's published checksum | yes | yes |
| SHA-256 matches the GitHub release asset digest | not checked | yes |
| composer/ca-bundle version | 1.5.12 | 1.6.0 |
| Mozilla data date in `cacert.pem` | 2026-05-14 | 2026-10-20 |
| Contains `emSign ECC Root CA - G3`, by name or by SHA-256
`86:A1:EC:BA:…:6B:BE:6B` | yes | no |

The 2.11.0 phar's SHA-256 is
`9674f12a2a181100d889ebfd0b4510805b3e94cea57869b14b383753d602599b`.

## What this costs

- Upgrading the CLI reinstalls Composer and every PHP plugin on the
first run. That run has to reach getcomposer.org and Packagist.

Composer 2.11 needs PHP 7.2.5 or later, the same as 2.10.3. Two other
2.11 changes reach PHP plugin installs only through the `config` section
of a repository's `composer.json`, which `package_file` installs pass
through. The new `cooldown` policy is off by default, so it doesn't hold
back pinned plugin versions unless a repository turns it on. The removed
`source-fallback` option was already off by default in 2.10.3.

## Testing

- `cargo test -p qlty-check --lib` passes (287 tests).
- **End to end, macOS arm64, PHP 8.4.8.** The run used a scratch `HOME`
and a repo with php-codesniffer 3.13.6. It ran on the first revision of
this branch, whose production code is the same as this one's.

| Run | What the CLI did |
|---|---|
| Released 0.663.0 | Installed Composer 2.10.3 into
`composer/2.10.3-16155ab30ac5` and php-codesniffer into
`3.13.6-e5c976f326e7`. Reported 4 issues. |
| This branch, same `HOME` | Installed Composer 2.11.0 into
`composer/2.11.0-4eb54323e421`. The phar matches the published checksum.
Reinstalled php-codesniffer into `3.13.6-2cb25c425f24` with that
Composer. Kept the PHP runtime directory. Reported the same 4 issues. |
| This branch, again | Reused both directories. Reported the same 4
issues. |

## Left open

- After the release that ships this pin, record it and its Composer
version on qltysh/qltysh#1187.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Nov 4, 2026
Composer 2.5.8 bundles composer/ca-bundle 1.3.5, which still contains
the emSign ECC Root CA - G3 and AAA Certificate Services roots to which
the compromised eMudhra intermediate CAs chain ([1]).

Composer 2.11.0 updates composer/ca-bundle to 1.6.0, which no longer
contains these roots, and also rejects TLS connections presenting the
compromised intermediates even when the system CA store still trusts
their roots [2]. 2.11.1 is the latest release.

This also includes the other security fixes released since 2.5.8 (see
the package's changelog for the complete list).

Composer 2.11.x requires PHP >= 7.2.5, which host-php satisfies.

Release notes: https://github.com/composer/composer/releases/tag/2.11.1
Changelog: https://github.com/composer/composer/blob/2.11.1/CHANGELOG.md

[1]: https://emudhra.we-have-a-problem.com/
[2]: composer/composer#13146

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Signed-off-by: Julien Olivain <ju.o@free.fr>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Nov 16, 2026
Composer 2.5.8 bundles composer/ca-bundle 1.3.5, which still contains
the emSign ECC Root CA - G3 and AAA Certificate Services roots to which
the compromised eMudhra intermediate CAs chain ([1]).

Composer 2.11.0 updates composer/ca-bundle to 1.6.0, which no longer
contains these roots, and also rejects TLS connections presenting the
compromised intermediates even when the system CA store still trusts
their roots [2]. 2.11.1 is the latest release.

This also includes the other security fixes released since 2.5.8 (see
the package's changelog for the complete list).

Composer 2.11.x requires PHP >= 7.2.5, which host-php satisfies.

Release notes: https://github.com/composer/composer/releases/tag/2.11.1
Changelog: https://github.com/composer/composer/blob/2.11.1/CHANGELOG.md

[1]: https://emudhra.we-have-a-problem.com/
[2]: composer/composer#13146

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit db1d038)
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Nov 16, 2026
Composer 2.5.8 bundles composer/ca-bundle 1.3.5, which still contains
the emSign ECC Root CA - G3 and AAA Certificate Services roots to which
the compromised eMudhra intermediate CAs chain ([1]).

Composer 2.11.0 updates composer/ca-bundle to 1.6.0, which no longer
contains these roots, and also rejects TLS connections presenting the
compromised intermediates even when the system CA store still trusts
their roots [2]. 2.11.1 is the latest release.

This also includes the other security fixes released since 2.5.8 (see
the package's changelog for the complete list).

Composer 2.11.x requires PHP >= 7.2.5, which host-php satisfies.

Release notes: https://github.com/composer/composer/releases/tag/2.11.1
Changelog: https://github.com/composer/composer/blob/2.11.1/CHANGELOG.md

[1]: https://emudhra.we-have-a-problem.com/
[2]: composer/composer#13146

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit db1d038)
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant