Skip to content

Token signed with a short secret written in the code

Gaphigh severity · reads .ts .tsx .js .jsx .mjs .cjs .pyBeta

Anyone who reads the code, or guesses a short key, can sign their own login tokens (CWE-798, CWE-521). When Lintsure finds this, it marks it as a Gap: the code itself shows the problem.

What it looks like

A line Lintsure flags in its own test app:

// web/learned.ts
export const token = (id: string) => jwt.sign({ id }, "secret123", { expiresIn: "1h" });

How to fix it

Read the signing key from the environment or a secret store, and make it at least 32 random bytes.

Through a coding agent, Lintsure suggests the change and waits. Nothing is edited until you approve it.

Controls it relates to

What the framework asks

OWASP Top 10 A04:2025: Cryptographic Failures

Protect data with sound cryptography: HTTPS everywhere, certificate checks on, strong password hashing, modern ciphers, unpredictable tokens, signed tokens that are verified, and no keys in code.

Evidence a reviewer may ask for: Where data is encrypted in transit and at rest, and how keys are stored and rotated.

OWASP Top 10 A07:2025: Authentication Failures

Logins and sessions that hold up: no passwords in code, strong secrets, tokens that expire and are verified, and session cookies protected from scripts and plain HTTP.

Evidence a reviewer may ask for: Login, session and token settings.

API2:2023: Broken Authentication

Sign-in, tokens and password resets must resist guessing, forgery and theft: verified tokens that expire, strong password hashing and limits on attempts.

Evidence a reviewer may ask for: How tokens are issued, checked and revoked, and the limits on sign-in attempts.

Summaries are our own reading of the public texts, not the official wording.

Check your code for this

Runs on your machine. Your code is never uploaded.

npx lintsure scan

Quickstart · Use it in Claude Code or Cursor

This rule is in Beta: its mapping to framework controls is our own reading of the public texts, not independently reviewed. Lintsure is a readiness tool, not an audit or legal advice. A finding, or the lack of one, doesn't make you compliant. Disclaimer

We improve these rules all the time. If you see a false alarm, a missed problem or anything that could work better, tell us in a review and we will use it to improve your experience.

Related rules

Did this rule flag something that's fine, or miss a real problem? Tell us on GitHub. Every report becomes a test case, so the same mistake can't come back.