Lua-Resty-JWT Authentication Bypass
The lua-resty-jwt library, as distributed via LuaRocks, was found to be vulnerable to JWT key confusion by default, allowing an attacker to sign a symmetric JWT using a recovered RSA public key. This could let an attacker forge tokens and bypass authentication.
insinuator.net
Published on insinuator.net
I was writing some challenges for PacketWars at TROOPERS22. One was intended to be a JWT key confusion challenge where the public key from an RSA JWT should be recovered and used to sign a symmetric JWT.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the library accepts the algorithm specified in the JWT header without restricting it to the expected asymmetric algorithm, enabling key confusion.
Impact
An attacker could forge JWTs and bypass authentication, though the text does not detail a specific exploit against a live system.
What the attacker needed
Access to a JWT signed with RSA; recover the RSA public key
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A JWT is a signed token used to prove who you are. Some systems check the signature using a public key, but if the library is confused about which algorithm to use, an attacker can sign a token with that public key as if it were a shared secret. This means they can create valid-looking tokens without knowing the real secret.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.