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

Aperta
#771 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
PHP
Stelle
954
Fork
119
Merge medio
48m
PR unite (30g)
17

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di web-token/jwt-framework

Tutte le issue di web-token/jwt-framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.