Skip to content
Heist/ feed
Back to feed
UnratedFix available

`PamHandle::get_user` can cause an authentication bypass

Type: advisorySources: OSV

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: ```rust 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][ffi-decl] for [`pam_get_user(3)`][pam-get-user]. 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][ub-immutable]. 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`][null-check] 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

Products
pam-bindings
Affected versions
Not specified
Fixed versions
0.1.2
CVEs
Not specified
Confirmed fixed CVEs
Not specified
Updated in this feed
1 Nov 2026, 14:47 UTC · Revision 1

Source evidence

`PamHandle::get_user` can cause an authentication bypass

core-osv · Original source

Published 2 Jun 2025, 12:00 UTC

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: ```rust 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][ffi-decl] for [`pam_get_user(3)`][pam-get-user]. 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][ub-immutable]. 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`][null-check] 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

osv:RUSTSEC-2025-0173

pam-bindings

Fixed versions: 0.1.2

Complete source record
{
  "id": "1848456ed028a7d2aaa4ccc40dd896abe71ae08abfa625f6ba0993c9be3d2c00",
  "url": "https://osv.dev/vulnerability/RUSTSEC-2025-0173",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "`PamHandle::get_user` can cause an authentication bypass",
    "summary": "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: ```rust 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][ffi-decl] for [`pam_get_user(3)`][pam-get-user]. 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][ub-immutable]. 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`][null-check] 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",
    "evidence": "osv:RUSTSEC-2025-0173",
    "products": [
      {
        "name": {
          "value": "pam-bindings",
          "evidence": "/affected/0/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "0.1.2",
            "evidence": "/affected/0/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "unknown",
    "structured": {
      "id": "RUSTSEC-2025-0173",
      "aliases": [
        "RUSTSEC-2025-0173"
      ],
      "affected": [
        {
          "ranges": [
            {
              "type": "SEMVER",
              "events": [
                {
                  "introduced": "0.0.0-0"
                },
                {
                  "fixed": "0.1.2"
                }
              ]
            }
          ],
          "package": {
            "name": "pam-bindings",
            "purl": "pkg:cargo/pam-bindings",
            "ecosystem": "crates.io"
          },
          "database_specific": {
            "cvss": null,
            "source": "https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2025-0173.json",
            "categories": [
              "privilege-escalation"
            ],
            "informational": null
          },
          "ecosystem_specific": {
            "affects": {
              "os": [],
              "arch": [],
              "functions": []
            },
            "affected_functions": null
          }
        }
      ],
      "modified": "2026-10-26T14:00:04.237415395Z",
      "provider": "osv",
      "references": [
        "https://crates.io/crates/pam-bindings",
        "https://rustsec.org/advisories/RUSTSEC-2025-0173.html",
        "https://github.com/lvkv/pam-rs/issues/16"
      ],
      "provider_metadata": {
        "license": "CC0-1.0"
      }
    },
    "related_cves": [],
    "security_relevant": true,
    "severity_evidence": null
  },
  "source_id": "core-osv",
  "document_id": 454186,
  "published_at": "2025-06-02T12:00:00+00:00"
}