{"id":"RUSTSEC-2025-0173","revision":null,"records":[{"revision":"eaa7a00f083b4aa982d487e72b4f9058","observedAt":"2026-10-26T14:35:44.727+00:00","statement":{"source":"osv","id":"RUSTSEC-2025-0173","aliases":[],"title":"`PamHandle::get_user` can cause an authentication bypass","description":"In affected versions, `PamHandle::get_user` can return `Err(PAM_SUCCESS)` after it gets the username successfully.\nPAM 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.\nThis means a user could log in when they shouldn't be able to (e.g., if the module is `sufficient`).\n\nThe `pam_try!` macro of this crate early-returns the code in this exact way:\n\n```rust\nfn sm_authenticate(pamh: &mut PamHandle, args: Vec<&CStr>, flags: PamFlag) -> PamResultCode {\n    let user = pam_try!(pamh.get_user(None)); // Can return PAM_SUCCESS here.\n    // If it does, the module does not get to this line.\n}\n```\n\nThe root cause is an [incorrect FFI declaration][ffi-decl] for [`pam_get_user(3)`][pam-get-user].\nThis C function writes a pointer to the username through its `user` argument (of type `const char **user`).\nThis crate's binding declared this argument as a shared reference (`&*mut c_char`).\nWriting through a shared reference is [undefined behavior][ub-immutable].\n\nThus, the compiler can assume that the local pointer, whose address is passed as `user`, is still null after the call.\nAfter the call, the affected code [returns `Ok`][null-check] only if the return code is `PAM_SUCCESS` *and* this pointer is not null.\nOtherwise, it returns the return code as an error.\nIf the compiler assumes that the pointer is null, `get_user` returns an error even when the return code is `PAM_SUCCESS`.\nRelease builds have been [observed to do this][observed-irl].\nDebug builds usually work correctly, so tests in debug mode can miss the problem.\n\nVersion 0.1.2 changes the declaration to `&mut *const c_char`.\nThe fix is in commit [401c961](https://github.com/lvkv/pam-rs/commit/401c961800c4dde356464b6a7d455af844a3954a).\n\nIf a module cannot upgrade, do not return the error code from `get_user`.\nReturn a failure code instead, for example `pam_try!(pamh.get_user(None), PamResultCode::PAM_AUTH_ERR)`.\nThis makes the module deny access instead of allowing it, but the undefined behavior remains.\n\n[pam-get-user]: https://github.com/linux-pam/linux-pam/blob/28fce1fd55b003fec90f34e5bc785e9439b216f2/libpam/include/security/pam_modules.h#L30-L31\n[ffi-decl]: https://github.com/lvkv/pam-rs/blob/3d9318b5b812d9142595928deec23e5843a60995/pam/src/module.rs#L49-L53\n[ub-immutable]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html#r-undefined.immutable\n[null-check]: https://github.com/lvkv/pam-rs/blob/3d9318b5b812d9142595928deec23e5843a60995/pam/src/module.rs#L196-L202\n[observed-irl]: https://github.com/lvkv/pam-rs/issues/16#issuecomment-3693665220","state":0,"publishedAt":"2025-06-02T12:00:00+00:00","modifiedAt":"2026-10-26T14:00:04.2374154+00:00","affected":[{"ecosystem":"crates.io","name":"pam-bindings","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0.0.0-0"},{"kind":"fixed","version":"0.1.2"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[],"references":["https://crates.io/crates/pam-bindings","https://rustsec.org/advisories/RUSTSEC-2025-0173.html","https://github.com/lvkv/pam-rs/issues/16"],"sourceUrl":"https://osv.dev/vulnerability/RUSTSEC-2025-0173","license":"OSV · upstream source license applies","key":"osv:RUSTSEC-2025-0173","identifiers":["RUSTSEC-2025-0173"]},"retained":false,"historicalAffected":[]}],"coverage":[{"source":"cisa-kev:global","scope":"Complete CISA KEV catalog; all vendors. Missing entries do not establish absence of exploitation.","generation":"2026-10-28T10:33:32.5344446+00:00","complete":true,"records":1760,"lastAttemptAt":"2026-10-28T10:33:32.5344446+00:00","lastSuccessAt":"2026-10-28T10:33:32.6834837+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:32.6834858+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"cve-program","scope":"Official CVE Program baseline and cumulative hourly delta; all vendors, published and rejected records","generation":"cve-d2186f400c54d65f61687f78bb1a00d184d2e215877d0194d7ed70caee809a44-dbe935b5c0445aa8bf0ad6eee2fdccbed1511848550405783cb6764f13f2cea1","complete":true,"records":415637,"lastAttemptAt":"2026-10-28T10:33:28.1218743+00:00","lastSuccessAt":"2026-10-28T10:33:28.0918568+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:28.1218743+00:00","snapshotPublishedAt":"2026-10-28T10:28:43+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"euvd","scope":"Rolling EUVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global EUVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-faed4bf7c3b54b258c46962bb8c893c7","complete":false,"records":13230,"lastAttemptAt":"2026-10-28T10:34:55.4095227+00:00","lastSuccessAt":"2026-10-28T10:34:55.4624366+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:34:55.4624366+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"first-epss:nuget","scope":"FIRST EPSS for explicit CVE aliases in the collected public NuGet archive. Not a global EPSS backfill.","generation":"2026-10-28T10:33:32.5344446+00:00","complete":true,"records":1093,"lastAttemptAt":"2026-10-28T10:33:32.5344446+00:00","lastSuccessAt":"2026-10-28T10:33:32.6846081+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:32.6846084+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"nvd","scope":"Rolling NVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global NVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-8d16a738328646698f9217d8ea11893c","complete":true,"records":13449,"lastAttemptAt":"2026-10-28T10:33:33.1463542+00:00","lastSuccessAt":"2026-10-27T22:48:29.491+00:00","error":null,"lastVerifiedAt":"2026-10-27T22:48:29.491+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":13514,"expectedIdentifiers":13514,"failedIdentifiers":0},{"source":"osv:Go","scope":"Complete OSV Go ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"go-f7cb12508d9e6a348c8a60f772ed85529cc80cd2ff853da1099b57754b20e943","complete":true,"records":9790,"lastAttemptAt":"2026-10-28T10:33:28.4933633+00:00","lastSuccessAt":"2026-10-27T21:49:03.9756799+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:28.4933633+00:00","snapshotPublishedAt":"2026-10-27T21:48:11+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:NuGet","scope":"Complete OSV NuGet ecosystem archive, including GitHub Advisory Database records; NuGet version matching only","generation":"nuget-72e5e79de0026dd0562d40734074a2236a06886643d67182b8381eaee757dbf7","complete":true,"records":1966,"lastAttemptAt":"2026-10-28T10:33:28.2877501+00:00","lastSuccessAt":"2026-10-27T21:46:38.0277323+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:28.2877501+00:00","snapshotPublishedAt":"2026-10-27T21:18:15+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:crates.io","scope":"Complete OSV crates.io ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"crates.io-9cc0e41ed4e75d0c111bed7fd0bbcd4f139c80cc1fc67f8c3d9a33a41da846ad","complete":true,"records":3002,"lastAttemptAt":"2026-10-28T10:33:32.5040876+00:00","lastSuccessAt":"2026-10-28T10:33:32.3653779+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:32.5040876+00:00","snapshotPublishedAt":"2026-10-28T09:02:50+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:npm","scope":"Complete OSV npm ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"npm-2ba4ef78ff3a54a3ff2eeaf8e09b7b84901727f582723b80c5b0279e777b2781","complete":true,"records":230857,"lastAttemptAt":"2026-10-28T10:33:28.3916004+00:00","lastSuccessAt":"2026-10-28T09:35:14.9469514+00:00","error":null,"lastVerifiedAt":"2026-10-28T10:33:28.3916004+00:00","snapshotPublishedAt":"2026-10-28T09:33:01+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null}]}