{"answers":{"affected":"1 open source package ship an affected version, including pam-bindings.","exploited":"There is no known exploitation of RUSTSEC-2025-0173 in the wild and no public exploit code.","fix":"Upgrade pam-bindings to 0.1.2 or later.","what":"RUSTSEC-2025-0173 is a vulnerability in pam-bindings, published on 2 Jun 2025."},"fix_prompt":"Check this codebase for RUSTSEC-2025-0173 and fix it if it is affected.\n\nWhat it is: RUSTSEC-2025-0173 is a vulnerability in pam-bindings, published on 2 Jun 2025. \nExploitation: There is no known exploitation of RUSTSEC-2025-0173 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- pam-bindings (crates.io): affected from 0.0.0-0; fixed in 0.1.2\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/RUSTSEC-2025-0173/ (Markdown: https://insights.sbomify.com/RUSTSEC-2025-0173/index.md)","id":"RUSTSEC-2025-0173","markdown":"https://insights.sbomify.com/RUSTSEC-2025-0173/index.md","name":"RUSTSEC-2025-0173","record":{"aliases":[],"analysis":null,"analysis_generated_by":null,"assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"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: \u0026mut PamHandle, args: Vec\u003c\u0026CStr\u003e, flags: PamFlag) -\u003e 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 (`\u0026*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 `\u0026mut *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","ecosystems":["crates.io"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"`PamHandle::get_user` can cause an authentication bypass","id":"RUSTSEC-2025-0173","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"crates.io","product":null,"products":[],"type":null,"year":"2025"},"n_packages":1,"n_references":null,"packages":[{"ecosystem":"crates.io","fixed":["0.1.2"],"introduced":["0.0.0-0"],"last_affected":[],"package":"pam-bindings","purl":"pkg:cargo/pam-bindings","source":"RUSTSEC-2025-0173"}],"products":null,"published":"2025-06-02","related":[],"sources":[{"class":"open","licence":"CC0 1.0","name":"RustSec","prefix":"RUSTSEC"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":null,"url":"https://insights.sbomify.com/RUSTSEC-2025-0173/"}