CVE-2026-34986: Go JOSE affect by a panic in JWE decryption

Published Apr 3, 2026
·
Updated

Impact

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 encryptedkey field is empty. The panic happens when cipher.KeyUnwrap() in keywrap.go attempts to allocate a slice with a zero or negative length based on the length of the encryptedkey.

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.

Fixed In

4.1.4 and v3.0.5

Workarounds

If the list of keyAlgorithms passed to ParseEncrypted() / ParseEncryptedJSON() / ParseEncryptedCompact() does not include key wrapping algorithms (those ending in KW), your application is unaffected.

If your application uses key wrapping, you can prevalidate to the JWE objects to ensure the encryptedkey field is nonempty. If your application accepts JWE Compact Serialization, apply that validation to the corresponding field of that serialization (the data between the first and second .).

Thanks

Go JOSE thanks Datadog's Security team for finding this issue.

Other sources

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 encryptedkey field is empty. The panic happens when cipher.KeyUnwrap() in keywrap.go attempts to allocate a slice with a zero or negative length based on the length of the encryptedkey. 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.

MITRE

Affected Software

5 affected componentsFixes available
go/github.com/go-jose/go-jose<=2.6.3
go/github.com/go-jose/go-jose/v3<3.0.5
3.0.5
go/github.com/go-jose/go-jose/v4<4.1.4
4.1.4
Go-jose Project Go-jose>=3.0.0<3.0.5
Go-jose Project Go-jose>=4.0.0<4.1.4

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/go-jose/go-jose/v3 to a version that resolves this vulnerability.

    Fixed in 3.0.5
  2. Upgrade

    Upgrade go/github.com/go-jose/go-jose/v4 to a version that resolves this vulnerability.

    Fixed in 4.1.4
  3. Upgrade

    Upgrade go-jose to a version that resolves this vulnerability.

    Fixed in 4.1.4
  4. Upgrade

    Upgrade go-jose to a version that resolves this vulnerability.

    Fixed in 3.0.5
  5. Configuration

    Ensure the accepted key algorithms passed to ParseEncrypted(), ParseEncryptedJSON(), or ParseEncryptedCompact() do not include key wrapping algorithms (alg values ending in KW). If your list of keyAlgorithms does not include key wrapping algorithms, the application is unaffected.

    Go JOSE JWE parsing/decryption keyAlgorithms list for ParseEncrypted()/ParseEncryptedJSON()/ParseEncryptedCompact() = exclude key wrapping algorithms (alg values ending in KW, except A128GCMKW, A192GCMKW, A256GCMKW)
  6. Configuration

    If your application accepts JWE Compact Serialization, apply validation to the corresponding field in that serialization (the data between the first and second '.') to ensure the encrypted_key is nonempty before attempting decryption.

    JWE Compact Serialization validation encrypted_key field validation for Compact Serialization = reject/validate when encrypted_key is empty
  7. Compensating control

    Prevalidate JWE objects so that when the JWE header 'alg' indicates a key wrapping algorithm (ending in 'KW', with the exception of A128GCMKW, A192GCMKW, and A256GCMKW), the JWE 'encrypted_key' field is nonempty; this prevents the reachable panic path during ParseEncrypted*/Decrypt().

Event History

Apr 3, 2026
Advisory Published
via GitHub·03:28 AM
Data Sourced
via GitHub·03:28 AM
DescriptionSeverityWeaknessAffected Software
Apr 6, 2026
CVE Published
via MITRE·04:22 PM
Data Sourced
via MITRE·04:22 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·05:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·05:17 PM
DescriptionSeverityWeaknessAffected Software

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203