medium
github.com/lestrrat-go/jwx vulnerable to Potential Padding Oracle Attack
- Severity
- medium rating by GitHub
- Published
- Last changed
- Also known as
- GO-2023-1859
Description
Summary
Decrypting AES-CBC encrypted JWE has Potential Padding Oracle Attack Vulnerability.
Details
On v2.0.10, decrypting AES-CBC encrypted JWE may return an error "failed to generate plaintext from decrypted blocks: invalid padding":
Reporting padding error causes Padding Oracle Attack Vulnerability. RFC 7516 JSON Web Encryption (JWE) says that we MUST NOT do this.
11.5. Timing Attacks To mitigate the attacks described in RFC 3218 [RFC3218], the recipient MUST NOT distinguish between format, padding, and length errors of encrypted keys. It is strongly recommended, in the event of receiving an improperly formatted key, that the recipient substitute a randomly generated CEK and proceed to the next step, to mitigate timing attacks.
In addition, the time to remove padding depends on the length of the padding. It may leak the length of the padding by Timing Attacks.
To mitigate Timing Attacks, it MUST be done in constant time.
Impact
The authentication tag is verified, so it is not an immediate attack.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| github.com/lestrrat-go/jwx/v2 (Go) | before 2.0.11, before 2.0.11-0.20230614080639-c8b6bec919a1 | GitHub Advisory Database, Go Vulnerability Database |
| github.com/lestrrat-go/jwx (Go) | before 1.2.26 | GitHub Advisory Database, Go Vulnerability Database |
What each source says
GitHub Advisory Database
Summary
Decrypting AES-CBC encrypted JWE has Potential Padding Oracle Attack Vulnerability.
Details
On v2.0.10, decrypting AES-CBC encrypted JWE may return an error "failed to generate plaintext from decrypted blocks: invalid padding":
Reporting padding error causes Padding Oracle Attack Vulnerability. RFC 7516 JSON Web Encryption (JWE) says that we MUST NOT do this.
11.5. Timing Attacks To mitigate the attacks described in RFC 3218 [RFC3218], the recipient MUST NOT distinguish between format, padding, and length errors of encrypted keys. It is strongly recommended, in the event of receiving an improperly formatted key, that the recipient substitute a randomly generated CEK and proceed to the next step, to mitigate timing attacks.
In addition, the time to remove padding depends on the length of the padding. It may leak the length of the padding by Timing Attacks.
To mitigate Timing Attacks, it MUST be done in constant time.
Impact
The authentication tag is verified, so it is not an immediate attack.
Go Vulnerability Database
AES-CBC decryption is vulnerable to a timing attack which may permit an attacker to recover the plaintext of JWE data.
References
Sources
| Source | Record | Licence |
|---|---|---|
| GitHub Advisory Database | GHSA-rm8v-mxj3-5rmq changed 2023-11-08 | CC-BY-4.0 |
| Go Vulnerability Database | GO-2023-1859 changed 2024-05-20 | CC-BY-4.0 |