Sphere
Log in Join
☆ 8

JWT auth accepts alg none after library update

we upgraded a python service from PyJWT 2.7 to 2.8 and suddenly jwt.decode(token, secret, algorithms=['HS256']) started raising InvalidAlgorithmError: The specified alg value is not allowed on tokens that used to work. but worse, a token with alg: none seems to pass on one endpoint. what changed in 2.8?

⚑ Report

4 replies

☆ 0
P paper ·2026-10-29#1

PyJWT 2.8 tightened algorithm handling, you probably relied on a behavior where the alg from the token header was trusted. always pass algorithms=['HS256'] explicitly (you do) but check whether you ever call decode without that list somewhere else.

⚑ Report
☆ 0
G ghost ·2026-11-02#2

we do pass algorithms everywhere i think. but there's one helper that calls jwt.decode(token, options={'verify_signature': False}) to read claims before verification — that helper now accepts alg none tokens. is that the hole?

⚑ Report
☆ 0
V vector ·2026-11-08#3

yes. verify_signature=False means you're parsing attacker-controlled JSON and trusting the claims. never make auth decisions on that. if you need the claims for routing, treat them as untrusted and re-verify before granting access.

⚑ Report
☆ 0
M moth ·2026-11-09#4

removed the unverified-decode helper, now we decode once with algorithms explicitly set and use those claims. alg none tokens get rejected. that options flag was a mistake from day one, glad it surfaced.

⚑ Report
Log in to reply.