# insecure-jwt-token

Rule `sonarjs/insecure-jwt-token`. JWT should be signed and verified with strong cipher algorithms

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1228 by reach, #529 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/insecure-jwt-token` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-5659/) |

## Code examples

### Incorrect: the rule reports this

```js
const jwt = require('jsonwebtoken');

let token = jwt.sign({ foo: 'bar' }, key, { algorithm: 'none' }); // Noncompliant: 'none' cipher doesn't sign the JWT (no signature will be included)

jwt.verify(token, key, { expiresIn: 360000 * 5, algorithms: ['RS256', 'none'] }, callbackcheck); // Noncompliant: 'none' cipher should not be used when verifying JWT signature
```

### Correct: the rule accepts this

```js
const jwt = require('jsonwebtoken');

let token = jwt.sign({ foo: 'bar' }, key, { algorithm: 'HS256' }); // Compliant

jwt.verify(token, key, { expiresIn: 360000 * 5, algorithms: ['HS256'] }, callbackcheck); // Compliant
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/insecure-jwt-token": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/insecure-cookie](https://lintradar.dev/rules/sonarjs/insecure-cookie.md): Cookies should have the "secure" flag
- [sonarjs/inverted-assertion-arguments](https://lintradar.dev/rules/sonarjs/inverted-assertion-arguments.md): Assertion arguments should be passed in the correct order
- [sonarjs/index-of-compare-to-positive-number](https://lintradar.dev/rules/sonarjs/index-of-compare-to-positive-number.md): "indexOf" checks should not be for positive numbers
- [sonarjs/jsx-no-leaked-render](https://lintradar.dev/rules/sonarjs/jsx-no-leaked-render.md): React components should not render non-boolean condition values
- [sonarjs/inconsistent-function-call](https://lintradar.dev/rules/sonarjs/inconsistent-function-call.md): Functions should be called consistently with or without "new"
- [sonarjs/label-position](https://lintradar.dev/rules/sonarjs/label-position.md): Only "while", "do", "for" and "switch" statements should be labelled

---

Web page: https://lintradar.dev/rules/sonarjs/insecure-jwt-token. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
