]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: jwt: Deprecate jwt_verify converter
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Fri, 20 Nov 2026 10:08:46 +0000 (11:08 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 20 Nov 2026 13:50:30 +0000 (14:50 +0100)
The 'jwt_verify' converter was built with the idea of being easy to use
for all JWT tokens and its second parameter needied to be interpreted
totally differently depending on the first parameter (HMAC vs pubkey
path). This comes with a potential security risk if a user did not check
the algorithm type before calling the converter. If an HMAC-signed token
was tested in a jwt_verify call that provided a certificate as second
parameter, an attacker could try to guess the certificate path and forge
HMAC tokens that validate against the certificate path.

In order to get rid of this potential risk, a new jwt_verify_secret
converter was introduced, and paired with the already existing
jwt_verify_cert one, we can fully get rid of this risk since no
parameter gets treated differently based off client-provided
information.

doc/configuration.txt
reg-tests/jwt/jws_verify.vtc
src/sample.c

index 4b63abbca5f525eae2123c0836c6fcc5042454a8..0170ff7ac98dd7dfa16509f2d0b7685476b782bf 100644 (file)
@@ -23389,7 +23389,10 @@ jwt_payload_query([<json_path>[,<output_type>]])
   Please note that this converter is only available when HAProxy has been
   compiled with USE_OPENSSL.
 
-jwt_verify(<alg>,<key>)
+jwt_verify(<alg>,<key>) (deprecated)
+
+  This converter is deprecated, use 'jwt_verify_secret' or 'jwt_verify_cert'
+  instead.
 
   Performs a signature verification for the JSON Web Token (JWT) given in input
   by using the <alg> algorithm and the <key> parameter.
index f1174c117028338edf66766a5ed08b39b373329b..8b508c857ef550ec01e3980bfa34a75c9f53f2b1 100644 (file)
@@ -33,6 +33,7 @@ haproxy h1 -conf {
         tune.ssl.capture-buffer-size 1
         stats socket "${tmpdir}/h1/stats" level admin
         jwt.allow_none_alg
+        expose-deprecated-directives
 
     defaults
         mode http
index 5448166034be45dc668e9452b535781754eeb0a0..96ace8f5db0e377d3c72c84d08cbb0e3acb73aa8 100644 (file)
@@ -5268,6 +5268,10 @@ static int sample_conv_jwt_verify_check(struct arg *args, struct sample_conv *co
                expect_cert = 1;
        else if (strcmp(conv->kw, "jwt_verify_secret") == 0)
                expect_secret = 1;
+       else if (!deprecated_directives_allowed){
+               ha_warning("parsing [%s:%d]: 'jwt_verify' converter is deprecated, "
+                          "use 'jwt_verify_secret' or 'jwt_verify_cert' instead.\n", file, line);
+       }
 
        if (args[0].type == ARGT_STR) {
                alg = jwt_parse_alg(args[0].data.str.area, args[0].data.str.data);