CVE-2018-6331

CRITICAL9.8/ 10.0
Share:
Published: December 31, 2018 at 11:29 PM
Modified: May 6, 2025 at 04:15 PM
Source: cve-assign@fb.com

Vulnerability Description

Buck parser-cache command loads/saves state using Java serialized object. If the state information is maliciously crafted, deserializing it could lead to code execution. This issue affects Buck versions prior to v2018.06.25.01.

CVSS Metrics

Base Score
9.8
Severity
CRITICAL
Vector String
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Weaknesses (CWE)

Source: cve-assign@fb.com
Source: nvd@nist.gov

AI Security Analysis

01 // Technical Summary

Buck, a build system, is vulnerable to remote code execution (RCE) due to insecure deserialization of Java serialized objects used for caching. Attackers can craft malicious serialized data to execute arbitrary code on systems running vulnerable versions of Buck, potentially leading to complete system compromise and data exfiltration.

02 // Vulnerability Mechanism

Step 1: Payload Creation: The attacker crafts a malicious Java serialized object. This object contains a payload designed to execute arbitrary code when deserialized. This payload often leverages Java's reflection capabilities to instantiate and invoke methods of classes that perform malicious actions, such as executing shell commands or accessing sensitive data.

Step 2: Payload Delivery: The attacker needs to inject the crafted serialized object into the Buck parser cache. This can be achieved by either directly providing the malicious cache file or by exploiting a vulnerability that allows the attacker to influence the contents of the cache. The specific method depends on the context of the Buck build process.

Step 3: Cache Loading: The vulnerable Buck parser-cache command attempts to load the malicious serialized object from the cache.

Step 4: Deserialization: The Java deserialization process is triggered, attempting to reconstruct the object from its serialized representation. Because the serialized object is malicious, this process will execute the attacker's code.

Step 5: Code Execution: The attacker's code executes within the context of the Buck build process, potentially allowing the attacker to execute arbitrary commands, access sensitive data, or compromise the build environment.

03 // Deep Technical Analysis

The vulnerability stems from the use of Java's built-in serialization mechanism for storing and retrieving cached parser state. Buck's parser-cache command deserializes this state without proper validation or filtering of the input. This allows an attacker to inject a malicious serialized object containing code that will be executed during deserialization. The root cause is the lack of a secure deserialization implementation, specifically the absence of any checks or whitelisting of allowed classes during the deserialization process. This allows an attacker to leverage Java's deserialization capabilities to instantiate arbitrary classes and execute their methods, leading to RCE. The flaw resides in the parser-cache command's handling of serialized data, specifically within the BuckParserCache class or related components responsible for loading and saving the cache state.

CVE-2018-6331 - CRITICAL Severity (9.8) | Free CVE Database | 4nuxd