CVE-2021-31607: Salt Command Injection Vulnerability

HIGH
Advisory Identifier: GHSA-hcjf-rp5h-g5h3
CVSS 7.8
CWE-78 CWE-77
Published
Advisory Summary

CVE-2021-31607 is a HIGH (CVSS 7.8) command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Salt libraries in the PyPI ecosystem. The issue involves command injection in saltstack salt. Remediation is available by upgrading affected packages to version 3003rc1.

CVE-2021-31607 at a Glance

CVE Identifier CVE-2021-31607
GHSA Identifier GHSA-hcjf-rp5h-g5h3
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Salt
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.8

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

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

How to Fix CVE-2021-31607

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

salt fixed: 3003rc1
pip install salt>=3003rc1
Verify Direct and Transitive Dependencies

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

pip show salt

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2021-31607, inspect your installed packages using pip:

pip show salt

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

Note: The pip show salt command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Salt, 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

In SaltStack Salt 2016.9 through 3002.6, a command injection vulnerability exists in the snapper module that allows for local privilege escalation on a minion. The attack requires that a file is created with a pathname that is backed up by snapper, and that the master calls the snapper.diff function (which executes popen unsafely).

CVE-2021-31607 Affected Salt Versions

1 component(s)
Fixed Versions:
3003rc1
Product / Package Ecosystem Affected Versions Fixed Version
salt
PyPI
≥ 2016.11.0
< 3003rc1
3003rc1

References

NVD — CVE-2021-31607 NVD
https://nvd.nist.gov/vuln/detail/CVE-2021-31607
Salt Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/salt/PYSEC-2021-56.yaml
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2021/11/msg00009.html
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/6BUWUF5VTENNP2ZYZBVFKPSUHLKLUBD5
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ACVT7M4YLZRLWWQ6SGRK3C6TOF4FXOXT
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LDKMAJXYFHM4USVX3H5V2GCCBGASWUSM
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/MBAHHSGZLEJRCG4DX6J4RBWJAAWH55RQ
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/6BUWUF5VTENNP2ZYZBVFKPSUHLKLUBD5
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ACVT7M4YLZRLWWQ6SGRK3C6TOF4FXOXT
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LDKMAJXYFHM4USVX3H5V2GCCBGASWUSM
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MBAHHSGZLEJRCG4DX6J4RBWJAAWH55RQ
sec.stealthcopter.com/saltstack-snapper-m... WEB
https://sec.stealthcopter.com/saltstack-snapper-minion-privledge-escaltion
Salt Security Information SECURITY
https://security.gentoo.org/glsa/202310-22
Salt Security Information SECURITY
https://www.debian.org/security/2021/dsa-5011

Frequently Asked Questions

What is CVE-2021-31607?
CVE-2021-31607 is a security vulnerability in Salt involving Command Injection in SaltStack Salt under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Salt versions are affected?
Affected versions include releases prior to 3003rc1 across affected packages: salt.
What version fixes CVE-2021-31607?
Upgrading to 3003rc1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is salt affected?
Yes, salt is affected in releases prior to 3003rc1. Upgrade your dependency to 3003rc1 or later.
What is the CVSS score of CVE-2021-31607?
CVE-2021-31607 has a CVSS v3.1 base score of 7.8 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-31607?
CVE-2021-31607 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check PyPI dependencies for CVE-2021-31607?
Run the dependency tree command: 'pip show salt'. 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-hcjf-rp5h-g5h3",
  "modified" : "2024-10-23T18:32:07Z",
  "published" : "2022-05-24T17:48:21Z",
  "aliases" : [ "CVE-2021-31607" ],
  "summary" : "Command Injection in SaltStack Salt",
  "details" : "In SaltStack Salt 2016.9 through 3002.6, a command injection vulnerability exists in the snapper module that allows for local privilege escalation on a minion. The attack requires that a file is created with a pathname that is backed up by snapper, and that the master calls the snapper.diff function (which executes popen unsafely).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "salt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2016.11.0"
      }, {
        "fixed" : "3003rc1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3002.6"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-31607"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/salt/PYSEC-2021-56.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2021/11/msg00009.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/6BUWUF5VTENNP2ZYZBVFKPSUHLKLUBD5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ACVT7M4YLZRLWWQ6SGRK3C6TOF4FXOXT"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LDKMAJXYFHM4USVX3H5V2GCCBGASWUSM"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/MBAHHSGZLEJRCG4DX6J4RBWJAAWH55RQ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/6BUWUF5VTENNP2ZYZBVFKPSUHLKLUBD5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ACVT7M4YLZRLWWQ6SGRK3C6TOF4FXOXT"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LDKMAJXYFHM4USVX3H5V2GCCBGASWUSM"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MBAHHSGZLEJRCG4DX6J4RBWJAAWH55RQ"
  }, {
    "type" : "WEB",
    "url" : "https://sec.stealthcopter.com/saltstack-snapper-minion-privledge-escaltion"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202310-22"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2021/dsa-5011"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77", "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-23T06:37:59Z",
    "nvd_published_at" : "2021-04-23T06:15:00Z"
  }
}