CVE-2023-42456: Sudo rs Path Traversal Vulnerability

LOW
Advisory Identifier: GHSA-2r3c-m6v7-9354
CVSS 3.3
CWE-23 CWE-22
Published
Advisory Summary

CVE-2023-42456 is a LOW (CVSS 3.3) path traversal vulnerability (CWE-23: Relative Path Traversal) affecting Sudo rs libraries in the crates.io ecosystem. The issue involves sudo-rs session file relative path traversal vulnerability. Remediation is available by upgrading affected packages to version 0.2.1.

CVE-2023-42456 at a Glance

CVE Identifier CVE-2023-42456
GHSA Identifier GHSA-2r3c-m6v7-9354
Severity LOW
CVSS v3.1 Base Score 3.3
CWE Classification CWE-23: Relative Path Traversal
Affected Product Sudo rs
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 3.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2023-42456

To remediate this vulnerability, upgrade all affected Sudo rs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

sudo-rs fixed: 0.2.1
Upgrade sudo-rs to 0.2.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for sudo-rs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-42456, inspect your project dependencies for Sudo rs:

inspect dependencies for sudo-rs

Analyze the terminal output to locate any version of Sudo rs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.2.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-23: Relative Path Traversal, where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. In Sudo rs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Background Sudo-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). ### Impact An 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. 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. ### Affected systems Debian 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. ### Patches The 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. ### Workarounds The `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. ### References This 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. ### Notes This 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.

CVE-2023-42456 Affected Sudo rs Versions

1 component(s)
Fixed Versions:
0.2.1
Product / Package Ecosystem Affected Versions Fixed Version
sudo-rs
crates.io
< 0.2.1
0.2.1

References

Frequently Asked Questions

What is CVE-2023-42456?
CVE-2023-42456 is a security vulnerability in Sudo rs involving sudo-rs Session File Relative Path Traversal vulnerability under CWE-23: Relative Path Traversal.
Which Sudo rs versions are affected?
Affected versions include releases prior to 0.2.1 across affected packages: sudo-rs.
What version fixes CVE-2023-42456?
Upgrading to 0.2.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sudo-rs affected?
Yes, sudo-rs is affected in releases prior to 0.2.1. Upgrade your dependency to 0.2.1 or later.
What is the CVSS score of CVE-2023-42456?
CVE-2023-42456 has a CVSS v3.1 base score of 3.3 (LOW) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L.
What CWE is associated with CVE-2023-42456?
CVE-2023-42456 is classified under CWE-23: Relative Path Traversal (The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.).
How can I check crates.io dependencies for CVE-2023-42456?
Run the dependency tree command: 'inspect dependencies for sudo-rs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2r3c-m6v7-9354",
  "modified" : "2026-06-10T13:42:26Z",
  "published" : "2023-09-21T17:07:15Z",
  "aliases" : [ "CVE-2023-42456" ],
  "summary" : "sudo-rs Session File Relative Path Traversal vulnerability",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "sudo-rs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.2.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.2.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/memorysafety/sudo-rs/security/advisories/GHSA-2r3c-m6v7-9354"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/trifectatechfoundation/sudo-rs/security/advisories/GHSA-2r3c-m6v7-9354"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-42456"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/memorysafety/sudo-rs/commit/bfdbda22968e3de43fa8246cab1681cfd5d5493d"
  }, {
    "type" : "WEB",
    "url" : "https://ferrous-systems.com/blog/sudo-rs-audit"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-2r3c-m6v7-9354"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/memorysafety/sudo-rs"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2023-0069.html"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2023/11/02/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-23" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-09-21T17:07:15Z",
    "nvd_published_at" : "2023-09-21T16:15:09Z"
  }
}