Hardening: refuse a JSON "dir" JWE without protected header and "aad", whose content can be an A*GCMKW encrypted key

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

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

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

評価

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

調査の方向性

Read the decrypter and builder paths for JSON JWE handling, then trace how protected headers and aad determine content authentication data for dir. Check the existing tests for JSON serialization and decryption. Done means the decrypter rejects the described empty-AAD shape, the builder no longer emits it, and documentation recommends setting alg on keys shared across algorithms.

索引モデルが 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

AES-GCM key wrapping (A128GCMKW, A192GCMKW, A256GCMKW) encrypts the CEK with AES-GCM under the key and an empty AAD. In the JSON serializations, a JWE may carry alg and enc outside the protected header. When it has neither a protected header nor an aad member, the AAD of its content is empty too, and with dir the content is then encrypted by the same computation as a GCM key wrap.

A decrypter that registers dir, an AGCMKW algorithm and the AGCM algorithm of the same size, and holds the key-wrapping key without an alg parameter, therefore accepts the encrypted key of an A*GCMKW token presented as the content of a dir JWE, and returns the CEK of that token as payload. Nothing is gained unless the application reveals decrypted payloads to the sender. If it does, the CEK opens the original token and allows new content under its encrypted key. Conversely, a JSON dir JWE issued without a protected header is a valid GCM key wrap of its plaintext.

This is a property of the JSON serializations rather than of this library alone: other implementations behave the same when they are given the raw key bytes (checked with panva/jose 6.2.2). Compact JWEs, and therefore JWTs, cannot take this shape.

Mitigations available today:

  • an alg parameter on every key (the key analyzer already reports keys without it);
  • an AlgorithmChecker that reads the protected header only;
  • not registering dir next to key wrapping algorithms in the same decrypter.
Possible Solution
  • The decrypter refuses a dir JWE whose content AAD is empty (no protected header and no aad), and the builder no longer produces one. This refuses a token shape the JSON serializations allow, so 4.3.0 with an upgrade note.
  • Documentation: recommend alg on the keys of a key set shared by several algorithms.

Related: #761 (key_ops does not tell content decryption from key unwrapping).

Additional Context

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

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