CVE-2023-42456: sudo-rs Session File Relative Path Traversal vulnerability
Summary
CVE-2023-42456: sudo-rs Session File Relative Path Traversal vulnerability. Affects sudo-rs versions < 0.2.1. Fixed in 0.2.1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Sudo-rs is a tool that allows users to authenticate themselves for sudo attempts only once in a while, instead of every time. It achieves this by using session files (timestamps) stored in /var/run/sudo-rs/ts. These files are named after the username of the user making the sudo attempt. The vulnerability in sudo-rs allows for the corruption of specific files on the filesystem when usernames containing certain characters are used.
Vulnerability Detail
The vulnerability arises when usernames containing the '.' and '/' characters are used. These characters can be used to construct a username that appears to be a relative path. For example, a user with the username '../../../../bin/cp' can 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, effectively removing the 'cp' binary from the system. This vulnerability requires the ability to login as a user with a constructed username and the ability to create users with such usernames.
How To Fix
Latest published version: 0.2.15 as of 23 Oct 2026
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
0.2.1
This is the first release that contains the fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If you do not have any users with specially crafted usernames and untrusted users cannot create arbitrary users on your system, you should not be vulnerable to this issue. However, you can also run 'sudo -K' or 'sudo -k' commands to clear session records, even if you have no sudo access.
Conclusion
The sudo-rs Session File Relative Path Traversal vulnerability allows for the corruption of files on the filesystem, potentially leading to the removal of important binaries. Upgrading to version 0.2.1 of sudo-rs fixes this vulnerability by using the uid instead of the username for determining the filename. If you are not vulnerable to this issue, you can still use the 'sudo -K' or 'sudo -k' commands to clear session records. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for sudo-rs →
FAQ
Sudo-rs is a tool that allows users to authenticate themselves for sudo attempts only once in a while, instead of every time.
The vulnerability allows for the corruption of specific files on the filesystem, potentially leading to the removal of important binaries.
You can fix this vulnerability by upgrading to version 0.2.1 of sudo-rs, which uses the uid instead of the username for determining the filename.
Yes, you can use the 'sudo -K' or 'sudo -k' commands to clear session records, even if you have no sudo access.
If you do not have any users with specially crafted usernames and untrusted users cannot create arbitrary users on your system, you should not be vulnerable to this issue.
References
Related vulnerabilities
Recent vulnerabilities recorded for sudo-rs.