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

Segfault with multiple jwt_decode using RSA #23

Closed
jchook opened this issue Jan 10, 2019 · 1 comment
Closed

Segfault with multiple jwt_decode using RSA #23

jchook opened this issue Jan 10, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@jchook
Copy link

jchook commented Jan 10, 2019

Getting segmentation fault error on latest master:

segfault at 10 ip 00007f0f7535ba94 sp 00007ffcb6cd3d80 error 4 in jwt.so[7f0f75357000+6000]

Code to reproduce:

<?php

function generateKeyPair()
{
  $key = openssl_pkey_new([
    'digest_alg' => 'sha512',
    'private_key_bits' => 1024,
    'private_key_type' => OPENSSL_KEYTYPE_RSA,
  ]);
  openssl_pkey_export($key, $private);
  $public = openssl_pkey_get_details($key)['key'];
  openssl_pkey_free($key);
  return [$public, $private];
}

list($apub, $apriv) = generateKeyPair();
list($bpub, $bpriv) = generateKeyPair();

$payload = ['message' => 'hello world'];
$token = jwt_encode($payload, $apriv, 'RS512');
$decoded = jwt_decode($token, $apub, ['algorithm' => 'RS512']);

$payload = ['message' => 'hello world 2'];
$token = jwt_encode($payload, $bpriv, 'RS512');
$decoded = jwt_decode($token, $bpub, ['algorithm' => 'RS512']); // segfault
@cdoco
Copy link
Owner

cdoco commented Jan 11, 2019

Thanks. I fixed this bug in the develop branch.

@cdoco cdoco added the bug Something isn't working label Jan 11, 2019
@cdoco cdoco closed this as completed in 1a4155b Jan 14, 2019
cdoco added a commit that referenced this issue Jan 14, 2019
Fix #23 -> Segfault with multiple jwt_decode using RSA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants