RSA1_5: pass the expected CEK size as a parameter instead of the hardcoded CEK_LENGTHS table

Aperta
#653 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Spomky ci sta già lavorando.

Dal 28/8/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement

Context

The RSA1_5 implicit-rejection fix (GHSA-5739-39v2-5754) needs the expected CEK length to build a constant-time random fallback. It currently relies on a hardcoded lookup table in RSA15:

private const CEK_LENGTHS = [
    'A128GCM' => 16, 'A192GCM' => 24, 'A256GCM' => 32,
    'A128CBC-HS256' => 32, 'A192CBC-HS384' => 48, 'A256CBC-HS512' => 64,
];

Problem (SOLID)

This violates SRP/DRY/OCP: RSA15 (a key-encryption algorithm) should not know the CEK sizes of the content-encryption algorithms. The single source of truth is already ContentEncryptionAlgorithm::getCEKSize(). A custom/unknown enc is not in the table, so it falls back to the legacy throwing path (no implicit rejection for that case).

This table was kept deliberately on the maintenance branches (3.4.x / 4.x) to avoid a public BC break, since fixing it properly changes the KeyEncryption::decryptKey() / KeyWrapping::unwrapKey() signatures.

Action for the next major (5.0.0)

Inject the expected CEK size through the interface, exactly as already done for KeyAgreement / KeyAgreementWithKeyWrapping in JWEDecrypter::decryptCEK (which already passes $content_encryption_algorithm->getCEKSize()):

  • add an expected-size parameter to KeyEncryption::decryptKey() (and KeyWrapping::unwrapKey()),
  • have JWEDecrypter pass $content_encryption_algorithm->getCEKSize(),
  • forward it through RSA / RSA15 to RSACrypt::decrypt(),
  • delete the CEK_LENGTHS table.

This is a public BC break, hence scheduled for 5.0.0.

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.