The deprecated key set cache of JKUFactory and X5UFactory ignores the request headers

Đang mở
#763 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, symfony
Lĩnh vực
backend, security

Hướng nghiên cứu

Start with UrlKeySetFactoryTrait::getContent() for 4.3 and UrlKeySetFactory::getContent() for 3.4 through 4.2, as named in the issue. Trace how the URL and request headers are used to build the cache key, then check the existing tests for these factories. Done means cached results for the same URL and different headers are kept separate; the issue also calls for an upgrade note about Vary when replacing this cache with Symfony's CachingHttpClient.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Version(s) affected

3.4.0 to 3.4.12, 4.0.0 to 4.0.8, 4.1.0 to 4.1.10, 4.2.0 to 4.2.5, 4.3.x-dev

Description

With enabledCache(), JKUFactory and X5UFactory store the response under hash('xxh128', $url), although the request also carries the $header argument of loadFromUrl(). A later call for the same URL with other headers gets the document fetched for the first ones, without any request, until the entry expires (3600 s by default). With a pool shared between requests or processes (filesystem, APCu, Redis, a long-running worker), this applies to the whole application.

When an endpoint answers with a different key set per header value (a tenant header, a per-tenant Authorization), the verifier of one tenant receives the keys of another. A genuine token of tenant A then verifies for tenant B, unless an iss/aud check binds tokens to their tenant, and tenant B's own tokens fail until the entry expires.

The bundle never calls enabledCache(). The cache is deprecated since 4.1 (runtime notice from 4.3 on) and goes away in 5.0, but 3.4.x and 4.0.x still present it as a normal feature.

How to reproduce
use Jose\Component\KeyManagement\JKUFactory;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

$factory = new JKUFactory($client); // the endpoint answers with one key set per "X-Tenant" value
$factory->enabledCache(new ArrayAdapter());

$acme = $factory->loadFromUrl('https://keys.example.com/jwks', ['X-Tenant' => 'acme']);
$globex = $factory->loadFromUrl('https://keys.example.com/jwks', ['X-Tenant' => 'globex']);

// $globex holds acme's keys, and the endpoint received a single request.
Possible Solution

Include the headers in the cache key, for example hash('xxh128', serialize([$url, $header])), in UrlKeySetFactoryTrait::getContent() (4.3) and UrlKeySetFactory::getContent() (3.4.x to 4.2.x). Entries stored by an older version are simply no longer read.

Additional Context

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

The replacement named by the deprecation, Symfony's CachingHttpClient, keys its entries on the method, the URL, a few standard headers (Authorization, Cookie, Accept*, Host, User-Agent…) and the headers listed in the response's Vary. A key service that selects the document with a custom header must send Vary for that header, or the same mixing happens. Worth a line in the upgrade notes.

Ngôn ngữ chính
PHP
Star
954
Fork
119
Merge trung bình
48 phút
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của web-token/jwt-framework

Tất cả issue của web-token/jwt-framework

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.