Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when parsing set of JWK keys which contain unsupported algorithms #561

Open
promasu opened this issue Mar 21, 2024 · 0 comments
Open

Comments

@promasu
Copy link

promasu commented Mar 21, 2024

When using the https://github.com/firebase/php-jwt/blob/main/src/JWK.php#L55 parseKeySet function with a list of jwks which contains keys with unsupported algorithms, for example when using this lib with Keycloak for OIDC then the method does not complete to build a list because of the exceptions that are thrown in the parseKey function.

An example keyset to try:
{
  "keys": [
    {
      "kid": "Qtv00g9pCu24BJpG0JydtLajCBiho69iIZfivhjPwRM",
      "kty": "RSA",
      "alg": "RSA-OAEP",
      "use": "enc",
      "n": "vZi3klbtMtzknokuHuU4WyAs7HFnCG-QUSa2Y-PfbwqONlW7ZruTd9lKv6xVzQKqAldhrF2Ljm1dujMkdMSHYHW7L7WD718k0QX-duH_Z3kediGVgVVIikV5y17wYliHcM9x2lUV1EzVhfI3BQrhu-yHkmzvhuHAosr-kDELD483ReMYbG4f79DHoTl-NAg1ZgKhmUc2aPhut9NrJAIE7Q6mf2EnOeHP9e7KzQPOJW7-_ACnRb2E3iXBqpeX4-uNN5h2zCM1jzgN1m8v3xlqJnz4cydIAJ6Np1fCLief31UK6Tiz84xOgjEhCowjK_i1zrm7ciq-Sgs1heMIfKQ5JQ",
      "e": "AQAB",
      "x5c": [
        "MIICnzCCAYcCBgGEr+Dy7jANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhlbnRyb3BpYTAeFw0yMjExMjUxNzM5MjVaFw0zMjExMjUxNzQxMDVaMBMxETAPBgNVBAMMCGVudHJvcGlhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvZi3klbtMtzknokuHuU4WyAs7HFnCG+QUSa2Y+PfbwqONlW7ZruTd9lKv6xVzQKqAldhrF2Ljm1dujMkdMSHYHW7L7WD718k0QX+duH/Z3kediGVgVVIikV5y17wYliHcM9x2lUV1EzVhfI3BQrhu+yHkmzvhuHAosr+kDELD483ReMYbG4f79DHoTl+NAg1ZgKhmUc2aPhut9NrJAIE7Q6mf2EnOeHP9e7KzQPOJW7+/ACnRb2E3iXBqpeX4+uNN5h2zCM1jzgN1m8v3xlqJnz4cydIAJ6Np1fCLief31UK6Tiz84xOgjEhCowjK/i1zrm7ciq+Sgs1heMIfKQ5JQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAKbEduhsT1yxsCymFBHYDNdSXEtZnCSf/NGan9+wyOZtaDyYYtuAipiX43mahkXP/3RlPyDn6UfMXTsdzeD8tml1sZ1bVqD39VsbPZOr6HSvh1JlX40Bn8mLEU/FoQ4OfgrQzdgSLehFLbZ5P0RWwUcZjV+OpdxkOcC7pSb6y1W+3UfsfVhejTUHncan5ZInMI7GWdMRGVuN4JMuAbgnp2v6XqL1di3gTBJl83vFE8GRdwCoyJJiOzXUqcIjWfUsC6PLeHKtPqPlxtHHyvgJdAuGYVLameBoeDJISu3nxkng/RfSU0iwX1hf/1eHOhva0HG5FjMHQNYGJ+V7wYpxOr"
      ],
      "x5t": "1Nd1lnfuVZjpEjnFppIrEcpJhW4",
      "x5t#S256": "8NRLcvxX_jloFTT5EZMkchtgkJylb_v0ZwK1HJSQXW4"
    },
    {
      "kid": "aI_rrbdNagZjWTJ517JBbTAv-eDZoYiR8If3ZMZuf0M",
      "kty": "RSA",
      "alg": "RS256",
      "use": "sig",
      "n": "tI59R8YidctuCz_3-51aP86L4hGbsF8JeuEuQNmArQ1Xj22jwEUSr-YDPb5u6XViyWzLJI6_z5j3vK7O5XVOQGa09LkcHDdPWeuWq3Twy8ZTTqf8miMgIVLNhNYUmMwTFvvg9tVl-sF4XjcxEUdknvdjgDbkHQgfVEycGcinh-u66ZSXFrYcwD1sGSDPA8RzYDpb9wkedDGQU-s7UZFWRPVbFpg9HiK90f7YNJDbR_xZxwMQftsrTlsArfXptdgx295OrF11BQ_CguftLxUC-6C8W-XxXZb49mzDpznR6ITBo3YfkvWnqL4KplNzG6p9l_3ZVqbCuMUiZYv5dV5iYw",
      "e": "AQAB",
      "x5c": [
        "MIICnzCCAYcCBgGEr+DwPzANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhlbnRyb3BpYTAeFw0yMjExMjUxNzM5MjVaFw0zMjExMjUxNzQxMDVaMBMxETAPBgNVBAMMCGVudHJvcGlhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtI59R8YidctuCz/3+51aP86L4hGbsF8JeuEuQNmArQ1Xj22jwEUSr+YDPb5u6XViyWzLJI6/z5j3vK7O5XVOQGa09LkcHDdPWeuWq3Twy8ZTTqf8miMgIVLNhNYUmMwTFvvg9tVl+sF4XjcxEUdknvdjgDbkHQgfVEycGcinh+u66ZSXFrYcwD1sGSDPA8RzYDpb9wkedDGQU+s7UZFWRPVbFpg9HiK90f7YNJDbR/xZxwMQftsrTlsArfXptdgx295OrF11BQ/CguftLxUC+6C8W+XxXZb49mzDpznR6ITBo3YfkvWnqL4KplNzG6p9l/3ZVqbCuMUiZYv5dV5iYwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQArE6mZeWH4haqOGRjtoPHcjO9J4giO9VR6Cxay4bcgrnJYVuIAn5y6umaLjUaP8IthQMMhDcXh3dkoXkaUvlZFtelB29JXZjwPW66rmrPW/5iVqst6qUghyMI80pQyw4UPZKE09atchMiWwtmJ63BbzAYXizzt4FnWJqX6vcSr5cXRrtcYn4WWxaYVAUqSN5koust3vN7YOKhTk0XBpay+dirfa3ENwLbq4KjhImmHwcZa3RpRgkHInbG2U8u6nZDTsOmyIDgVnG8/LZmBHINQ9vhpiLTiERzk0zRk1WtwojHoe9A5MfEgqC3MW5KMVOYlfE+d0QnvCJ3KKaOj8xwE"
      ],
      "x5t": "GQ1-KNU1SgsG8tFXiqNjTt-x1IQ",
      "x5t#S256": "6L5_LevQpy2vP_VUiqOBM3hGIXVIx1EmzsTQPPh0jWc"
    },
    {
      "kid": "X1JHUQ58RnZc0xHM0NCz_3fbq8JtBbCvMx9adHTDDTA",
      "kty": "EC",
      "alg": "ES512",
      "use": "sig",
      "crv": "P-521",
      "x": "ANCPjd7cPxRHok4a444BTEa0NjIGBfeXlQK6OtdTUjJojmeWznop8koQh4P9sN4NuU2nm49PglN2Jq7GF3eANSDr",
      "y": "Aag3LtKNyL4NJualANsYqnITNQE2H00ZXzogOq_3QbcPwspG8St_dHTFoKEiOSl-Y9776_kJHBPtdlh1H7SY5AbZ"
    },
    {
      "kid": "HmJ4is_hIt-PAdNYRw6raC-wZ58Hppf32qxswz0no5s",
      "kty": "RSA",
      "alg": "RS512",
      "use": "sig",
      "n": "zI4ON1mKFst4kN4RBzbjfeeitXOQQ1APwHQ51WqCIQVLJwXEkVUjNtMAZ4PvSp0lC-Tw9xW3ZMkkE8CNNVZJqtmA8oz6sp_BqdyjMM3pJPeuTudXnAfJ2SmOHSqW2T3RLXRj_Lcvrl__AtJkASnKFAaSUiinXbqzgWOvmwYUyY4IBLSt4d_iDe72UDyEtnDysAJWxu6xOXKUgQkJq_gq3gXEkzGDhSsdyvdKk7uTKSIt_zioQy-cTYGVxgnHvSqPW_glvTiha6HJte8SMcSt34HFU8m3FOI7IZyS8gQzfquLkPZilDU90p_W4c57v2zRGfZ4Rt4Lov9ZV4JmwGSh4w",
      "e": "AQAB",
      "x5c": [
        "MIICnzCCAYcCBgGJsSt25TANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhlbnRyb3BpYTAeFw0yMzA4MDExMjU0MjNaFw0zMzA4MDExMjU2MDNaMBMxETAPBgNVBAMMCGVudHJvcGlhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzI4ON1mKFst4kN4RBzbjfeeitXOQQ1APwHQ51WqCIQVLJwXEkVUjNtMAZ4PvSp0lC+Tw9xW3ZMkkE8CNNVZJqtmA8oz6sp/BqdyjMM3pJPeuTudXnAfJ2SmOHSqW2T3RLXRj/Lcvrl//AtJkASnKFAaSUiinXbqzgWOvmwYUyY4IBLSt4d/iDe72UDyEtnDysAJWxu6xOXKUgQkJq/gq3gXEkzGDhSsdyvdKk7uTKSIt/zioQy+cTYGVxgnHvSqPW/glvTiha6HJte8SMcSt34HFU8m3FOI7IZyS8gQzfquLkPZilDU90p/W4c57v2zRGfZ4Rt4Lov9ZV4JmwGSh4wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBITUGrXrNa4Jg1/x4v3HbK/HJqoVhA0ysxcCFY4WoAM4KRGTHPJouqDzU3qPl/+ENvN2e7NKNeziHfYR/q9hp4mVY9h8vQZHTZTG2rnPAJKOLnBjAOFZ0Vcq575kxb+Gl2QBUZ8lBkfwOmpMZyNGseSS6t8tck1YSikbTjw6fePPH+ZXTEMcLs5uEi7JTCtn6Adwn2AybJ3fFxfrrbAht13Jw6I7CLebnm8Qf4IDE/DAh7zpAtKsDGwd0c/Kbts0a9AGtEvsM6pD6e0dT0K+KaDeH2RY/JuciVTf46rqvA18kG6ZGZwo2tbM4aYpYTWWet7VNCPrBfHa1IdEjfPqfv"
      ],
      "x5t": "6BJYF7VoZZQRv8fsUnqfTsBAyqE",
      "x5t#S256": "CBOg1Ypm4hc0m9Rn5737QXU5UWbcdILmQC0sgKJtJt4"
    },
    {
      "kid": "2Rrz-nR_1OJJznPq5OKGxLyPtzjq920egvDCOuoiplE",
      "kty": "EC",
      "alg": "ES384",
      "use": "sig",
      "crv": "P-384",
      "x": "fm9Je26t48PaE7Iubn6BjMsq2Ul8e0E00FlX-sA04GkduD0KNUs-27y7eePKyP7q",
      "y": "G7zZSIpqpMnvHdjBYiRNMg1RL9y-1i5edenVSk8ZxuIyUAOihNBRTbWaQL5hgGYm"
    },
    {
      "kid": "7JiaBXb5r-RlNz80Br9_ie8kd27i_3qX1Qabkm11w0E",
      "kty": "RSA",
      "alg": "PS384",
      "use": "sig",
      "n": "xaL4VC2GVsO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AncCgBRFdHn9COLPVzor2OAiAhLuYdr2cVjSMSq+0PwY9mOj94eMsTmAptuf3yGsYg5HX6pihGXqx0S0vdGd6br+9/JbCPYvnx1ntz2YHLGXTDE9/m7DjsboEuIdKZezHd7iuzLQ/o2bVazxwmb0tfttjxVLql6HOh8Ql8FhY7mE"
      ],
      "x5t": "5T0Tr0Jh1JvXxb01X-NV2RBjI2w",
      "x5t#S256": "GgdBwBsBMKgW7srmHYjg0afMKZ7v2mDNV2RNb0R_HLI"
    }
  ]
}
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

No branches or pull requests

1 participant