Base64UrlSafe accepts bytes 0x80 to 0xFF when ext-sodium is loaded
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
- 76/100
Direzione di ricerca
Start with Base64UrlSafe::decodeNoPadding() and compare its sodium path with the pure PHP decoder; the issue says the class handles key material too. Check how the existing code raises RangeException for invalid input, then verify that bytes outside the base64url alphabet are rejected consistently while valid input still decodes. The issue gives a reproduction using QUJ_ and QUJ\xFF; use these to confirm the behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version(s) affected
3.4.9 to 3.4.12, 4.0.7 to 4.0.8, 4.1.0 to 4.1.10, 4.2.0 to 4.2.5, and the 4.3.x and 5.0.x branches, when ext-sodium is linked against libsodium 1.0.21 or older on a platform where char is signed (x86-64)
Description
When ext-sodium is loaded, Base64UrlSafe::decodeNoPadding() hands its input to sodium_base642bin() and relies on libsodium to reject characters outside the base64url alphabet. Up to 1.0.21, libsodium decodes every byte from 0x80 to 0xFF as _ where char is signed (seen with 1.0.18 on x86-64). This was fixed upstream in 1.0.22 (jedisct1/libsodium@a615d0ed74, "base64: reject signed chars"). The pure PHP decoder of the same class rejects these bytes, so the result depends on the environment.
Every token segment goes through this decoder. Each _ in the signature of a compact JWS, or in the encrypted key, IV, ciphertext or tag of a compact JWE, can be replaced by any byte from 0x80 to 0xFF, and the token still loads with the same header, payload and plaintext. The header and payload segments are used as received, so they cannot be changed this way.
Nothing is forged or disclosed. A token holder can however produce other strings for a token the application accepts, which matters to applications that recognise a token by its string or its hash (deny-list of revoked tokens, replay cache).
The sodium path was added in #636 (4.1.0) and backported in #644 (3.4.9, 4.0.7).
How to reproduce
use Jose\Component\Core\Util\Base64UrlSafe;
echo bin2hex(Base64UrlSafe::decodeNoPadding('QUJ_')), PHP_EOL; // 41427f
echo bin2hex(Base64UrlSafe::decodeNoPadding("QUJ\xFF")), PHP_EOL; // 41427f with ext-sodium, RangeException without it
Possible Solution
Reject the bytes outside the alphabet on the sodium path too, with the same RangeException as the pure PHP path. The class also decodes key material (k, d…), so the check should not take a time that depends on the characters, which strspn() does before PHP 8.4. Decoding, re-encoding the result with sodium_bin2base64() and comparing with hash_equals() rejects all 128 high bytes, gives the same output on valid input, and keeps most of the speed-up of the sodium path (22 ms on 1.3 MiB, against 12.5 ms today and 409 ms for the pure PHP path).
Additional Context
Found by the Anthropic OSS Scanner (ANT-2026-DYQEQ988).
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di web-token/jwt-framework
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
web-token/jwt-framework#757 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
web-token/jwt-framework#773 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
web-token/jwt-framework#772 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
web-token/jwt-framework#771 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
web-token/jwt-framework#770 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di web-token/jwt-framework
Issue simili
-
enhancement priority Sales
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
novalo-dev/Prestashop-MCP-Server#201 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Include flows spanning the full report time windowForse già presa @somethingwithproof l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Cacti/plugin_flowview#306 ·
I maintainer di solito rispondono entro 1 giorno
-
bug origin: upstream priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
mattytap/Mattytap-Sermons#105 ·
-
priority:low type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
crazy-goat/workerman-bundle#1189 ·
I maintainer di solito rispondono entro 1 giorno