Go JOSE affect by a panic in JWE decryption
go-jose
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| github.com/go-jose/go-jose/v4 Go |
|
|
| github.com/go-jose/go-jose/v3 Go |
|
|
| github.com/go-jose/go-jose Go |
go-jose
| Product | Affected | Fixed in |
|---|---|---|
| github.com/go-jose/go-jose/v4 Go |
|
|
| github.com/go-jose/go-jose/v3 Go |
|
|
| github.com/go-jose/go-jose Go |
|
| No fix yet |
Go JOSE provides an implementation of the Javascript Object Signing and Encryption set of standards in Go, including support for JSON Web Encryption (JWE), JSON Web Signature (JWS), and JSON Web Token (JWT) standards. Prior to 4.1.4 and 3.0.5, decrypting a JSON Web Encryption (JWE) object will panic if the alg field indicates a key wrapping algorithm (one ending in KW, with the exception of A128GCMKW, A192GCMKW, and A256GCMKW) and the encrypted_key field is empty. The panic happens when cipher.KeyUnwrap() in key_wrap.go attempts to allocate a slice with a zero or negative length based on the length of the encrypted_key. This code path is reachable from ParseEncrypted() / ParseEncryptedJSON() / ParseEncryptedCompact() followed by Decrypt() on the resulting object. Note that the parse functions take a list of accepted key algorithms. If the accepted key algorithms do not include any key wrapping algorithms, parsing will fail and the application will be unaffected. This panic is also reachable by calling cipher.KeyUnwrap() directly with any ciphertext parameter less than 16 bytes long, but calling this function directly is less common. Panics can lead to denial of service. This vulnerability is fixed in 4.1.4 and 3.0.5.
From the CVE record · GitHub_M
go-jose can panic when decrypting a JWE with an empty encrypted_key field and a supported key-wrapping algorithm in its alg field. An attacker who can supply a JWE for the application to parse and decrypt may cause a denial of service. Parsing rejects the JWE if the application's accepted key algorithms exclude key-wrapping algorithms; network access, authentication requirements, and user interaction are not specified.
Check applications using github.com/go-jose/go-jose/v4 before 4.1.4, /v3 before 3.0.5, or the unversioned package through 2.6.3.