Weak obfuscation of web requests High

Weak obfuscation of web requests makes your application vulnerable to unauthorized access. Using stronger obfuscation significantly reduces the chances of attacks due to unauthorized access.

Detector ID
typescript/weak-obfuscation-of-request@v1.0
Category
Common Weakness Enumeration (CWE) external icon

Noncompliant example

1import jwt from "jsonwebtoken";
2function weakObfuscationOfRequestNoncompliant() {
3  // Noncompliant: secret is hardcoded.
4  const payload = "sss";
5  var secret = "secret";
6  jwt.sign(payload, secret);
7}

Compliant example

1import jwt from "jsonwebtoken";
2var payload: number;
3function weakObfuscationOfRequestCompliant() {
4  // Compliant: secret is properly loaded from environment variables.
5  var secret = process.env.JWT_TOKEN_SECRET;
6  jwt.sign(payload, secret);
7}