CVE-2022-31777: Pyspark Apache Spark Vulnerable To Log Vulnerability
MODERATECVE-2022-31777 is a MODERATE (CVSS 5.4) apache spark vulnerable to log vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Pyspark libraries in the PyPI ecosystem. The issue involves apache spark vulnerable to log injection. Remediation is available by upgrading affected packages to version 3.2.2, 3.3.1.
CVE-2022-31777 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2022-31777
To remediate this vulnerability, upgrade all affected Pyspark dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install pyspark>=3.2.2
pip install pyspark>=3.3.1
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.9.3</artifactId>
<version>Latest secure release</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.13</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.13</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>Latest secure release</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>Latest secure release</version>
</dependency>
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pyspark
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2022-31777, inspect your installed packages using pip:
pip show pyspark
Analyze the terminal output to locate any version of Pyspark in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.2), your application is affected.
Note: The pip show pyspark command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In Pyspark, 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
CVE-2022-31777 Affected Pyspark Versions
9 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pyspark
|
PyPI |
< 3.2.2
|
3.2.2
|
|
pyspark
|
PyPI |
≥ 3.3.0
< 3.3.1
All 1 versions
3.3.0
|
3.3.1
|
|
org.apache.spark:spark-core_2.9.3
|
Maven |
|
|
|
org.apache.spark:spark-core_2.13
|
Maven |
< 3.2.2
|
3.2.2
|
|
org.apache.spark:spark-core_2.13
|
Maven |
≥ 3.3.0
< 3.3.1
All 1 versions
3.3.0
|
3.3.1
|
|
org.apache.spark:spark-core_2.12
|
Maven |
< 3.2.2
|
3.2.2
|
|
org.apache.spark:spark-core_2.12
|
Maven |
≥ 3.3.0
< 3.3.1
All 1 versions
3.3.0
|
3.3.1
|
|
org.apache.spark:spark-core_2.11
|
Maven |
|
|
|
org.apache.spark:spark-core_2.10
|
Maven |
|
|
References
Frequently Asked Questions
What is CVE-2022-31777?
Which Pyspark versions are affected?
What version fixes CVE-2022-31777?
Is pyspark affected?
Is spark-core_2.9.3 affected?
What is the CVSS score of CVE-2022-31777?
What CWE is associated with CVE-2022-31777?
How can I check PyPI dependencies for CVE-2022-31777?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-43xg-8wmj-cw8h",
"modified" : "2025-12-18T15:59:36Z",
"published" : "2022-11-01T19:00:29Z",
"aliases" : [ "CVE-2022-31777" ],
"summary" : "Apache Spark vulnerable to Log Injection",
"details" : "A stored cross-site scripting (XSS) vulnerability in Apache Spark 3.2.1 and earlier, and 3.3.0, allows remote attackers to execute arbitrary JavaScript in the web browser of a user, by including a malicious payload into the logs which would be returned in logs rendered in the UI.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pyspark"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.2.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "pyspark"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.3.0"
}, {
"fixed" : "3.3.1"
} ]
} ],
"versions" : [ "3.3.0" ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.9.3"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "< 3.2.2"
}
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.13"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.2.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.13"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.3.0"
}, {
"fixed" : "3.3.1"
} ]
} ],
"versions" : [ "3.3.0" ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.12"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.2.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.12"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.3.0"
}, {
"fixed" : "3.3.1"
} ]
} ],
"versions" : [ "3.3.0" ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.11"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "< 3.2.2"
}
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.apache.spark:spark-core_2.10"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "< 3.2.2"
}
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31777"
}, {
"type" : "WEB",
"url" : "https://github.com/apache/spark/commit/ad90195de56688ce0898691eb9d04297ab0871ad"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/apache/spark"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pyspark/PYSEC-2022-42976.yaml"
}, {
"type" : "WEB",
"url" : "https://lists.apache.org/thread/60mgbswq2lsmrxykfxpqq13ztkm2ht6q"
}, {
"type" : "WEB",
"url" : "https://web.archive.org/web/20220728105026/https://issues.apache.org/jira/browse/SPARK-39505"
}, {
"type" : "WEB",
"url" : "http://www.openwall.com/lists/oss-security/2022/11/01/14"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-74" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-11-01T21:03:46Z",
"nvd_published_at" : "2022-11-01T16:15:00Z"
}
}