SD-JWT: DisclosureProcessor has no depth bound, and chained Disclosures make memory grow quadratically

Aperta
#773 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend, security

Direzione di ricerca

Start by reading DisclosureProcessor::processValue() and the existing SD-JWT tests. Trace how disclosed values and claim paths are processed recursively, then add a depth bound that rejects excessive nesting with InvalidTokenException. Run the SD-JWT tests and confirm a deeply chained payload is rejected while existing valid cases still pass.

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

Descrizione

bug
Version(s) affected

4.3.x and 5.0.x branches (SD-JWT is not in any release yet).

Description

DisclosureProcessor follows the digests found in disclosed values recursively, as SD-JWT allows, but nothing bounds how deep Disclosures may reference one another. Every level copies the claim path twice: once into the recorded paths, once as the argument of the pending recursive call. Memory therefore grows with the square of the length of a chain of Disclosures. The JSON depth limit does not help, because each Disclosure is a separate JSON document.

On 4.3.x, 1,000 chained Disclosures (117 kB) peak at 30 MB, and 4,000 (465 kB) at 370 MB, against 7.3 MB for 4,000 Disclosures side by side. Under memory_limit=128M, about 2,400 chained Disclosures end the request with a fatal error instead of the InvalidTokenException the class documents. The same code runs in verifyWithKeyBinding() before the Key Binding JWT is checked, and in SDJWT::select(), which verifies no signature.

The chain has to start from a digest covered by the Issuer signature. #772 is one way for a holder to obtain one.

Possible Solution

Bound the depth of the processed payload, disclosed values included, in DisclosureProcessor::processValue(), and reject deeper payloads with InvalidTokenException. A bound of 64 levels rejects the 4,000-Disclosure chain at 5 MB, and the existing SD-JWT tests still pass.

Additional Context

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

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.