Skip to content

Conversation

@RustyCoderX
Copy link

…change their password without needing full ACL SETUSER permissions

…change their password without needing full ACL SETUSER permissions
@CLAassistant
Copy link

CLAassistant commented Nov 24, 2025

CLA assistant check
All committers have signed the CLA.

@jit-ci
Copy link

jit-ci bot commented Nov 24, 2025

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

Copy link

@shahsb shahsb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RustyCoderX for your efforts on this.!

addReplyBulkCString(c, "timestamp-last-updated");
addReplyLongLong(c, le->ctime);
}
} else if (!strcasecmp(sub,"setpass") && c->argc == 3) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add unit or component tests for this change?

You could add to tests/unit/acl.tcl (run via redis-server --test-coverage). It would be nice to cover basic + edge cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahsb Yeah sure

src/acl.c Outdated
}

/* Set the password for the current user. */
sds password = c->argv[2]->ptr;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a length check for the password (configurable via a potential future acl-password-min-length config, but it could be hardcoded to 4 for now -- aligns with common Redis ACL practices).

Something like:

    /* Validate password length (min 4 chars for basic security). */
    size_t pwlen = sdslen(c->argv[2]->ptr);
    if (pwlen < 4) {
        addReplyErrorFormat(c, "Password must be at least %zu characters long", (size_t)4);
        return;
    }

    /* Set the password for the current user (hashed via ACLSetUser). */
    sds password = c->argv[2]->ptr;

src/acl.c Outdated
/* Reset existing passwords and set the new one. */
if (ACLSetUser(c->user, "resetpass", -1) != C_OK ||
ACLSetUser(c->user, aclop, sdslen(aclop)) != C_OK) {
addReplyError(c, "Failed to set password");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to enhance error handling: Distinguish between auth failures (already good), validation errors, and ACLSetUser issues (e.g., read-only mode or OOM via a simple errno check if available).

like:

    if (acl_err != C_OK) {
        /* More specific error if read-only (extend as needed). */
        if (server.masterhost && server.master) {  /* Replica check example */
            addReplyError(c, "Password update failed: instance is read-only");
        } else {
            addReplyError(c, "Failed to set password");
        }
    } else {
        addReply(c, shared.ok);
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahsb u can check now the updated code

@sundb
Copy link
Collaborator

sundb commented Nov 26, 2025

i don't think OPS like you to modify the password even you have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants