Skip to content

Update signature tests for the protected-header "alg" requirement#651

Merged
Spomky merged 1 commit into
3.4.xfrom
security/jws-alg-confusion-tests
Jun 6, 2026
Merged

Update signature tests for the protected-header "alg" requirement#651
Spomky merged 1 commit into
3.4.xfrom
security/jws-alg-confusion-tests

Conversation

@Spomky
Copy link
Copy Markdown
Member

@Spomky Spomky commented Jun 6, 2026

Contexte

Le correctif GHSA-jc38-x7x8-2xc8 (algorithm confusion) a durci JWSVerifier::getAlgorithm() : le paramètre alg est désormais lu uniquement dans le header protégé en intégrité (RFC 7515 §4.1.1), et un JWS dont le alg n'y figure pas est rejeté.

Trois tests existants validaient l'ancien comportement (cas RFC 7520 §4.7 / §4.8 où alg provient du header non protégé) et étaient donc rouges sur 3.4.x depuis le merge de l'advisory (release 3.4.10).

Changements

  • SignerTest::signAndLoadWithoutAlgParameterInTheHeader : message d'exception attendu mis à jour (No "alg" parameter set in the protected header.).
  • HMACFromRFC7520Test::hS256WithoutProtectedHeader : la construction/sérialisation du token RFC §4.7 reste vérifiée ; la vérification d'un alg non protégé est désormais attendue comme rejetée.
  • MultipleSignaturesTest::multipleSignatures : les signatures avec alg protégé (RS256, HS256) restent valides ; la signature ES512 (alg non protégé) est attendue comme rejetée.

Aucun code de production modifié : seuls des tests sont mis à jour pour refléter le comportement sécurisé.

Validation

  • Suite signature complète verte : OK (111 tests, 313 assertions).
  • Pas de commentaire inline ajouté (uniquement docblocks classe/méthode).

Cible 3.4.x → sera cascadée vers 4.0.x / 4.1.x / 4.2.x. À publier en 3.4.11.

Following the algorithm-confusion fix (GHSA-jc38-x7x8-2xc8), JWSVerifier
reads "alg" only from the integrity-protected header and rejects a JWS
whose "alg" is absent from it. Three existing tests asserted the previous
behaviour where "alg" could come from the unprotected header (RFC 7520
§4.7 / §4.8 examples); they now assert that such tokens are rejected, and
the expected exception message is updated accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Spomky Spomky added this to the 3.4.11 milestone Jun 6, 2026
@Spomky Spomky merged commit fb6d524 into 3.4.x Jun 6, 2026
4 of 12 checks passed
@Spomky Spomky deleted the security/jws-alg-confusion-tests branch June 6, 2026 17:41
wheakerd pushed a commit to wheakerd/jwt-framework that referenced this pull request Jun 7, 2026
* 3.4.x:
  Update signature tests for the protected-header "alg" requirement (web-token#651)
  Merge commit from fork
  Merge commit from fork
  Merge commit from fork
  Merge commit from fork
  Add sodium support for Base64 URL safe encoding/decoding (web-token#644)
  Allow `psr/cache` v2 (web-token#620)
  Fix call function on null (web-token#596)
  Add RangeException to Base64UrlSafe (web-token#577)
  Add Base64UrlSafe utility and refactor code references (web-token#576)

# Conflicts:
#	composer.json
#	phpstan-baseline.neon
#	src/Bundle/DataCollector/JWECollector.php
#	src/Experimental/KeyEncryption/AESCTR.php
#	src/Experimental/KeyEncryption/Chacha20Poly1305.php
#	src/Experimental/Signature/Blake2b.php
#	src/Library/Console/GeneratorCommand.php
#	src/Library/Core/JWK.php
#	src/Library/Core/Util/Base64UrlSafe.php
#	src/Library/Encryption/Algorithm/ContentEncryption/AESCBCHS.php
#	src/Library/Encryption/Algorithm/ContentEncryption/AESGCM.php
#	src/Library/Encryption/Algorithm/KeyEncryption/AESGCMKW.php
#	src/Library/Encryption/Algorithm/KeyEncryption/AESKW.php
#	src/Library/Encryption/Algorithm/KeyEncryption/AbstractECDH.php
#	src/Library/Encryption/Algorithm/KeyEncryption/Dir.php
#	src/Library/Encryption/Algorithm/KeyEncryption/PBES2AESKW.php
#	src/Library/Encryption/Algorithm/KeyEncryption/RSA15.php
#	src/Library/Encryption/Algorithm/KeyEncryption/Util/ConcatKDF.php
#	src/Library/Encryption/Algorithm/KeyEncryption/Util/RSACrypt.php
#	src/Library/Encryption/Serializer/CompactSerializer.php
#	src/Library/Encryption/Serializer/JSONFlattenedSerializer.php
#	src/Library/Encryption/Serializer/JSONGeneralSerializer.php
#	src/Library/KeyManagement/Analyzer/ESKeyAnalyzer.php
#	src/Library/KeyManagement/Analyzer/HSKeyAnalyzer.php
#	src/Library/KeyManagement/Analyzer/OctAnalyzer.php
#	src/Library/KeyManagement/Analyzer/RsaAnalyzer.php
#	src/Library/KeyManagement/Analyzer/ZxcvbnKeyAnalyzer.php
#	src/Library/Signature/Algorithm/EdDSA.php
#	src/Library/Signature/Algorithm/HMAC.php
#	src/Library/Signature/Serializer/CompactSerializer.php
#	src/Library/Signature/Serializer/JSONFlattenedSerializer.php
#	src/Library/Signature/Serializer/JSONGeneralSerializer.php
#	src/Library/composer.json
#	tests/Bundle/JoseFramework/Functional/Encryption/JWECollectorTest.php
#	tests/Bundle/JoseFramework/Functional/KeyManagement/JWKLoaderTest.php
#	tests/Component/Encryption/RFC7520/A128KWAndA128GCMEncryptionWithCompressionTest.php
#	tests/Component/KeyManagement/JWKFactoryTest.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant