CVE-2023-42456 json
sudo-rs Session File Relative Path Traversal vulnerability
published 2023-09-21 3 y ago modified 2026-10-13 26 d ago also GHSA-2r3c-m6v7-9354 , RUSTSEC-2023-0069 , EUVD-2023-2397
- cvss
- 3.3
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 0.6%
- EPSS 0.6% chance of exploitation in 30 days, percentile 50%
- public exploits
- 0
- none known
Summary
Sudo-rs, a memory safe implementation of sudo and su, allows users to not have to enter authentication at every sudo attempt, but instead only requiring authentication every once in a while in every terminal or process group. Only once a configurable timeout has passed will the user have to re-authenticate themselves. Supporting this functionality is a set of session files (timestamps) for each user, stored in `/var/run/sudo-rs/ts`. These files are named according to the username from which the sudo attempt is made (the origin user).
An issue was discovered in versions prior to 0.2.1 where usernames containing the `.` and `/` characters could result in the corruption of specific files on the filesystem. As usernames are generally not limited by the characters they can contain, a username appearing to be a relative path can be constructed. For example we could add a user to the system containing the username `../../../../bin/cp`. When logged in as a user with that name, that user could run `sudo -K` to clear their session record file. The session code then constructs the path to the session file by concatenating the username to the session file storage directory, resulting in a resolved path of `/bin/cp`. The code then clears that file, resulting in the `cp` binary effectively being removed from the system.
An attacker needs to be able to login as a user with a constructed username. Given that such a username is unlikely to exist on an existing system, they will also need to be able to create the users with the constructed usernames.
The issue is patched in version 0.2.1 of sudo-rs. Sudo-rs now uses the uid for the user instead of their username for determining the filename. Note that an upgrade to this version will result in existing session files being ignored and users will be forced to re-authenticate. It also fully eliminates any possibility of path traversal, given that uids are always integer values.
The `sudo -K` and `sudo -k` commands can run, even if a user has no sudo access. As a workaround, make sure that one's system does not contain any users with a specially crafted username. While this is the case and while untrusted users do not have the ability to create arbitrary users on the system, one should not be able to exploit this issue.
Patch / fix
- crates.io sudo-rs 0.2.1
- memorysafety sudo 0.2.1
- sudo openSUSE Tumbleweed 1.9.15p2-1.1
opensuse advisories openSUSE-SU-2024:13490-1
CISA SSVC
- Exploitation
- none
- Automatable
- no
- Technical impact
- partial
- Assessed
- 2 y ago
Exploit prediction
0.63% chance of exploitation in the next 30 days, higher than 50% of all scored CVEs (FIRST EPSS, 2026-11-08).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 3.3 | CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L |
| NVD | 3.1 | 8.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H |
| GitHub | 3.1 | 3.3 | CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L |
| OSV | 3.1 | 3.1 | CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:N/I:L/A:L |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| crates.io | sudo-rs | <0.2.1 >=0.0.0-0, <0.2.1 |
0.2.1 |
Affected products
- memorysafety sudo-rs
Classification
References
-
github.com
/memorysafety/sudo-rs/commit/bfdbda22968e3de43fa8246cab1681cfd5d5493d
web, patch
-
github.com
/memorysafety/sudo-rs/security/advisories/GHSA-2r3c-m6v7-9354
web, vendor-advisory
-
github.com
/trifectatechfoundation/sudo-rs/security/advisories/GHSA-2r3c-m6v7-9354
web
-
openwall.com
/lists/oss-security/2023/11/02/1
web
- ferrous-systems.com /blog/sudo-rs-audit/
-
nvd.nist.gov
/vuln/detail/CVE-2023-42456
advisory
-
ferrous-systems.com
/blog/sudo-rs-audit
web
-
github.com
/advisories/GHSA-2r3c-m6v7-9354
advisory
-
github.com
/memorysafety/sudo-rs
package
-
rustsec.org
/advisories/RUSTSEC-2023-0069.html
web, advisory
-
crates.io
/crates/sudo-rs
package
-
cve.mitre.org
/cgi-bin/cvename.cgi?name=CVE-2023-42456
web
Sources
- CVE List CVE-2023-42456
- GitHub Advisory GHSA-2r3c-m6v7-9354
- NVD CVE-2023-42456
- OSV RUSTSEC-2023-0069
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.