Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungI audited my own ML linter and had to withdraw its best evidence(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungQuantum Result Validation for Distributed Computing Systems(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungJWT Authentication and Role-Based Access Control in LocalHands(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungStochastic Parrot or Alien Mind?(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungBuilding AI for the Physical World Is a Different Engineering Problem(21.09.2026 um 22:58 Uhr)
Sichere ProgrammierungI audited my own ML linter and had to withdraw its best evidence(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungQuantum Result Validation for Distributed Computing Systems(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungJWT Authentication and Role-Based Access Control in LocalHands(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungStochastic Parrot or Alien Mind?(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungBuilding AI for the Physical World Is a Different Engineering Problem(21.09.2026 um 22:58 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

I Audited 12 Open Source JWT Implementations and Found the Same 6 Mistakes

I spent last month reviewing JWT implementations across 12 open-source Node.js projects on GitHub — ranging from starter templates with 2k stars to production boilerplates used by teams at real companies. I found the same 6 mistakes in a…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

I spent last month reviewing JWT implementations across 12 open-source Node.js projects on GitHub — ranging from starter templates with 2k stars to production boilerplates used by teams at real companies. I found the same 6 mistakes in almost every one.



None of these projects are bad. The developers are skilled. The mistakes are subtle, copy-paste errors from tutorials that nobody questioned.



Here they are.






Mistake 1 — The Secret Is Literally "secret"



I found this in three separate projects:




const token = jwt.sign({ userId: user.id }, "secret", { expiresIn: "1h" });






This secret is in every JWT tutorial on the internet. It is in the jwt.io documentation. It is in the jsonwebtoken README. Developers copy it and forget to replace it.



A 6-character ASCII secret has approximately 42 bits of entropy. A GPU cluster cracks it from a dictionary in milliseconds. Generate a real secret here — it takes 3 seconds and produces a 256-bit cryptographically random key.






Mistake 2 — jwt.decode() Used in Auth Middleware






// DANGEROUS — this is in a production auth middleware
const decoded = jwt.decode(req.headers.authorization.split(" ")[1]);
if (!decoded.userId) return res.status(401).send("Unauthorized");






jwt.decode() does not verify the signature. It reads the payload regardless of whether the token is valid, expired, or forged. An attacker can craft any payload they want and it will pass this check.



The fix is two characters: jwt.verify().




const decoded = jwt.verify(token, process.env.JWT_SECRET, { algorithms: ["HS256"] });









Mistake 3 — Algorithm Not Specified in verify()






// Missing algorithms option
jwt.verify(token, secret);






Without { algorithms: ['HS256'] }, the library trusts whatever algorithm is in the token's header. An attacker can create a token with alg: none and an empty signature — and jwt.verify() will accept it.



Always specify the expected algorithm explicitly.






Mistake 4 — Secret Committed to Version Control






// Found in config.js, committed to a public repo
module.exports = {
jwtSecret: "productionsecretdonotshare2024",
database: process.env.DATABASE_URL
};






Note the comment — "do not share." The developer knew this was sensitive. But it still ended up committed to a public repository.



Once in git history, a secret is compromised permanently. Even deleting the file does not remove it from history. Rotate immediately if this has happened to you.






Mistake 5 — Tokens Stored in localStorage






// Frontend code in multiple projects
localStorage.setItem("token", response.data.token);

// Later:
const token = localStorage.getItem("token");






localStorage is accessible to any JavaScript running on the page. A single XSS vulnerability — an improperly sanitised comment, a compromised npm package, a third-party script — and all stored tokens are exfiltrated.



Use httpOnly cookies for authentication tokens. They are invisible to JavaScript, making XSS token theft impossible.






Mistake 6 — Tokens Never Expire






// No expiresIn — token is valid forever
const token = jwt.sign({ userId: user.id }, secret);






A JWT without an exp claim never expires. If it is ever leaked — in a log file, an error response, a frontend cache — it remains valid indefinitely.



Always set expiresIn. For access tokens: 15 minutes. For long-lived sessions: use a refresh token pattern, not a long-lived access token.






The Pre-Ship Checklist



Before your next JWT implementation goes to production:




  • [ ] Secret generated with a CSPRNG, minimum 256 bits

  • [ ] Secret in environment variable, not in code

  • [ ] jwt.verify() used everywhere, never jwt.decode() alone

  • [ ] { algorithms: ['HS256'] } explicitly specified

  • [ ] expiresIn set on all tokens

  • [ ] Tokens in httpOnly cookies, not localStorage
    I have been using jwtsecretgenerator.com for generating secrets — it runs entirely in the browser using the Web Crypto API, nothing is sent to a server, and it produces the right bit length for your algorithm.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten I Audited 12 Open Source JWT Implementations and Found the Same 6 Mistakes

Thematisch verwandte Begriffe: Audited, Open, Source, Implementations · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-45381 | Tautulli is a Python based monitoring and tracking tool for Plex Media S…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick