JWELoaderFactory and JWSLoaderFactory ignore the requested header checkers when they have no HeaderCheckerManagerFactory

オープン
#768 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, symfony

調査の方向性

Start with JWELoaderFactory and JWSLoaderFactory, then inspect the corresponding bundle factories and the service names described in the bundle documentation. Check how create() handles requested header checker aliases when no manager factory is available, including the empty list case. Done means the documented services are accurate and requested aliases cannot be silently ignored.

索引モデルが issue の本文から書いたものです。

説明

bug
Version(s) affected

All released versions since 1.1.0 (3.4.x, 4.0.x, 4.1.x, 4.2.x), and the 4.3.x and 5.0.x branches.

Description

The third constructor argument of Jose\Component\Encryption\JWELoaderFactory and Jose\Component\Signature\JWSLoaderFactory is a nullable HeaderCheckerManagerFactory. When it is null, create() ignores $headerCheckers and returns a loader without header checker manager, which checks no header parameter at all (typ, alg, crit, exp…). Nothing is thrown, even for an alias that does not exist, whereas an unknown serializer or algorithm alias is refused. NestedTokenLoaderFactory passes its two lists to these factories and behaves the same.

$factory = new JWELoaderFactory($serializerManagerFactory, $decrypterFactory, null);
$loader = $factory->create(['jwe_compact'], ['A256KW', 'A256GCM'], ['access_token_type']);
$loader->getHeaderCheckerManager(); // null

With the Symfony bundle this happens without anybody writing null. The bundle documentation fetches Jose\Component\Encryption\JWELoaderFactory (likewise JWSLoaderFactory, JWEDecrypterFactory, JWSVerifierFactory, the builder and checker manager factories) from the container, but since 2.0 the bundle registers Jose\Bundle\JoseFramework\Services\* instead. An application that then registers the library classes itself, with autowiring, gets null as third argument: no service has the type Jose\Component\Checker\HeaderCheckerManagerFactory, and the argument is nullable.

Loaders declared in the bundle configuration (jose.jwe.loaders, jose.jws.loaders) and loaders created by the bundle's own factories are not affected.

How to reproduce

With autowire: true, register Jose\Component\Encryption\JWEDecrypterFactory and Jose\Component\Encryption\JWELoaderFactory as services, and a TypeChecker('at+jwt') tagged jose.checker.header with the alias access_token_type. A loader created by the library factory with create(['jwe_compact'], ['A256KW', 'A256GCM'], ['access_token_type']) accepts a JWE whose protected header has "typ":"refresh+jwt". The loader created by the bundle's factory with the same arguments rejects it with Unsupported type..

Possible Solution
  • Throw an InvalidArgumentException from create() when header checker aliases are requested and no HeaderCheckerManagerFactory is available, and keep returning a loader without manager for an empty list. Same change in the two factories of the bundle.
  • Fix the bundle documentation so that it names the services the bundle registers.
  • 5.0.0: consider making the argument non-nullable, which turns the autowiring case into a container error.
  • Changelog: such a configuration now fails when the loader is created.
Additional Context

Found by the Anthropic OSS Scanner (ANT-2026-F6XYPNCA).

主要言語
PHP
スター
954
フォーク
119
平均マージ
48分
マージ済み PR(30日)
17

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

web-token/jwt-framework のほかの issue

web-token/jwt-framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。