Skip to main content

Business information leak - JWT

Description

Business information is obtained within the JWT, such as:

  • Username
  • Password

Impact

  • Get the username from the JWT.
  • Get the encrypted password from the JWT.

Recommendation

Remove the sensitive information from the JWT and manage this kind of information in the server-side.

Threat

Anonymous attacker from the Internet.

Expected Remediation Time

⌚ 30 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: N
  • Attack complexity: H
  • Privileges required: N
  • User interaction: N
  • Scope: U
  • Confidentiality: L
  • Integrity: N
  • Availability: N

Temporal

  • Exploit code madurity: X
  • Remediation level: X
  • Report confidence: X

Result

  • Vector string: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N/E:X/RL:X/RC:X
  • Score:
    • Base: 3.7
    • Temporal: 3.7
  • Severity:
    • Base: Low
    • Temporal: Low

Code Examples

Compliant code

The jwt token is securely configured to avoid including sensitive information

app.post("/user/generateToken", (req, res) => {
// Validate User Code
let jwtSecretKey = process.env.JWT_SECRET_KEY;
let data = {
time: Date(),
userId: 12,
}
const token = jwt.sign(data, jwtSecretKey);
res.send(token);
});

Non compliant code

The jwt token response includes password and username

app.post("/user/generateToken", (req, res) => {
// Validate User Code
let jwtSecretKey = process.env.JWT_SECRET_KEY;
let data = {
userName: req.body.user,
password: req.body.password,
}
const token = jwt.sign(data, jwtSecretKey);
res.send(token);
});

Requirements

free trial

Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.