AES Key Wrap based algorithms unwrap an encrypted key of any length before comparing it with the CEK size

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php

調査の方向性

Read JWEDecrypter and locate checkCekSize(), then trace the four AES Key Wrap algorithm implementations named in the issue. Identify how each derives or determines the expected CEK size and where it performs key derivation, agreement, and unwrapping. Done means invalid encrypted key lengths are rejected before those costly operations; add tests for oversized keys and confirm valid JWEs still decrypt.

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

説明

enhancement
Version(s) affected

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

Description

A128KW/A192KW/A256KW, PBES2-+AKW, ECDH-ES+AKW and ECDH-SS+AKW pass the whole JWE Encrypted Key to spomky-labs/aes-key-wrap, which unwraps any number of 64-bit blocks (six AES calls per block, from PHP) before checking the integrity value. The only valid length is the CEK size plus 8 bytes. JWEDecrypter already knows the CEK size, but checks it only after the unwrapping (checkCekSize()).

A token with an oversized encrypted key is therefore rejected only after work and memory proportional to its size: about 1.5 s of CPU and 14 MB of memory per megabyte of encrypted key (4.2.x and 4.3.x), multiplied by the number of keys tried, against about 0.01 s for a valid token of the same size. Under memory_limit=128M, a token of about 9 MB ends in a fatal error instead of an exception.

The cost is linear in the token size. It matters for applications that accept JWEs in request bodies or fetch them (encrypted request objects, pushed authorization requests, request_uri), not for tokens carried in headers.

Possible Solution
  • Compare the encrypted key length with the expected size before the key derivation, the key agreement or the unwrapping, in the four algorithms.
  • Optionally, add a general bound on the encrypted key length in JWEDecrypter.
  • Meanwhile, applications can limit the size of the tokens they accept.
Additional Context

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

主要言語
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 を短くまとめたダイジェスト。