/

CVE-2025-54920

Severity:

HIGH RISK

(8.8)

Unsafe Deserialization in Apache Spark History Server Event

CVE-2025-54920

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution on Spark History Server host

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Apache Spark's History Server contains an unsafe Jackson deserialization flaw in how it parses event log JSON, allowing arbitrary class instantiation via polymorphic deserialization.

If an attacker can write to the Spark event logs directory, they can inject malicious JSON that triggers execution of unintended classes during deserialization, potentially leading to command execution on the host running the History Server.

Affected context

The issue appears in Apache Spark deployments that:

  • Enable event logging and persist logs to a filesystem or object store
  • Run the Spark History Server to load and analyze those event logs
  • Use versions of Spark where SparkListenerEvent objects are deserialized with Jackson polymorphic typing (e.g., 3.5.4 and earlier 3.x / affected 4.0 releases)

The vulnerability is relevant when the event log storage location is writable by users or processes that are not fully trusted, including shared clusters, multi-tenant environments, or misconfigured storage permissions.

Exploit preconditions

  • Attack surface: Spark History Web UI / History Server backend, specifically the event log loading/deserialization logic.
  • Required access: Ability to create, overwrite, or modify Spark event log files in the directory (or bucket) that the History Server reads from.
  • Trigger point: When the History Server starts or reloads/parses an event log file, it deserializes the injected JSON as SparkListenerEvent data.
  • Why exploitation is possible: Jackson is configured with @JsonTypeInfo.Id.CLASS for polymorphic deserialization of SparkListenerEvent objects, allowing the JSON payload to specify arbitrary class names. This enables construction of unexpected classes whose constructors or initialization logic can perform network calls or other side effects, effectively granting code execution capabilities.

Why this happens

The root cause is the use of overly permissive polymorphic deserialization in Jackson for untrusted event log data.

By using @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) or equivalent configuration on SparkListenerEvent, the deserializer trusts a class/type field from JSON to determine which Java class to instantiate. When this mechanism is applied to data that can be influenced by attackers (event logs), it becomes a classic CWE-502: Unsafe Deserialization scenario. Instead of restricting deserialization to a fixed, known set of event types, the system allows arbitrary class names, some of which may execute external calls or perform other actions during construction or initialization. This design ties data parsing directly to execution-capable behavior, which is the core unsafe pattern.

Potential impact

  • Remote code execution on the host running the Spark History Server via gadget chains or classes with side-effectful initialization.
  • Outbound network connections to attacker-controlled endpoints (e.g., JDBC, HTTP, RPC) enabling data exfiltration or pivoting.
  • Unauthorized access to sensitive cluster metadata, job information, or credentials accessible to the History Server process.
  • Use of the compromised History Server as a foothold for lateral movement across the Spark cluster or wider infrastructure.
  • Denial of service of the History Server process through malicious payloads that crash or hang deserialization.

General mitigation guidance

Effective mitigation centers on removing unsafe deserialization patterns and hardening the event log trust boundary:

  • Replace Jackson polymorphic deserialization based on Id.CLASS with a closed set of allowed subtypes (e.g., Id.NAME with explicit type mappings, or explicit DTOs).
  • Treat event logs as untrusted input, even when produced by Spark itself, and avoid tying deserialization directly to executable or side-effectful classes.
  • Introduce a strict schema for event log JSON and validate incoming data against that schema before deserialization.
  • Use dedicated, side-effect-free data structures for event representation instead of reusing classes that perform I/O, network access, or system operations in constructors or deserialization callbacks.
  • Apply least privilege to the History Server process (reduced OS permissions, no unnecessary credentials, network egress controls) to limit damage from a successful exploit.
  • Restrict write permissions to the event log directory or bucket to trusted principals only, and avoid sharing it broadly across tenants or untrusted jobs.

How teams detect issues like this

Detection can focus on both code-level patterns and operational indicators:

  • Use static analysis or code review to flag Jackson usage with:
  • @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) or equivalent polymorphic typing based on fully qualified class names.
  • Deserialization of data originating from files, logs, or network sources without prior validation.
  • During manual review, look for:
  • Event log or audit log parsers that deserialize directly into domain objects or connection-related classes.
  • Reuse of driver or connector classes (e.g., JDBC connection classes) as deserialization targets instead of pure data containers.
  • Employ SAST/IAST tools configured with rules for unsafe deserialization and dangerous Jackson configurations.
  • Monitor runtime behavior of the History Server for:
  • Unexpected outbound connections (e.g., JDBC connections to unrecognized hosts).
  • Crashes or exceptions related to Jackson deserialization when loading event logs.
  • Implement operational controls such as:
  • File integrity monitoring or checksums on event log directories to detect tampering.
  • Logging and alerting on changes to event log storage locations in multi-tenant or shared environments.

Sources

SourceLink
github.comgithub.com/apache/spark/pull/51312
github.comgithub.com/apache/spark/pull/51323
issues.apache.orgissues.apache.org/jira/browse/SPARK-52381
lists.apache.orglists.apache.org/thread/4y9n0nfj7m68o2hpmoxgc0y7dm1lo02s
openwall.comopenwall.com/lists/oss-security/2026/03/13/4

Frequently asked

questions

Exploitability is constrained by access to the event log storage. An attacker must be able to write or modify Spark event logs that the History Server later reads. In environments where logs are tightly controlled and not writable by untrusted users, the risk is lower; in shared or multi-tenant clusters with relaxed permissions, the risk is significantly higher.

Not necessarily in the traditional web authentication sense. The critical requirement is write access to the event log directory or bucket. That access might be granted via OS accounts, container permissions, Hadoop/S3 ACLs, or misconfigured storage policies, regardless of whether the attacker has direct access to the Spark History Web UI.

The most robust pattern is to remove Jackson polymorphic deserialization based on arbitrary class names and instead deserialize into a small, explicitly whitelisted set of event types or DTOs. Combine this with schema-based validation, and ensure that deserialized classes are side-effect free and do not perform network or system actions during construction or initialization.

Establish project-wide guidelines that treat all external data sources (logs, configuration files, network input, message queues) as untrusted, and forbid deserialization into arbitrary classes. Prefer explicit, versioned schemas and pure data structures for interchange formats. Augment this with automated checks in CI to detect dangerous deserialization patterns (e.g., Id.CLASS, enableDefaultTyping) and periodic security reviews of serialization frameworks and their configurations.

Find out what's already
exploitable in your codebase.