]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: map/cli: CLI commands lack admin permission checks
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 25 Mar 2026 13:57:08 +0000 (14:57 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 31 Mar 2026 10:34:33 +0000 (12:34 +0200)
The CLI commands (get|add|del|clear|commit|set) | (acl|map) does not
contain a permission check on admin level.

Must be backported to 3.3. This can be a breaking change for some users.

Initially reported by Cameron Brown.

src/map.c

index 1e5dcf13bfde77a132ddcc541c20e73e9a7215b8..d85b2e5d60366c89b19ba934117e5aeeaa266c17 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -621,8 +621,8 @@ static int cli_parse_get_map(char **args, char *payload, struct appctx *appctx,
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0 || strcmp(args[1], "acl") == 0) {
                /* Set flags. */
@@ -667,8 +667,8 @@ static int cli_parse_prepare_map(char **args, char *payload, struct appctx *appc
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0 ||
            strcmp(args[1], "acl") == 0) {
@@ -712,8 +712,8 @@ static int cli_parse_show_map(char **args, char *payload, struct appctx *appctx,
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0 ||
            strcmp(args[1], "acl") == 0) {
@@ -769,8 +769,8 @@ static int cli_parse_set_map(char **args, char *payload, struct appctx *appctx,
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0) {
                char *err;
@@ -844,8 +844,8 @@ static int cli_parse_add_map(char **args, char *payload, struct appctx *appctx,
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0 ||
            strcmp(args[1], "acl") == 0) {
@@ -977,8 +977,8 @@ static int cli_parse_del_map(char **args, char *payload, struct appctx *appctx,
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (args[1][0] == 'm')
                ctx->display_flags = PAT_REF_MAP;
@@ -1075,8 +1075,8 @@ static int cli_parse_clear_map(char **args, char *payload, struct appctx *appctx
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0 || strcmp(args[1], "acl") == 0) {
                const char *gen = NULL;
@@ -1134,8 +1134,8 @@ static int cli_parse_commit_map(char **args, char *payload, struct appctx *appct
 {
        struct show_map_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
 
-       if ((appctx->cli_ctx.level & ACCESS_LVL_MASK) < ACCESS_LVL_ADMIN)
-               ha_warning("'%s %s' accessed without admin rights, this won't be supported anymore starting from haproxy 3.3\n", args[0], args[1]);
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
 
        if (strcmp(args[1], "map") == 0 || strcmp(args[1], "acl") == 0) {
                const char *gen = NULL;