2026-03-02 19:17CVE-2026-21882GitHub_M
PUBLISHED5.2CWE-273CWE-269CWE-250

theshit's Improper Privilege Dropping Allows Local Privilege Escalation via Command Re-execution

theshit is a command-line utility that automatically detects and fixes common mistakes in shell commands. Prior to version 0.2.0, improper privilege dropping allows local privilege escalation via command re-execution. This issue has been patched in version 0.2.0.

Problem type

Affected products

AsfhtgkDavid

theshit

< 0.2.0 - AFFECTED

References

GitHub Security Advisories

GHSA-2j3p-gqw5-g59j

theshit's Improper Privilege Dropping Allows Local Privilege Escalation via Command Re-execution

https://github.com/advisories/GHSA-2j3p-gqw5-g59j

Impact

Vulnerability Type: Local Privilege Escalation (LPE) / Improper Privilege Management / Arbitrary Command Execution.

The application automatically re-executes the previously failed command but does not properly drop elevated privileges during this process.

When the tool is executed with sudo or otherwise runs with an effective UID of root, it records the last executed command and attempts to rerun it. However, the application fails to restore the original unprivileged user context before re-executing the command. As a result, the retried command is executed with root privileges, even if the original command was issued by an unprivileged user.

This allows a local attacker to intentionally trigger a failed command under elevated execution and gain arbitrary command execution as root via the retry mechanism.

Who is impacted: Any system where this tool is executed with elevated privileges is affected. The risk is especially high in environments where the tool is permitted to run via sudo, including configurations with NOPASSWD, as an unprivileged user can escalate privileges to root without additional interaction.

Proof of Concept

To verify the vulnerability without a shell, attempt to create a file in a root-protected directory.

1. Verify the file does not exist

sudo ls /root/proof_of_lpe
# Output: No such file or directory

2. Run the vulnerable command

sudo bash -c "SH_PREV_CMD='touch /root/proof_of_lpe' target/release/theshit fix"

3. Check if the file was created by root

sudo ls -l /root/proof_of_lpe

Expected Result: The command succeeds silently, and the file /root/proof_of_lpe is created, confirming arbitrary command execution with root privileges.

Patches

The issue has been fixed in version 0.1.2.

The patch ensures that privilege levels are correctly handled during command re-execution. Before retrying any previously executed command, the application now explicitly resets the effective UID and GID to the original invoking user.

Workarounds

If upgrading is not possible, users should avoid executing the application with sudo or as the root user.

As a temporary mitigation, administrators should restrict the use of the tool in privileged contexts and ensure it is not included in sudoers configurations, particularly with NOPASSWD. Running the tool strictly as an unprivileged user prevents exploitation of the retry mechanism.

References

  • Commit fixing the issue
  • CWE-269: Improper Privilege Management
  • CWE-273: Improper Check for Dropped Privileges
  • CWE-250: Execution with Unnecessary Privileges

JSON source

https://cveawg.mitre.org/api/cve/CVE-2026-21882
Click to expand
{
  "dataType": "CVE_RECORD",
  "dataVersion": "5.2",
  "cveMetadata": {
    "cveId": "CVE-2026-21882",
    "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
    "assignerShortName": "GitHub_M",
    "dateUpdated": "2026-03-02T19:44:41.557Z",
    "dateReserved": "2026-01-05T17:24:36.928Z",
    "datePublished": "2026-03-02T19:17:22.220Z",
    "state": "PUBLISHED"
  },
  "containers": {
    "cna": {
      "providerMetadata": {
        "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
        "shortName": "GitHub_M",
        "dateUpdated": "2026-03-02T19:17:22.220Z"
      },
      "title": "theshit's Improper Privilege Dropping Allows Local Privilege Escalation via Command Re-execution",
      "descriptions": [
        {
          "lang": "en",
          "value": "theshit is a command-line utility that automatically detects and fixes common mistakes in shell commands. Prior to version 0.2.0, improper privilege dropping allows local privilege escalation via command re-execution. This issue has been patched in version 0.2.0."
        }
      ],
      "affected": [
        {
          "vendor": "AsfhtgkDavid",
          "product": "theshit",
          "versions": [
            {
              "version": "< 0.2.0",
              "status": "affected"
            }
          ]
        }
      ],
      "problemTypes": [
        {
          "descriptions": [
            {
              "lang": "en",
              "description": "CWE-273: Improper Check for Dropped Privileges",
              "cweId": "CWE-273",
              "type": "CWE"
            }
          ]
        },
        {
          "descriptions": [
            {
              "lang": "en",
              "description": "CWE-269: Improper Privilege Management",
              "cweId": "CWE-269",
              "type": "CWE"
            }
          ]
        },
        {
          "descriptions": [
            {
              "lang": "en",
              "description": "CWE-250: Execution with Unnecessary Privileges",
              "cweId": "CWE-250",
              "type": "CWE"
            }
          ]
        }
      ],
      "references": [
        {
          "url": "https://github.com/AsfhtgkDavid/theshit/security/advisories/GHSA-2j3p-gqw5-g59j",
          "name": "https://github.com/AsfhtgkDavid/theshit/security/advisories/GHSA-2j3p-gqw5-g59j",
          "tags": [
            "x_refsource_CONFIRM"
          ]
        },
        {
          "url": "https://github.com/AsfhtgkDavid/theshit/commit/5293957b119e55212dce2c6dcbaf1d7eb794602a",
          "name": "https://github.com/AsfhtgkDavid/theshit/commit/5293957b119e55212dce2c6dcbaf1d7eb794602a",
          "tags": [
            "x_refsource_MISC"
          ]
        }
      ],
      "metrics": [
        {
          "cvssV3_1": {
            "version": "3.1",
            "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
            "attackVector": "LOCAL",
            "attackComplexity": "LOW",
            "privilegesRequired": "NONE",
            "userInteraction": "NONE",
            "scope": "UNCHANGED",
            "confidentialityImpact": "HIGH",
            "integrityImpact": "HIGH",
            "availabilityImpact": "HIGH",
            "baseScore": 8.4,
            "baseSeverity": "HIGH"
          }
        }
      ]
    },
    "adp": [
      {
        "providerMetadata": {
          "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
          "shortName": "CISA-ADP",
          "dateUpdated": "2026-03-02T19:44:41.557Z"
        },
        "title": "CISA ADP Vulnrichment",
        "metrics": [
          {}
        ]
      }
    ]
  }
}