HS256
acronymcryptographysecurity
Stands for: HMAC with SHA-256 (JWA identifier)
A JWT signing algorithm: HMAC with SHA-256.
HS256 is a JSON Web Algorithm identifier (RFC 7518) for a symmetric HMAC signature using SHA-256. Because signing and verifying use the same shared secret, mixing it up with an asymmetric algorithm like RS256 is the root of a well-known JWT attack.
HS256 signs a JWT with HMAC and SHA-256, which means the same secret both creates and verifies the signature. That symmetry is the whole story: it is fast, simple, and requires everyone who validates a token to hold the key that could also mint one.
That is fine when one service issues and validates its own tokens, and it becomes a structural problem the moment tokens cross a boundary. Distributing a verification secret to five services means five copies of a signing key, and any of them, or anyone who compromises any of them, can forge tokens indistinguishable from the real thing. The moment you have more than one validator, asymmetric signing is the correct answer.
The failure it enables is the classic algorithm confusion attack. A server that trusts the algorithm named in the token header can be handed a token switched from RS256 to HS256 and signed with the RSA public key, which is not secret, as the HMAC secret. A naive implementation verifies it happily. The defence is unchanged from the general rule: the server decides which algorithm is acceptable, never the token.
Also known as: hs256