{"id":"CVE-2023-42456","aliases":["CVE-2023-42456","GHSA-2r3c-m6v7-9354","RUSTSEC-2023-0069"],"related":[],"kind":"vulnerability","state":"published","title":"sudo-rs Session File Relative Path Traversal vulnerability","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).\n\nAn 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.\n\nAn 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.\n\nThe 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.\n\nThe `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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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).\n\nAn 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.\n\nAn 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.\n\nThe 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.\n\nThe `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.","source":"cvelist"},{"lang":"en","text":"### Background\n\nSudo-rs 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).\n\n### Impact\n\nAn issue was discovered where usernames containing the `.` and `/` characters could result in the corruption of specific files on the filesystem. On some operating systems usernames are not limited as to the characters they can contain, so 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.\n\nAn 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.\n\n### Affected systems\nDebian bookworm (and earlier) and Ubuntu 24.04 (and earlier) allow creating of these usernames using `useradd` without warning. On most other systems and later versions an attempt to create such users will result in an error.\n\n### Patches\nThe bug is fixed 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.\n\n### Workarounds\nThe `sudo -K` and `sudo -k` commands can run, even if a user has no sudo access. Make sure that your 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 your system you should not be able to exploit this issue.\n\n### References\nThis issue was identified by Andrea Jegher from Radically Open Security during an audit of the sudo-rs code. The same problem existed in original sudo and was fixed in version 1.9.15.\n\n### Notes\nThis advisory was updated in 2026 to better reflect the fact that \"path-like\" user names are normally forbidden from creation, and the CVSS score downgraded accordingly.","format":"markdown","source":"ghsa"},{"lang":"en","text":"## Impact\nAn issue was discovered 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.\n\nAn 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.\n\n## Patches\nThe bug is fixed 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.\n\nThe issue was corrected in commit `bfdbda22968e3de43fa8246cab1681cfd5d5493d`.","format":"markdown","source":"rustsec"},{"lang":"es","text":"Sudo-rs, una implementación segura de memoria de sudo y su, permite a los usuarios no tener que ingresar autenticación en cada intento de sudo, sino que solo requiere autenticación de vez en cuando en cada terminal o grupo de procesos. Solo una vez que haya transcurrido un tiempo de espera configurable, el usuario deberá volver a autenticarse. Esta funcionalidad admite un conjunto de archivos de sesión (marcas de tiempo) para cada usuario, almacenados en `/var/run/sudo-rs/ts`. Estos archivos se nombran según el nombre de usuario desde el que se realiza el intento de sudo (el usuario de origen). Se descubrió un problema en versiones anteriores a la 0.2.1 donde los nombres de usuario que contenían los caracteres `.` y `/` podían provocar la corrupción de archivos específicos en el sistema de archivos. Como los nombres de usuario generalmente no están limitados por los caracteres que pueden contener, se puede construir un nombre de usuario que parezca un Path Traversal. Por ejemplo, podríamos agregar un usuario al sistema que contenga el nombre de usuario `../../../../bin/cp`. Cuando iniciaba sesión como usuario con ese nombre, ese usuario podía ejecutar `sudo -K` para borrar su archivo de registro de sesión. Luego, el código de sesión construye la ruta al archivo de sesión concatenando el nombre de usuario al directorio de almacenamiento del archivo de sesión, lo que da como resultado una ruta resuelta de `/bin/cp`. Luego, el código borra ese archivo, lo que da como resultado que el binario `cp` se elimine efectivamente del sistema. Un atacante debe poder iniciar sesión como usuario con un nombre de usuario construido. Dado que es poco probable que dicho nombre de usuario exista en un sistema existente, también deberán poder crear usuarios con los nombres de usuario creados. El problema se solucionó en la versión 0.2.1 de sudo-rs. Sudo-rs ahora usa el uid del usuario en lugar de su nombre de usuario para determinar el nombre del archivo. Tenga en cuenta que una actualización a esta versión hará que se ignoren los archivos de sesión existentes y los usuarios se verán obligados a volver a autenticarse. También elimina por completo cualquier posibilidad de Path Traversal, dado que los uids son siempre valores enteros. Los comandos `sudo -K` y `sudo -k` se pueden ejecutar, incluso si un usuario no tiene acceso a sudo. Como workaround, asegúrese de que su sistema no contenga ningún usuario con un nombre de usuario especialmente manipulado. Si bien este es el caso y aunque los usuarios que no son de confianza no tienen la capacidad de crear usuarios arbitrarios en el sistema, no se debería poder explotar este problema.","source":"nvd"}],"published":"2023-09-21T15:20:56.969Z","modified":"2026-10-13T15:19:21.929Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L","score":3.3,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L","score":3.3,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L","score":3.3,"rating":"LOW"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:N/I:L/A:L","score":3.1,"rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"}],"cwes":["CWE-22","CWE-23"],"affected":[{"ranges":[{"version":"< 0.2.1","status":"affected"}],"vendor":"memorysafety","product":"sudo-rs","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.2.1"}],"ecosystem":"crates.io","package":"sudo-rs","purl":"pkg:cargo/sudo-rs","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.2.1"}],"ecosystem":"crates.io","package":"sudo-rs","purl":"pkg:cargo/sudo-rs","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"0.2.1"}],"vendor":"memorysafety","product":"sudo","cpe":"cpe:2.3:a:memorysafety:sudo:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/trifectatechfoundation/sudo-rs/security/advisories/GHSA-2r3c-m6v7-9354","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/memorysafety/sudo-rs/commit/bfdbda22968e3de43fa8246cab1681cfd5d5493d","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","rustsec","nvd"]},{"url":"https://github.com/memorysafety/sudo-rs/security/advisories/GHSA-2r3c-m6v7-9354","tags":["vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"http://www.openwall.com/lists/oss-security/2023/11/02/1","tags":["web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://ferrous-systems.com/blog/sudo-rs-audit/","tags":["x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-42456","tags":["advisory"],"sources":["ghsa"]},{"url":"https://ferrous-systems.com/blog/sudo-rs-audit","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/advisories/GHSA-2r3c-m6v7-9354","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/memorysafety/sudo-rs","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2023-0069.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/sudo-rs","tags":["package"],"sources":["rustsec"]},{"url":"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-42456","tags":["web"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-09-24T14:48:35.595Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-42456","url":"https://www.cve.org/CVERecord?id=CVE-2023-42456","licence":"CVE Terms of Use","modified":"2026-06-10T13:43:28.414Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2r3c-m6v7-9354","url":"https://github.com/advisories/GHSA-2r3c-m6v7-9354","licence":"CC-BY-4.0","modified":"2026-06-10T14:00:09.013Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2023-0069","url":"https://rustsec.org/advisories/RUSTSEC-2023-0069.html","licence":"CC0-1.0","modified":"2026-10-13T15:19:21.929Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-42456","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-42456","licence":"Public domain","modified":"2026-06-17T06:23:52.197Z"}],"updatedAt":"2026-11-25T22:58:28.057Z","epss":{"score":0.00625,"percentile":0.51314,"date":"2026-12-01T12:00:22.000Z"}}