Automated Threat Modeling

MeterSphere CVE-2022-51027: Pre-Auth RCE via /plugin/customMethod, with PoC and Patch Analysis

CVE-2022-51027 is a pre-authentication remote code execution flaw in MeterSphere, caused by anonymous access to /plugin/** endpoints. This post covers the exploitation chain, public PoCs, and the one-line routing fix.

CVE Analysis

7 min read

Gaurav Sarraf
Gaurav Sarraf

2026-11-18

MeterSphere CVE-2022-51027: Pre-Auth RCE via /plugin/customMethod, with PoC and Patch Analysis

Introduction

An unauthenticated attacker who could reach a MeterSphere instance was able to upload a Java archive and have the server run arbitrary code from it, with no credentials required at any point. For a continuous testing platform that often sits inside CI/CD and internal engineering networks, exposing the plugin controller without authentication turned a convenience feature into a direct path to remote code execution.

MeterSphere is an open source continuous testing platform maintained by FIT2CLOUD. It is used for functional, API, and performance testing workflows, and its plugin system extends the platform with custom Java components. Because it typically runs with access to testing infrastructure and internal services, reachability by untrusted users carries real risk.

Technical Information

The root cause of CVE-2022-51027 is a missing authentication control, classified as CWE-306 (Missing Authentication for Critical Function). MeterSphere's Apache Shiro configuration mapped the entire /plugin/** path to the anon (anonymous) filter. In Shiro, any path mapped to anon is served without a logged-in subject, so this single mapping meant that every method on the plugin controller, io.metersphere.controller.PluginController, was reachable without authentication. The handlers themselves were never the weakness. The weakness was that they were exposed to anonymous callers.

Two endpoints form the exploitation chain:

  • POST /plugin/add accepts a multipart file upload. The file is written by io.metersphere.service.PluginService#editPlugin, which calls io.metersphere.commons.utils.FileUtils#create to place the file into /opt/metersphere/data/body/plugin/ (for example <uuid>_test.jar). The JAR is then loaded in-memory via a URLClassLoader in PluginService#getMethod through a loadJar() call, registering arbitrary attacker-supplied classes.
  • POST /plugin/customMethod reaches PluginService#customMethod, where a Class.forName argument is attacker-controlled. This lets the attacker resolve a class from the uploaded JAR and invoke a customMethod function inside it, executing arbitrary Java code.

Attack flow

  1. The attacker compiles an evil class that exposes a customMethod function and packages it as a JAR.
  2. They upload the JAR via POST /plugin/add. Because /plugin/** is anonymous, no authentication is required. The JAR is written to disk and loaded in memory through a URLClassLoader, registering the attacker's class.
  3. They send POST /plugin/customMethod with the entry parameter set to the fully qualified class name and the request parameter carrying input. The entry value flows into Class.forName and the customMethod function is invoked.
  4. The attacker's code runs as the MeterSphere process, which gives remote code execution.

This is the chain documented in the write-up by Y4er, "MeterSphere PluginController Pre-Auth RCE" (2022-01-07), which includes a reproduction screenshot and an affected-version build environment using the v1.16.3 release.

Proof of Concept

Multiple independent, verified public PoCs exist for CVE-2022-51027.

The ProjectDiscovery Nuclei template metersphere-plugin-rce.yaml is marked verified: true with severity critical and tags metersphere,rce,intrusive,vuln. It is a complete, intrusive two-request PoC. The first request uploads an embedded JAR (metersphere-plugin-DebugSampler-1.0.1-jar-with-all-dependencies.jar, delivered as a base64-decoded multipart payload defining io.metersphere.plugin.DebugSampler.UiScriptApiImpl); the second invokes it to execute a command.

The key request bodies are:

POST /plugin/add HTTP/1.1 Host: {{Hostname}} Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryreButJNjkCniQExX ------WebKitFormBoundaryreButJNjkCniQExX Content-Disposition: form-data; name="file"; filename="metersphere-plugin-DebugSampler-1.0.1-jar-with-all-dependencies.jar" Content-Type: application/octet-stream {{base64_decode("UEsDBAoACAgIAOyhUFas...<embedded JAR bytes>...")}} ------WebKitFormBoundaryreButJNjkCniQExX Content-Disposition: form-data; name="request"; filename="blob" Content-Type: application/json null ------WebKitFormBoundaryreButJNjkCniQExX--
POST /plugin/customMethod HTTP/1.1 Host: {{Hostname}} Origin: {{BaseURL}} Content-Type: application/json {"entry":"io.metersphere.plugin.DebugSampler.UiScriptApiImpl","request":"id"}

The template confirms exploitation by matching "success":true and a response body containing the executed id command output, matched via the regex ((u|g)id|groups)=[0-9]{1,4}\([a-z0-9]+\).

As further corroboration, a Goby exploit module (MeterSphere-Remote-Code-Execution.json, author [email protected], mapped to CNVD-2022-01152) marks HasExp: true with a cmd parameter, targeting the same unauthenticated plugin-interface RCE. It uses the FOFA/Goby query app="MeterSphere" || app="FIT2CLOUD-MeterSphere" and recommends upgrading to MeterSphere 1.16.4+.

Patch Information

FIT2CLOUD fixed CVE-2022-51027 by deleting one routing rule. The plugin controller code was left unchanged. Before the fix, the Shiro configuration gave the whole /plugin/** path the anon filter, so Shiro skipped authentication for /plugin/add and /plugin/customMethod. The fix removes that rule, so /plugin/** requests now go through Shiro's normal authentication like the rest of the API.

The security-relevant diff is in backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java, inside loadBaseFilterChain(), which builds the map from URL patterns to Shiro filters:

@@ -71,9 +71,6 @@ public static void loadBaseFilterChain(Map filterChainDefinition //mock接口 filterChainDefinitionMap.put("/mock/**", "anon"); filterChainDefinitionMap.put("/ws/**", "anon"); - - filterChainDefinitionMap.put("/plugin/**", "anon"); - }

The fix landed on two release lines, per OSV's git-range data:

  • 1.15.x / 1.16.x line: commit 07155cf833094f88820ada18af489cedd07d3100, authored 2022-01-05. The commit message translates to "fix(test plan): fix custom plugin security vulnerability and case module matching issue". This line is fixed in 1.16.4.
  • 1.13.x / 1.14.x line (backport): commit 399bd4acff5f38807dae397ca9721b5622e43e64, authored 2022-01-06, making the same three-line deletion at line 69 of the 1.14-line file. This line is fixed in 1.14.7.

Neither commit message mentions the CVE ID. The commit was tied to the CVE later, when the record (assigned by VulnCheck) listed 07155cf833 as the fix reference.

Once the mapping is gone, plugin requests fall through to the authenticated filter chain that already protects the rest of the API, so an unauthenticated client can no longer reach the upload or customMethod handlers. The handlers themselves were not changed, so the patch removes pre-auth reachability but does not change how customMethod resolves and invokes classes for authenticated callers.

Both commits also edit MsHTTPSamplerProxy.java. These edits are not security fixes. In matchConfig(), a fallback was added so that if no test-plan API case is found by ID, the code looks it up by name instead (testPlanApiCase = testPlanApiCase == null ? testPlanApiCaseService.getById(this.getName()) : testPlanApiCase;), which is the "case module matching" fix named in the commit messages. The 1.14 backport also moves the "use the full URL if one is given" check inside the isUrl() branch and removes the matching early return true from isUrl(). Neither change affects the vulnerability. The ShiroUtils.java hunk is the whole security fix.

Affected Systems and Versions

Release lineAffected rangeFixed boundary
MeterSphere 1.131.13.0 up to, but not including, 1.14.71.14.7
MeterSphere 1.151.15.0 up to, but not including, 1.16.41.16.4

Instances running within either range with the /plugin/** endpoints reachable by untrusted users are affected.

Vendor Security History

There is a public record of multiple distinct MeterSphere disclosures. A FIT2CLOUD notice published in January 2023 discusses separate issues reported in December 2022, including CVE-2022-23544, CVE-2022-23512, and CVE-2022-46178, and advises upgrading to secure versions. A later CVE record, CVE-2025-62604, describes a separate logic flaw affecting retrieval of arbitrary user information before version 2.10.25-lts, which is identified as the patched release. These are separate vulnerabilities, and they do not indicate that CVE-2022-51027 affects those later product versions. They show a public history of disclosures and version-based fixes, but the reviewed sources do not support a broader assessment of the vendor's overall security performance.

References

Detect & fix
what others miss

Works with
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps Services
  • Gerrit
  • CVS
  • Jira
  • Linear
  • Slack
  • Security Compass
Explore integrations
Security magnifying glass visualization