Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream: Retry up to 3 times on password authentication failure #102

Closed
wants to merge 1 commit into from
Closed

Conversation

humaidq
Copy link

@humaidq humaidq commented Jul 16, 2022

@Duncaen
Copy link
Owner

Duncaen commented Jul 16, 2022

This needs to be handled different, shadowauth and pamauth have some state, both open the timestamp fd every iteration.

For pamauth there is a little more state and this leaks memory of pam handles every iteration. I think it would be best to instead of repeatably calling the shadowauth or pamauth functions to move the iterations into each of the functions so the pam handle doesn't need to be recreated.

For shadow, I would loop around:

OpenDoas/shadow.c

Lines 84 to 100 in b96106b

response = readpassphrase(challenge, rbuf, sizeof(rbuf), RPP_REQUIRE_TTY);
if (response == NULL && errno == ENOTTY) {
syslog(LOG_AUTHPRIV | LOG_NOTICE,
"tty required for %s", myname);
errx(1, "a tty is required");
}
if (response == NULL)
err(1, "readpassphrase");
if ((encrypted = crypt(response, hash)) == NULL) {
explicit_bzero(rbuf, sizeof(rbuf));
errx(1, "Authentication failed");
}
explicit_bzero(rbuf, sizeof(rbuf));
if (strcmp(encrypted, hash) != 0) {
syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
errx(1, "Authentication failed");
}

For pam the loop should be here, but that needs more investigation to confirm that this is supported by the pam api:

OpenDoas/pam.c

Lines 288 to 294 in b96106b

/* authenticate */
ret = pam_authenticate(pamh, 0);
if (ret != PAM_SUCCESS) {
pamcleanup(ret, sess, cred);
syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
errx(1, "Authentication failed");
}

@Duncaen
Copy link
Owner

Duncaen commented Jul 16, 2022

This was also an issue in the linked revision, https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/doas/doas.c.diff?r1=1.91&r2=1.92&f=h

@humaidq humaidq closed this by deleting the head repository Nov 25, 2023
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.

Feature request: Multiple tries
2 participants