nic-6443 opened a new pull request, #13913: URL: https://github.com/apache/apisix/pull/13913
### Description `jwe-decrypt` rejects every token a standard JWE library produces on the older OpenResty releases APISIX supports. RFC 7516 authenticates the encoded protected header as the AES-GCM additional authenticated data, and the plugin passes it as the third argument of `aes_default:decrypt(ciphertext, tag, o.header)`. `resty.aes` only grew that parameter in lua-resty-string 0.16; on OpenResty 1.21.4, the oldest release `apisix/cli/ops.lua` accepts, the signature is `decrypt(self, s, tag)` and the argument is dropped without a word. The AAD attempt and the backward compatible attempt then run the exact same decryption without AAD, so a token whose tag covers the header always fails and the request gets `400 failed to decrypt JWE token`. A token built without AAD decrypts fine, which is what makes this look like a key problem rather than an AAD one. The AEAD now runs through `resty.openssl`, which takes the AAD on every version and is already used by `apisix/upstream.lua`, `jwt-auth`, `cas-auth` and `openid-connect`. `resty.openssl` also hands the tag to OpenSSL as it is. OpenSSL accepts a GCM tag shorter than the 128 bits RFC 7518 fixes for `A256GCM` and then verifies only the bits it was given, so the IV and tag lengths are checked before the token reaches it. The same check rejects a tag carrying trailing bytes, which `resty.aes` silently truncated to its first 16 — a token had many valid encodings until now. Behavior change: a token whose IV is not 96 bits, or whose tag is not 128 bits, is now rejected. Both are fixed by RFC 7518 for `A256GCM` and every JWE library emits them, but a token minted through the `/apisix/plugin/jwe/encrypt` endpoint removed in #13464 with an explicit `iv` of another length no longer decrypts. ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [x] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
