You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPEqhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
2
+
<qhelp>
3
+
<overview>
4
+
<p>
5
+
A JSON Web Token (JWT) is used for authenticating and managing users in an application.
6
+
</p>
7
+
<p>
8
+
Using a hard-coded secret key for parsing JWT tokens in open source projects
9
+
can leave the application using the token vulnerable to authentication bypasses.
10
+
</p>
11
+
12
+
<p>
13
+
A JWT token is safe for enforcing authentication and access control as long as it can't be forged by a malicious actor. However, when a project exposes this secret publicly, these seemingly unforgeable tokens can now be easily forged.
14
+
Since the authentication as well as access control is typically enforced through these JWT tokens, an attacker armed with the secret can create a valid authentication token for any user and may even gain access to other privileged parts of the application.
15
+
</p>
16
+
17
+
</overview>
18
+
<recommendation>
19
+
20
+
<p>
21
+
Generating a cryptographically secure secret key during application initialization and using this generated key for future JWT parsing requests can prevent this vulnerability.
22
+
</p>
23
+
24
+
</recommendation>
25
+
<example>
26
+
27
+
<p>
28
+
The following code uses a hard-coded string as a secret for parsing user provided JWTs. In this case, an attacker can very easily forge a token by using the hard-coded secret.
29
+
</p>
30
+
31
+
<samplesrc="ExampleGood.go" />
32
+
33
+
</example>
34
+
<references>
35
+
<li>
36
+
CVE-2022-0664:
37
+
<ahref="https://nvd.nist.gov/vuln/detail/CVE-2022-0664">Use of Hard-coded Cryptographic Key in Go github.com/gravitl/netmaker prior to 0.8.5,0.9.4,0.10.0,0.10.1. </a>
0 commit comments