Comment

Comment by gavinray

This exact vulnerability is something I've seen in a good number of open-source codebases or boilerplate repos in the Node ecosystem.

The library most people use for JWT stuff in Node is Auth0's. There are two methods for decoding a token payload: jwt.decode() and jwt.verify()

Both of them return the decoded payload, but one (if you don't read the documentation) sounds more immediately like the one you think you want to use.

jwt.decode() doesn't verify the token when decoding:

https://github.com/auth0/node-jsonwebtoken#jwtdecodetoken--o...

If you dig through Node repos on Github searching for "jwt.decode()" or "this.jwtService.decode()" you'll see a shocking number of results.

The other big mistake I've seen is encoding personal data in the token, instead of just an ID that only has meaning inside of your database. It turns out not everyone is aware that JWT tokens are publicly decodable and that the only security is in the signing + verification. Many people I've spoke with think the token is like a hash.

parent gavinray 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton