Open-Source Security Intelligence

Know every vulnerability
before it knows you.

DevGuard continuously monitors your dependencies and alerts you when CVEs like this one affect your stack — with real-time threat intelligence built for developers.

Search

RUSTSEC-2025-0173

Published Jun 2, 2025·Last modified Oct 26, 2026
Affected Components(1)
crates.io logopam-bindings
0.0.0-0 – 0.1.2
Description

In affected versions, PamHandle::get_user can return Err(PAM_SUCCESS) after it gets the username successfully. PAM modules that return this "error" code from sm_authenticate or sm_acct_mgmt early-return a success code to PAM without doing any further verification. This means a user could log in when they shouldn't be able to (e.g., if the module is sufficient).

The pam_try! macro of this crate early-returns the code in this exact way:

fn sm_authenticate(pamh: &mut PamHandle, args: Vec<&CStr>, flags: PamFlag) -> PamResultCode {
    let user = pam_try!(pamh.get_user(None)); // Can return PAM_SUCCESS here.
    // If it does, the module does not get to this line.
}

The root cause is an incorrect FFI declaration for pam_get_user(3). This C function writes a pointer to the username through its user argument (of type const char **user). This crate's binding declared this argument as a shared reference (&*mut c_char). Writing through a shared reference is undefined behavior.

Thus, the compiler can assume that the local pointer, whose address is passed as user, is still null after the call. After the call, the affected code returns Ok only if the return code is PAM_SUCCESS and this pointer is not null. Otherwise, it returns the return code as an error. If the compiler assumes that the pointer is null, get_user returns an error even when the return code is PAM_SUCCESS. Release builds have been observed to do this. Debug builds usually work correctly, so tests in debug mode can miss the problem.

Version 0.1.2 changes the declaration to &mut *const c_char. The fix is in commit 401c961.

If a module cannot upgrade, do not return the error code from get_user. Return a failure code instead, for example pam_try!(pamh.get_user(None), PamResultCode::PAM_AUTH_ERR). This makes the module deny access instead of allowing it, but the undefined behavior remains.

Upload your SBOM

Upload your own SBOM in CycloneDX 1.6 or higher (JSON) directly here to check your vulnerabilities.

Risk Scores
Base Score
-1.0

Measures severity based on intrinsic characteristics of the vulnerability, independent of environment.

Threat Intelligence
-1.0

No exploitation activity has been observed at this time. Continue routine monitoring.

EPSS
N/A

Probability that this vulnerability will be exploited in the wild within the next 30 days.

Exploit
Not available

We did not find any exploit available. Neither in GitHub repositories nor in the Exploit-Database.

Scan your project

Continuously monitor your dependencies and get alerted when vulnerabilities like this one affect your stack.

Checkout DevGuard