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

Using predictable/constant cryptographic key when creating and verifing Json Web Token. #66

Open
xubowenW opened this issue Sep 5, 2022 · 3 comments

Comments

@xubowenW
Copy link

xubowenW commented Sep 5, 2022

Hi, we are a research group to help developers build secure applications. We designed a cryptographic misuse detector on Java language. We found your great public repository (i.e., lilishop) from Github, and several security issues detected by our detector are shown in the following. The specific security issues we found are as follows:
(1) Location: Package: cn.lili.common.security.token Class: SecretKeyUtil.class
Security issue: Using predictable/constant cryptographic key when creating and verifing Json Web Token.
(2) Location: Package: cn.lili.common.security.security.context Class: UserContext.class
Security issue: Using predictable/constant cryptographic key when creating and verifing Json Web Token.
(3) Location: Package: cn.lili.common.security.token Class: TokenUtil.class
Security issue: Using predictable/constant cryptographic key when creating and verifing Json Web Token.
image
image
image

@xubowenW
Copy link
Author

xubowenW commented Sep 6, 2022

First of all, any hardcoded(predictable/constant) cryptographic key (private key or symmetric key for signing or encryption) is not secure, it can be see CWE-321, NIST Special Publication 800-57 and other public publications.
Second, I observed that lamp-core-3.7.0, lamp-util-3.7.0 are two separate librares, in which the key you use to generate or verify the JWT signature is hardcoded, All JWTs generated by applications or web programs that use these two packages can be forged.
JWT is widely used in permission granting or identity authentication, and the integrity of the JWT is guaranteed by the signature algorithm. If the signature key is obtained by others, the attacker can arbitrarily forge the JWT to obtain the corresponding permission or log in as any user.

@chopper711
Copy link
Contributor

First of all, any hardcoded(predictable/constant) cryptographic key (private key or symmetric key for signing or encryption) is not secure, it can be see CWE-321, NIST Special Publication 800-57 and other public publications. Second, I observed that lamp-core-3.7.0, lamp-util-3.7.0 are two separate librares, in which the key you use to generate or verify the JWT signature is hardcoded, All JWTs generated by applications or web programs that use these two packages can be forged. JWT is widely used in permission granting or identity authentication, and the integrity of the JWT is guaranteed by the signature algorithm. If the signature key is obtained by others, the attacker can arbitrarily forge the JWT to obtain the corresponding permission or log in as any user.

Thank you for your feedback.

In the current system, JWT is just the cached key, not a direct string for permission verification. The decrypted information is also public information, so there will be no relevant security problems. If the attacker needs to invade the current system, he needs to invade redis first.

@xubowenW
Copy link
Author

xubowenW commented Sep 6, 2022

This is only a security enhancement suggestion, because our detector only detects the implementation security of JWT. Using a hard-coded secret does not conform to the security implementation specification of JWT, which may bring security risks to your system. It is recommended that you use a more secure way to store the secret used to generate the JWT.

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

2 participants