A JSON Web Token is read without checking its signature, or may be unsigned
What it finds
parser.ParseUnverified(token, claims) or jwt.SigningMethodNone: a token whose signature is not checked, or that may be signed with the algorithm none, says whatever its sender wants, so claims such as the user or the expiry cannot be trusted. Parse with a key function that checks the algorithm verifies the signature.
In files that import github.com/golang-jwt/jwt (any major version) or github.com/dgrijalva/jwt-go, reported are calls of a method ParseUnverified and uses of the package members SigningMethodNone and UnsafeAllowNoneSignatureType. A package imported with a version suffix and no name is taken to be named jwt.
From the rule's source, jwt_unverified.rs.
package p import "github.com/golang-jwt/jwt/v5" func read(token string, parser *jwt.Parser, claims jwt.MapClaims) { parser.ParseUnverified(token, claims)tx0 reports: the token is parsed without checking its signature _ = jwt.SigningMethodNonetx0 reports: the algorithm none signs nothing _ = jwt.SigningMethodHS256} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:jwt-unverified" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:jwt-unverified] reason="..."tx0 explain tx0/go:jwt-unverified shows the same in the terminal. Found a false positive? Report it.